• Cobbler无人值守安装系统 安装


    1.Cobbler安装

    1.1设置下主机名 (我的IP是10.0.0.48)

    [root@ cobbler48 ~]# hostnamectl set-hostname cobbler48 

    1.2 安装  启动

    [root@ cobbler48 ~]# yum -y install cobbler cobbler-webtftp-server pykickstart httpd dhc xinetd debmirror
    
    [root@ cobbler48 ~]# systemctl start httpd cobblerd
    [root@ cobbler48 ~]# systemctl enable httpd cobblerd
    Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/sys徐娅 temd/system/httpd.service.
    Created symlink from /etc/systemd/system/multi-user.target.wants/cobblerd.service to /usr/lib/systemd/system/cobblerd.service.  

    安装的组件的作用:

    • cobbler  //程序包
    • cobbler-web //web 界面包
    • tftp-server  //支持tftp服务
    • pykickstart  // 检查kickstart 语法错误
    • httpd //apache
    • dhcp //dhcp服务
    • xinetd // 超级守护进程

      

    1.3 配置Cobbler

    [root@ cobbler48 ~]# cobbler check //检查 看需要修改那些地方
    The following are potential configuration items that you may want to fix:
    
    1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work.  This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.
    2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.
    3 : change 'disable' to 'no' in /etc/xinetd.d/tftp
    4 : Some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely.  Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.
    5 : enable and start rsyncd.service with systemctl
    6 : comment out 'dists' on /etc/debmirror.conf for proper debian support
    7 : comment out 'arches' on /etc/debmirror.conf for proper debian support
    8 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
    9 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
    
    Restart cobblerd and then run 'cobbler sync' to apply changes.

    在更改上卖弄的问题前,需要设置为可以动态设置

    [root@ cobbler48 ~]# sed -ri '/allow_dynamic_settings:/callow_dynamic_settings: 1' /etc/cobbler/settings
    [root@ cobbler48 ~]# grep allow_dynamic_settings /etc/cobbler/settings
    allow_dynamic_settings: 1
    [root@ cobbler48 ~]# systemctl restart cobblerd

    1.3.1

     解决第一个问题 配置server地址 (1: /etc/cobbler/settings中的'server'字段必须设置为本地主机以外的其他内容,否则启动功能将不起作用。这应该是一个可解析的主机名或引导服务器的IP,所有使用它的机器都可以访问它。) /

    [root@ cobbler48 ~]# cobbler setting edit --name=server--value=10.0.0.48 

    1.3.2

    第二个问题 配置next_server地址(2:为了使PXE起作用,“next_server”字段inuld匹配PXE网络上启动服务器的IP)

    [root@ cobbler48 ~]# cobbler setting edit --name=next_server --value=10.0.0.48

    1.3.3 

    第三个问题 配置xinetd管理tftp (3:将/etc/xinetd.d/tftp中的“disable”改为“no”)

    [root@ cobbler48 ~]# sed -ri '/disable/cdisable = no' /etc/xinetd.d/tftp
    [root@ cobbler48 ~]# systemctl enable xinetd
    [root@ cobbler48 ~]# systemctl restart xinetd

    1.3.4

    第四个问题(4:在/var/lib/cobbler/loaders中缺少一些网络引导加载程序,您可以运行'cobbler get-loaders'来下载它们,或者,如果您只想处理x86/x86_64网络引导,您可以确保您已经安装了一个*最新*版本的syslinux包,可以完全忽略这个消息。如果您希望支持所有架构,那么这个目录中的文件应该包括pxelinux。0,菜单。c32 elilo。efi, yaboot。'cobbler get-loaders'命令是解决这些需求的最简单方法。)

    [root@ cobbler48 ~]# cobbler get-loaders // 可能会有点慢,千万不要断开
    task started: 2020-03-03_181702_get_loaders
    task started (id=Download Bootloader Content, time=Tue Mar  3 18:17:02 2020)
    downloading https://cobbler.github.io/loaders/README to/var/lib/cobbler/loaders/README
    downloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
    downloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
    downloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
    downloading https://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
    downloading https://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
    downloading https://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0
    downloading https://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32
    downloading https://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
    downloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
    *** TASK COMPLETE ***
    

      

    1.3.5

    第五个问题 (5:启用并启动rsyncd。服务与systemctl)

    [root@ cobbler48 ~]# systemctl start rsyncd
    [root@ cobbler48 ~]# systemctl enable rsyncd
    Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.
    

      

    1.3.6

    第六个问题(6:注释掉/etc/debmirr .conf上的“用户”,以获得适当的debian支持)

    [root@ cobbler48 ~]#  sed -i 's#@dists="sid";##@dists="sid";#gp' /etc/debmirror.conf
    

      

    1.3.7

    第七个问题(7:注释掉/etc/debmirr .conf上的“拱门”以获得适当的debian支持)

    [root@ cobbler48 ~]# sed -i 's#@arches="i386";##@arches="i386";#g' /etc/debmirror.conf
    

      

    1.3.8

    第八个问题(8:新安装机器的示例模板使用的默认密码(default_password_crypted in /etc/cobbler/settings)仍然设置为“补鞋匠”,应该更改,请尝试:“openssl passwd -1 -salt‘random-phrase-here’‘your-password-here’”以生成新密码)

    [root@ cobbler48 ~]#  openssl passwd -1 -salt `openssl rand -hex 4` '123456'
    $1$1a34d2f0$laBUxra8f0mUlyliQ0P/u0
    [root@ cobbler48 ~]# cobbler setting edit --name=default_password_crypted --value='$1$1a34d2f0$laBUxra8f0mUlyliQ0P/u0'
    

      

    1.3.9第九个问题(9:没有找到击剑工具,需要使用(可选的)电源管理功能。安装cman或栅栏代理来使用它们)

    [root@ cobbler48 ~]# yum -y install fence-agents
    

     1.3  重启服务 检查所有的错误是否都解决了

    [root@ cobbler48 ~]# systemctl restart cobblerd
    [root@ cobbler48 ~]# cobbler sync
    task started: 2020-03-03_185853_sync
    task started (id=Sync, time=Tue Mar  3 18:58:53 2020)
    running pre-sync triggers
    cleaning trees
    removing: /var/lib/tftpboot/pxelinux.cfg/default
    removing: /var/lib/tftpboot/grub/images
    removing: /var/lib/tftpboot/grub/grub-x86.efi
    removing: /var/lib/tftpboot/grub/grub-x86_64.efi
    removing: /var/lib/tftpboot/grub/efidefault
    removing: /var/lib/tftpboot/s390x/profile_list
    copying bootloaders
    trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
    trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
    copying distros to tftpboot
    copying images
    generating PXE configuration files
    generating PXE menu structure
    rendering TFTPD files
    generating /etc/xinetd.d/tftp
    cleaning link caches
    running post-sync triggers
    running python triggers from /var/lib/cobbler/triggers/sync/post/*
    running python trigger cobbler.modules.sync_post_restart_services
    running shell triggers from /var/lib/cobbler/triggers/sync/post/*
    running python triggers from /var/lib/cobbler/triggers/change/*
    running python trigger cobbler.modules.manage_genders
    running python trigger cobbler.modules.scm_track
    running shell triggers from /var/lib/cobbler/triggers/change/*
    *** TASK COMPLETE ***
    [root@ cobbler48 ~]# cobbler check
    No configuration problems found.  All systems go.

    1.4 配置DHCP

    [root@ cobbler48 ~]# cobbler setting edit --name=manage_dhcp --value=1
    [root@ cobbler48 ~]# vim /etc/cobbler/dhcp.template

     

     

    1.5  同步Cobbler配置 

    [root@ cobbler48 ~]#  cobbler sync
    task started: 2020-03-03_192104_sync
    task started (id=Sync, time=Tue Mar  3 19:21:04 2020)
    running pre-sync triggers
    cleaning trees
    removing: /var/lib/tftpboot/pxelinux.cfg/default
    removing: /var/lib/tftpboot/grub/images
    removing: /var/lib/tftpboot/grub/grub-x86.efi
    removing: /var/lib/tftpboot/grub/grub-x86_64.efi
    removing: /var/lib/tftpboot/grub/efidefault
    removing: /var/lib/tftpboot/s390x/profile_list
    copying bootloaders
    trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
    trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
    copying distros to tftpboot
    copying images
    generating PXE configuration files
    generating PXE menu structure
    rendering DHCP files
    generating /etc/dhcp/dhcpd.conf
    rendering TFTPD files
    generating /etc/xinetd.d/tftp
    cleaning link caches
    running post-sync triggers
    running python triggers from /var/lib/cobbler/triggers/sync/post/*
    running python trigger cobbler.modules.sync_post_restart_services
    running: dhcpd -t -q
    received on stdout:
    received on stderr:
    running: service dhcpd restart
    received on stdout:
    received on stderr: Redirecting to /bin/systemctl restart  dhcpd.service
    
    running shell triggers from /var/lib/cobbler/triggers/sync/post/*
    running python triggers from /var/lib/cobbler/triggers/change/*
    running python trigger cobbler.modules.manage_genders
    running python trigger cobbler.modules.scm_track
    running shell triggers from /var/lib/cobbler/triggers/change/*
    *** TASK COMPLETE ***
    [root@ cobbler48 ~]# cat /etc/dhcp/dhcpd.conf //查看是否可以管理DHCP
    # ******************************************************************
    # Cobbler managed dhcpd.conf file
    # generated from cobbler dhcp.conf template (Tue Mar  311:21:05 2020)
    # Do NOT make changes to /etc/dhcpd.conf. Instead, makeyour changes
    # in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be
    # overwritten.
    # ******************************************************************  

    1.6 创建一台新的虚拟机

    文件 ——> 新建虚拟机 ——>下一步——>选择稍后安装操作系统——>下一步——>下一步——>选择路径 然后一直下一步

     

     1.7 开启虚拟机以后,需要关掉光盘连接 (右键 断开连接) 重启 出现蓝色界面 成功

     

     2 安装centos6.1

    2.1 上传镜像 (也可以上传其它Centos6的版本)

    2.2 创建目录 挂载 (挂载成功 可以到创建的目录下查看)

    [root@ cobbler48 ~]# mkdir /centos6.1
    [root@ cobbler48 ~]#  mount -o loop CentOS-6.10-x86_64-bin-DVD1.iso /centos6.1

    2.3 导入镜像 (这一步操作会有些慢 稍安勿躁)

    [root@ cobbler48 centos6.1]# cobbler import --path=/centos6.1 --name=centos6.1 --arch=x86_64

    --path 镜像路径

    --name 给源起一个名字

    --arch 指定安装源是 32位 64位 或者ia64

    2.4  查看profile信息

    [root@ cobbler48 centos6.1]#  cobbler distro report --name=centos6.1-x86_64
    Name                           : centos6.1-x86_64
    Architecture                   : x86_64
    TFTP Boot Files                : {}
    Breed                          : redhat
    Comment                        :
    Fetchable Files                : {}
    Initrd                         : /var/www/cobbler/ks_mirror/centos6.1-x86_64/images/pxeboot/initrd.img
    Kernel                         : /var/www/cobbler/ks_mirror/centos6.1-x86_64/images/pxeboot/vmlinuz
    Kernel Options                 : {}
    Kernel Options (Post Install)  : {}
    Kickstart Metadata             : {'tree': 'http://@@http_server@@/cblr/links/centos6.1-x86_64'}
    Management Classes             : []
    OS Version                     : rhel6
    Owners                         : ['admin']
    Red Hat Management Key         : <<inherit>>
    Red Hat Management Server      : <<inherit>>
    Template Files                 : {}
    
    [root@ cobbler48 centos6.1]# cobbler profile report --name=centos6.1-x86_64
    Name                           : centos6.1-x86_64
    TFTP Boot Files                : {}
    Comment                        :
    DHCP Tag                       : default
    Distribution                   : centos6.1-x86_64
    Enable gPXE?                   : 0
    Enable PXE Menu?               : 1
    Fetchable Files                : {}
    Kernel Options                 : {}
    Kernel Options (Post Install)  : {}
    Kickstart                      : /var/lib/cobbler/kickstarts/sample_end.ks
    Kickstart Metadata             : {}
    Management Classes             : []
    Management Parameters          : <<inherit>>
    Name Servers                   : []
    Name Servers Search Path       : []
    Owners                         : ['admin']
    Parent Profile                 :
    Internal proxy                 :
    Red Hat Management Key         : <<inherit>>
    Red Hat Management Server      : <<inherit>>
    Repos                          : []
    Server Override                : <<inherit>>
    Template Files                 : {}
    Virt Auto Boot                 : 1
    Virt Bridge                    : xenbr0
    Virt CPUs                      : 1
    Virt Disk Driver Type          : raw
    Virt File Size(GB)             : 5
    Virt Path                      :
    Virt RAM (MB)                  : 512
    Virt Type                      : kvm

    2.5 编写kickstarts 文件

    [root@ cobbler48 centos6.1]# cd /var/lib/cobbler/kickstarts/
    [root@ cobbler48 kickstarts]# cp sample_end.ks centos6.1.ks
    [root@ cobbler48 kickstarts]# echo >centos6.1.ks
    [root@ cobbler48 kickstarts]# vim centos6.1.ks
    # This kickstart file should only be used with EL > 5 and/or Fedora > 7.
    # For older versions please use the sample.ks kickstart file.
    # Install OS instead of upgrade
    install
    # Use text mode install
    text
    # System keyboard
    keyboard us
    # System language
    lang en_US
    # System timezone
    timezone  Asia/ShangHai
    #Root password
    rootpw --iscrypted $default_password_crypted
    # System authorization information
    auth  --useshadow  --enablemd5
    # Firewall configuration
    firewall --disabled
    # SELinux configuration
    selinux --disabled
    # Use network installation
    url --url=$tree
    
    # Clear the Master Boot Record
    zerombr
    # System bootloader configuration
    bootloader --location=mbr
    # Partition clearing information
    clearpart --all --initlabel
    part /boot --fstype=ext4 --size=200
    part swap --fstype=swap --size=2048
    part / --fstype=ext4 --grow --size=200 --asprimary
    
    # If any cobbler repo definitions were referenced in the kickstart profile, include them here.
    $yum_repo_stanza
    # Network information
    $SNIPPET('network_config')
    # Do not configure the X Window System
    skipx
    # Run the Setup Agent on first boot
    firstboot --disable
    # Reboot after installation
    reboot
    
    
    %pre
    $SNIPPET('log_ks_pre')
    $SNIPPET('kickstart_start')
    $SNIPPET('pre_install_network_config')
    # Enable installation monitoring
    $SNIPPET('pre_anamon')
    %end
    
    %packages
    $SNIPPET('func_install_if_enabled')
    @core
    @base
    tree
    nmap
    wget
    lftp
    lrzsz
    telnet
    %end
    
    %post --nochroot
    $SNIPPET('log_ks_post_nochroot')
    %end
    
    %post
    $SNIPPET('log_ks_post')
    # Start yum configuration
    $yum_config_stanza
    # End yum configuration
    $SNIPPET('post_install_kernel_options')
    $SNIPPET('post_install_network_config')
    $SNIPPET('func_register_if_enabled')
    $SNIPPET('download_config_files')
    $SNIPPET('koan_environment')
    $SNIPPET('redhat_register')
    $SNIPPET('cobbler_register')
    # Enable post-install boot notification
    $SNIPPET('post_anamon')
    # Start final steps
    $SNIPPET('kickstart_done')
    # End final steps
    
    sed -ri "/^#UseDNS/cUseDNS no" /etc/ssh/sshd_config
    sed -ri "/^GSSAPIAuthentication/cGSSAPIAuthentication no" /etc/ssh/sshd_config
    %end
    

      

    2.6 更新 kickstarts文件 ,验证是否修改成功 ,同步cobbler配置 (每一次修改都要从新同步)

    [root@ cobbler48 kickstarts]# cobbler profile edit --name=centos6.1-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos6.1.ks
    [root@ cobbler48 kickstarts]# cobbler profile report --name=centos6.1-x86_64 |grep Kickstart
    Kickstart                      : /var/lib/cobbler/kickstarts/centos6.1.ks
    Kickstart Metadata             : {}
    [root@ cobbler48 kickstarts]# cobbler sync

    2.7 虚拟机自动安装

     

     3 自动安装Centos7系统  (如果本机是centos7 可以不用上传镜像)

    3.1 创建镜像目录

    [root@ cobbler48 ~]# mkdir centos7.3

    3.2 挂载 常见报错  (找不到镜像) 从新设置一下就好了

    [root@ cobbler48 ~]# mount -o loop /dev/cdrom /centos7.3mount: /dev/sr0: failed to setup loop device: No mediumfound //报错
    

      

     

      

  • 相关阅读:
    jqgrid addRowData报错
    LINE 项目总结
    bootstrap-table 常用总结-树形结构(展开和折叠)
    bootstrap-table 常用总结-树形结构
    为wordpress的分类以及子分类指定固定模版
    wordpress主题开发-部分函数调用整理
    superslide滚动插件使用记录-产品滚动-图片滚动
    4GL之Non-SCROLLING CURSOR
    asp.net报表结构学习记录
    HTML基础教程_1
  • 原文地址:https://www.cnblogs.com/gaiting/p/12404442.html
Copyright © 2020-2023  润新知