安装基本环境(可忽略)
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 : <> Name Servers : [] Name Servers Search Path : [] Owners : ['admin'] Parent Profile : Internal proxy : Red Hat Management Key : < > Red Hat Management Server : < > Repos : [] Server Override : < > 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 : < > Name Servers : [] Name Servers Search Path : [] Owners : ['admin'] Parent Profile : Internal proxy : Red Hat Management Key : < > Red Hat Management Server : < > Repos : [] Server Override : < > 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作支持的