1.系統環境
[root@localhost ~]# cat /etc/redhat-release
CentOS release 6.9 (Final)
[root@localhost ~]# uname -r
2.6.32-696.23.1.el6.x86_64
[root@localhost ~]# getenforce 必須關閉SELINUX
Disabled
[root@localhost ~]# /etc/init.d/iptables status 關閉防火牆
iptables: Firewall is not running.
[root@CentOS6 ~]# ifconfig eth0|awk -F "[ :]+" 'NR==2 {print $4}'
192.168.252.130
[root@localhost ~]# hostname
localhost.localdomain
[root@localhost ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repopython
2.安裝Cobbler
[root@localhost ~]# yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpdlinux
[root@localhost ~]# rpm -ql cobbler # 查看安裝的文件,下面列出部分。
/etc/cobbler # 配置文件目錄
/etc/cobbler/settings # cobbler主配置文件,這個文件是YAML格式,Cobbler是python寫的程序。
/etc/cobbler/dhcp.template # DHCP服務的配置模板
/etc/cobbler/tftpd.template # tftp服務的配置模板
/etc/cobbler/rsync.template # rsync服務的配置模板
/etc/cobbler/iso # iso模板配置文件目錄
/etc/cobbler/pxe # pxe模板文件目錄
/etc/cobbler/power # 電源的配置文件目錄
/etc/cobbler/users.conf # Web服務受權配置文件
/etc/cobbler/users.digest # 用於web訪問的用戶名密碼配置文件
/etc/cobbler/dnsmasq.template # DNS服務的配置模板
/etc/cobbler/modules.conf # Cobbler模塊配置文件
/var/lib/cobbler # Cobbler數據目錄
/var/lib/cobbler/config # 配置文件
/var/lib/cobbler/kickstarts # 默認存放kickstart文件
/var/lib/cobbler/loaders # 存放的各類引導程序
/var/www/cobbler # 系統安裝鏡像目錄
/var/www/cobbler/ks_mirror # 導入的系統鏡像列表
/var/www/cobbler/images # 導入的系統鏡像啓動文件
/var/www/cobbler/repo_mirror # yum源存儲目錄
/var/log/cobbler # 日誌目錄
/var/log/cobbler/install.log # 客戶端系統安裝日誌
/var/log/cobbler/cobbler.log # cobbler日誌web
1.3 配置Cobblerapp
[root@localhost ~]# cobbler check cp /etc/cobbler/settings{,.ori} #備份 sed -i 's/server: 127.0.0.1/server: 192.168.252.130/' /etc/cobbler/settings #服務端IP sed -i 's/next_server: 127.0.0.1/next_server: 192.168.252.130/' /etc/cobbler/settings #服務端IP sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings #dhcp只獲取一次 sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings #cobbler只執行一遍 sed -ri "/default_password_crypted/s#(.*: ).*#\1\"`openssl passwd -1 -salt 'admin' '123456'`\"#" /etc/cobbler/settings #設置密碼爲123456 sed -i 's#yes#no#' /etc/xinetd.d/rsync #xinet 管理rsync sed -i 's#yes#no#' /etc/xinetd.d/tftp #xinet 管理tftp cobbler get-loaders #下載 sed -i 's#192.168.1#192.168.252#g;22d;23d' /etc/cobbler/dhcp.template # 修改dhcp配置文件 cobbler sync #寫入磁盤 /etc/init.d/xinetd restart #啓動三個必須啓動的服務。詳情請看kickstart /etc/init.d/cobblerd restart /etc/init.d/httpd restart cobbler sync # 同步 掛載光盤: [root@localhost ~]# mount /dev/cdrom /mnt/ 製做鏡像導入到 cobbler [root@localhost ~]# cobbler import --path=/mnt/ --name=CentOS-6-x86_64 --arch=x86_64 --path= 路徑 --name=名稱 --arch=系統位數32 or 64 導入的位置 [root@localhost ks_mirror]# pwd /var/www/cobbler/ks_mirror [root@localhost ks_mirror]# ls CentOS-7-x86_64 config 查看 cobbler命令 [root@localhost /]# cobbler profile usage ===== cobbler profile add cobbler profile copy cobbler profile dumpvars cobbler profile edit cobbler profile find cobbler profile getks cobbler profile list cobbler profile remove cobbler profile rename cobbler profile report 查看鏡像 [root@localhost /]# cobbler profile list CentOS-6-x86_64 查看系統詳細信息 [root@localhost /]# cobbler profile report kickstarts文件放在/var/lib/cobbler/kickstarts下面 [root@localhost ~]# cd /var/lib/cobbler/kickstarts/ [root@localhost kickstarts]# rz - 自定義kickstarts文件 咱們使用cobbler profile report命令看到Kickstart默認在/var/lib/cobbler/kickstarts/sample_end.ks 咱們直接使用命令進行修改,咱們修改6的kickstarts [root@localhost /]# cobbler profile edit --name=CentOS-6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-6-x86_64.cfg 同步配置 [root@localhost /]# cobbler sync CentOS-6.8-x86_64.cfg 配置文件 install url --url=$tree text lang en_US.UTF-8 keyboard us zerombr bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet" $SNIPPET('network_config') timezone --utc Asia/Shanghai authconfig --enableshadow --passalgo=123456 rootpw --iscrypted $123456 clearpart --all --initlabel part /boot --fstype=ext4 --asprimary --size=200 part swap --size=1024 part / --fstype=ext4 --grow --asprimary --size=200 firstboot --disable selinux --disabled firewall --disabled logging --level=info reboot %pre $SNIPPET('log_ks_pre') $SNIPPET('kickstart_start') $SNIPPET('pre_install_network_config') # Enable installation monitoring $SNIPPET('pre_anamon') %end %packages @base @compat-libraries @debugging @development tree nmap sysstat lrzsz dos2unix 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 %end