安裝基本環境(可忽略)
yum groupinstall "Compatibility libraries" "Base" "Development tools" "debugging Tools" "Dial-up Networking Support" yum install tree nmap sysstat lrzsz dos2unix -y
建議使用清華源
[root@localhost ~]# yum install epel-release #安裝epel源
安裝cobbler程序包
[root@localhost ~]# yum install cobbler dhcp tftp-server pykickstart httpd
啓動Cobbler等程序
[root@localhost ~]# setenforce 0 [root@localhost ~]# service iptables stop;chkconfig iptables off [root@localhost ~]# chkconfig cobblerd on [root@localhost ~]# chkconfig httpd on;service httpd restart
配置Cobbler程序
[root@localhost yum.repos.d]# cobbler check
解決報錯
第一步+第二步 [root@localhost ~]# cat -n /etc/cobbler/settings 272 next_server: 192.168.1.1 384 server: 192.168.1.1 242 manage_dhcp: 1 第三步: [root@localhost ~]# cat -n /etc/selinux/config 7 SELINUX=disabled 第四步: [root@localhost ~]# vim /etc/xinetd.d/tftp 14 disable= no 第五步: [root@localhost ~]# cobbler get-loaders 第六步: [root@localhost ~]# cat -n /etc/xinetd.d/rsync 6 disable= no [root@localhost ~]# service xinetd restart [root@localhost ~]# chkconfig xinetd on 第七步:這是個BUG [root@localhost ~]# yum install debmirror -y [root@localhost ~]# vim /etc/debmirror.conf 28 #@dists="sid"; 29 @sections="main,main/debian-installer,contrib,non-free"; 30 #@arches="i386"; 第九步: [root@localhost ~]# openssl passwd -1 -salt 'suijishuru' 'Cobb_01!' $1$suijishu$J0AUTQIBV0QGeZvVkIT0G. [root@localhost ~]# cat /etc/cobbler/setting 101 default_password_crypted: "$1$suijishu $J0AUTQIBV0QGeZvVkIT0G." 第十步: [root@localhost ~]# yum install fence-agents -y##這個工具會安裝一些硬件管理工具,ipmitools等
配置DHCP
這裏在之前已經開啓了manage_dhcp,所以需要修改cobbler下的dhcp模板,不能修改dhcp的默認配置文件,因爲修改cobbler的模板後,cobbler sync後會將cobbler-dhcp模板裏的信息寫入到dhcp默認配置文件
[root@localhost ~]# vim /etc/cobbler/dhcp.template 21 subnet 192.168.1.0 netmask 255.255.255.0 { 22 option routers 192.168.1.1; 23 option domain-name-servers 8.8.8.8; 24 option subnet-mask 255.255.255.0; 25 range dynamic-bootp 192.168.1.100 192.168.1.220;
同步cobbler,並再次檢查
[root@localhost ~]# cobbler sync [root@localhost ~]# service cobblerd restart [root@localhost ~]# cobbler check
測試Cobbler是否可進行引導
注意關閉VMware裏虛擬網絡編輯器裏的DHCP功能
測試新建虛擬機,網卡模式與Cobbler一個通道,設置網絡啓動
Cobbler命令獲取幫助
導入放置ISO鏡像
[root@localhost ~]# mount /dev/cdrom /mnt [root@localhost ~]# cobbler import --path=/mnt/ --name= CentOS-7.2-x86_64 --arch=x86_64 [root@localhost ~]# cobbler import --path=/mnt/ --name= CentOS-6.5-x86_64 --arch=x86_64 ##需要再次掛載
查看當前cobbler發行鏡像列表
[root@localhost ~]# cobbler distro list ##這裏的列表應該和cobbler顯示界面的是一致的 CentOS-6.5-x86_64 CentOS-7.2-x86_64 images-x86_64
查看cobbler列表裏的鏡像的cobbler參數配置
[root@localhost kickstarts]# cobbler profile report Name : CentOS-7.2-x86_64 TFTP Boot Files : {} Comment : DHCP Tag : default Distribution : CentOS-7.2-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 Distribution : CentOS-6.5-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
實現自動化安裝,指定ks.cfg文件
無人值守文件存放目錄 /var/lib/cobbler/kickstarts/
cobbler profile edit --name=CentOS-6.5-x86_64 --kickstart=/var/lib/cobbler/kickstarts/Centos6.5.cfg
Centos7指定無人值守文件,並修改內核使網卡接口更改爲eth0
cobbler profile edit --name=CentOS-7.2-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS7.2.cfg --kopts='net.ifnames=0 biosdevname=0'
指定完kickstart文件後,即可實現無人值守安裝,如果不指定自定義的kickstart文件默認使用/var/lib/cobbler/kickstarts/下的sample_end.ks來無人值守安裝
關於kickstart文件小技巧
[root@localhost kickstarts]# vim Centos6.5.cfg ... url --url=$tree #url --url="http://192.168.1.1/CentOS-6.5-X86_64" ... 可以不再使用網絡路徑,不再手動指定路徑 ... rootpw --iscrypted $default_password_crypted #rootpw --iscrypted $1$Wpkdx1Ru$Uw8R9RAJV6fbt/Gm1trwj0 ... 調用/etc/cobbler/settings裏的default_password_crypted密碼 ... unsupported_hardware 該參數可以忽略對硬件的檢查 ...
補充一下吧,關於自動化部署,其實還可以依賴pxe的方式,但是相對pxe的方式操作太過複雜,並且功能不如cobbler強大,cobbler可以部署多種版本linux,但是無人值守是需要kickstart作支持的