zoukankan      html  css  js  c++  java
  • cobbler无人值守安装

    环境需求以及实用环境:

    减少重复的机械式工作,例如公司同时上线几十甚至几百台服务器,需要我们在最短时间内完成系统的安装

    下列步骤实现linux系统批量自动安装

    常使用的方法:

    kickstart 和 cobbler

    cobbler是linux服务器的服务,可以通过网络启动(PXE)的方式快速安装,同时还可以管理DHCP和dns

    cobbler可以使用命令行,也支持web页面管理工具

    一、部署cobbler

    [root@localhost ~]# cat /etc/redhat-release 
    CentOS Linux release 7.6.1810 (Core) 
    [root@localhost ~]# uname -r
    3.10.0-957.el7.x86_64
    [root@localhost ~]# getenforce

    关闭防火墙,优化yum源

    curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

    二、安装cobbler

    yum -y install cobbler cobbler-web tftp-server pykickstart httpd dhcp xinetd debmirror
    systemctl start httpd cobblerd
    
    systemctl enable httpd cobblerd

    三、运行cobbler check进行环境检查

    # 执行Cobbler check 检查目前环境还缺少哪些东西
    [root@localhost ~]#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 : debmirror package is not installed, it will be required to manage debian deployments and repositories
    7 : 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
    8 : 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.

    1、第一个问题,在 /etc/cobbler/settings 配置文件中的服务器字段中一定要有一个其他主机能够访问到的ip地址

    [root@localhost ~]#systemctl restart cobblerd
    [root@localhost ~]#cobbler sync

    再将next_server 的地址修改为本机地址

    # 可以看到 /var/lib/cobbler/loaders 目录下没有任何内容
    [root@localhost ~]#ls /var/lib/cobbler/loaders
    [root@localhost ~]#cobbler get-loaders
    task started: 2017-09-20_084605_get_loaders
    task started (id=Download Bootloader Content, time=Wed Sep 20 08:46:05 2017)
    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 ***
    sed -ri '/allow_dynamic_settings:/callow_dynamic_settings: 1' /etc/cobbler/settings
    
    grep allow_dynamic_settings /etc/cobbler/settings
    
    systemctl restart cobblerd
    
    cobbler setting edit --name=server --value=192.168.37.34
    cobbler setting edit --name=next_server --value=192168.37.34
    sed -ri '/disable/cdisable = no' /etc/xinetd.d/tftp
     sed -i 's#@dists="sid";##@dists="sid";#gp' /etc/debmirror.conf
     sed -i 's#@arches="i386";##@arches="i386";#g' /etc/debmirror.conf
    
    openssl passwd -1 -salt `openssl rand -hex 4` '123456'
    cobbler setting edit --name=default_password_crypted --value='$1$random-p$mzxQ/Sx848sXgvfwJCoZM0'
    
    yum -y install fence-agents
    
    ystemctl restart cobblerd
    systemctl enable xinetd
    systemctl restart xinetd

    2、修改cobbler下/etc/cobbler/dhcp.template文件

    # 在/etc/cobbler/dhcp.template 找到下面地这段内容进行修改整理。 
    # 按照自己地要求进行DHCP地配置。
    
    subnet 172.18.2.0 netmask 255.255.255.0 {
         option subnet-mask         255.255.255.0;
         range dynamic-bootp        172.18.2.100 172.18.2.254;
         default-lease-time         21600;
         max-lease-time             43200;
         next-server                $next_server;
         class "pxeclients" {
              match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
              if option pxe-system-type = 00:02 {
                      filename "ia64/elilo.efi";
              } else if option pxe-system-type = 00:06 {
                      filename "grub/grub-x86.efi";
              } else if option pxe-system-type = 00:07 {
                      filename "grub/grub-x86_64.efi";
              } else {
                      filename "pxelinux.0";
              }
         }
    
    }

     最后重启

    systemctl restart cobblerd
    cobbler sync

    四、点击安装系统

    cobbler profile edit --name=centos6.8-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos6.8.ks
    
    cobbler profile report --name=centos6.8-x86_64 |grep Kickstart
    cobbler sync

     

  • 相关阅读:
    看代码写程序
    NP
    一道神题
    找平方数
    凝视
    排队打水
    时间计算
    git客户端下载地址
    iOS GCD
    UIView 和 CALayer的那点事
  • 原文地址:https://www.cnblogs.com/security-guard/p/12396699.html
Copyright © 2011-2022 走看看