Cobbler實現自動化安裝(下)--實現過程

 實驗環境

[root@cobbler ~]# cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core) 
[root@cobbler ~]# ifconfig eno16777736
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.4.116  netmask 255.255.255.0  broadcast 192.168.4.255
        inet6 fe80::20c:29ff:fe93:270f  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:93:27:0f  txqueuelen 1000  (Ethernet)
        ...
[root@cobbler ~]# systemctl stop firewalld.service
[root@cobbler ~]# systemctl disable firewalld.service
[root@cobbler ~]# vim /etc/selinux/config
    ...
    SELINUX=disabled
    ...
[root@cobbler ~]# init 6

1)安裝Cobbler所依賴的相關服務

[root@cobbler ~]# yum -y install tftp tftp-server dhcp httpd  #pxe可經過http或者ftp等方式提供安裝文件
[root@cobbler ~]# yum install -y syslinux  #提供pxe安裝所須要的pxelinux.0等文件
[root@cobbler ~]# vim /etc/dhcp/dhcpd.conf
    option domain-name "test.com";
    option domain-name-servers 8.8.8.8,114.114.114.114;
    default-lease-time 600;
    max-lease-time 7200;
    log-facility local7;
    subnet 192.168.4.0 netmask 255.255.255.0{  #ip地址範圍必須跟本機ip一致
            range 192.168.4.1 192.168.4.100;
            option routers 192.168.4.116;
            filename "pxelinux.0";
            next-server 192.168.4.116;
    }
[root@cobbler ~]# systemctl start dhcpd  #啓動dhcp
[root@cobbler ~]# cat /var/lib/dhcpd/dhcpd.leases  #經過查看該文件能夠看到ip的租借狀況
[root@cobbler ~]# systemctl start httpd tftp.socket  #啓動http,tftp

2)安裝cobbler

一、安裝cobbler,啓動服務,而後執行cobbler check

[root@cobbler ~]# yum -y install cobbler
[root@cobbler ~]# systemctl start cobblerd
[root@cobbler ~]# 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.

二、針對檢查出來的各類報錯進行相應處理

#針對一、二、7進行修改
[root@cobbler ~]# openssl passwd -1 -salt "123456" "zhanfei"  #建立密鑰
    $1$123456$KhkWS/sJLYBtZ7iKPSRxT0
[root@cobbler ~]# vim /etc/cobbler/settings
  ... server: 192.168.4.116 next_server: 192.168.4.116 default_password_crypted: "$1$123456$KhkWS/sJLYBtZ7iKPSRxT0" #此密鑰是安裝系統後root默認密碼
  ... #針對3進行修改 [root@cobbler ~]# vim /etc/xinetd.d/tftp ... disable = no ... #針對4進行修改 [root@cobbler ~]# cobbler get-loaders ... #針對5進行修改 [root@cobbler ~]# systemctl start rsyncd.service [root@cobbler ~]# systemctl disable rsyncd.service ... #實驗不涉及debian系統,第6點能夠不理會 #針對8進行修改 [root@cobbler ~]# yum -y install fence-agents ...

三、重啓cobbler

[root@cobbler ~]# systemctl restart cobblerd
[root@cobbler ~]# cobbler check
    The following are potential configuration items that you may want to fix:

    1 : debmirror package is not installed, it will be required to manage debian deployments and repositories

    Restart cobblerd and then run 'cobbler sync' to apply changes.
[root@cobbler ~]# cobbler sync  #忽略debian的配置

3)配置cobbler

一、建立centos7.2的cobbler對象

[root@cobbler ~]# mount /dev/cdrom /mnt  #掛載centos7.2光驅
[root@cobbler ~]# cobbler import --name=centos-7.2-x86_6 --path=/mnt  #建立cobbler對象組,此過程較耗時
[root@cobbler ~]# cobbler distro list  #查看對應的distribution
    centos-7.2-x86_64

鏡像會被自動導入到/var/www/cobbler/ks_mirror,後續經過http的方式獲取安裝源;linux

默認狀況下,cobbler還會生成一個最小化安裝的kickstart文件,默認是/var/lib/cobbler/kickstarts/sample_end.ks。若是咱們想要自定義的kickstart文件,可進行以下操做:web

[root@cobbler ~]# cp centos7.2.cfg /var/lib/cobbler/kickstarts/  #centos7.2.cfg爲自定義的kickstart文件
[root@cobbler ~]# cobbler profile add --name=centos-7.2-x86_64-custom --distro=centos-7.2-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.2.cfg  #--distro要對應上一步建立的distro對象
[root@cobbler ~]# cobbler profile list
    centos-7.2-x86_64
    centos-7.2-x86_64-custom

檢查httpd和tftp服務相關目錄是否已經建立了相應的文件:vim

[root@cobbler ~]# ll /var/www/cobbler
total 0
drwxr-xr-x. 4 root root 54 Oct 17 16:06 images
drwxr-xr-x. 5 root root 67 Oct 17 16:04 ks_mirror
drwxr-xr-x. 2 root root 54 Oct 17 16:06 links
drwxr-xr-x. 2 root root  6 May 28 20:41 localmirror
drwxr-xr-x. 2 root root 37 Oct 17 10:29 misc
drwxr-xr-x. 2 root root  6 May 28 20:41 pub
drwxr-xr-x. 2 root root  6 May 28 20:41 rendered
drwxr-xr-x. 2 root root  6 May 28 20:41 repo_mirror
drwxr-xr-x. 2 root root 62 Oct 17 10:29 svc
[root@cobbler ~]# ll /var/lib/tftpboot/
total 300
drwxr-xr-x  3 root root     17 Oct 17 15:00 boot
drwxr-xr-x. 2 root root      6 May 28 20:41 etc
drwxr-xr-x. 2 root root     77 Oct 17 15:00 grub
drwxr-xr-x. 4 root root     54 Oct 17 16:06 images
drwxr-xr-x. 2 root root      6 May 28 20:41 images2
-rw-r--r--. 1 root root  26268 Mar  6  2015 memdisk
-rw-r--r--  2 root root  54964 May 10 16:49 menu.c32
drwxr-xr-x. 2 root root      6 May 28 20:41 ppc
-rw-r--r--  2 root root  16794 May 10 16:49 pxelinux.0
drwxr-xr-x. 2 root root     20 Oct 17 15:00 pxelinux.cfg
drwxr-xr-x. 2 root root     25 Oct 17 15:00 s390x
-rw-r--r--  2 root root 198236 May 10 16:49 yaboot

測試安裝:(只測試了cobbler自建的kickstart,成功)centos

二、建立centos6.7的cobbler對象

[root@cobbler ~]# mount /dev/cdrom /mnt  #掛載centos7.2光驅
[root@cobbler ~]# cobbler import --name=centos-6.7-x86_64 --path=/mnt  #建立cobbler對象組
[root@cobbler ~]# cobbler distro list  #查看對應的distribution
    centos-6.7-x86_64
    centos-7.2-x86_64
[root@cobbler ~]# cobbler profile list
    centos-6.7-x86_64
    centos-7.2-x86_64
    centos-7.2-x86_64-custom

測試安裝6.7:成功app

4)cobbler的web管理界面

[root@cobbler ~]# yum -y install cobbler-web
[root@cobbler ~]# vim /etc/cobbler/modules.conf
    ...
    [authentication]
    module = authn_pam   #使用authn_pam,本地用戶認證模塊
    ...
[root@cobbler ~]# useradd cbadmin
[root@cobbler ~]# echo 123456|passwd --stdin cbadmin
    ...
[root@cobbler ~]# vim /etc/cobbler/users.conf
    ...
    [admins]
    admin = "cbadmin" 
[root@cobbler ~]# systemctl restart cobblerd

客戶端測試:(注意是https)dom

相關文章
相關標籤/搜索