基于cobbler实现自动安装系统
说明:安装cobbler、dhcp、tftp的虚拟机两块网卡eth0:10.220.5.117(桥接)用于连接xshell,eth1:192.168.100.86(vmnet3)作为自动安装系统的服务器使用。
一、安装配置cobbler
二、安装配置dhcp
1.安装dhcp
[[email protected] ~]# yum install dhcp dhcp-common -y
2.配置dhcp
[email protected] ~]# vim /etc/dhcp/dhcpd.conf
【只需要如下内容,其他的都可以删除】
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 192.168.100.0 netmask 255.255.255.0 {
range 192.168.100.200 192.168.100.220;
option routers 192.168.100.86;
option domain-name-servers 8.8.8.8;
filename "pxelinux.0";
}
3.重启dhcp
[[email protected] ~]# service dhcpd restart
三、安装配置tftp
1.安装
[[email protected] ~]# yum install tftp tftp-server xinetd -y
2.启动
[[email protected] ~]# service xinetd restart
[[email protected] ~]# chkconfig xinetd on
[[email protected] ~]# chkconfig tftp on
[[email protected] ~]# chkconfig --list | grep tftp
tftp: on
四、以导入的方式创建repo
1.挂在光盘
[[email protected] ~]# mount /dev/cdrom /mnt/
2.在cobbler中导入镜像数据
[[email protected] ~]# cobbler import --path=/mnt/ --name=centos6.7_x86-64
导入需要一定时间耐心等待一下
3.执行一次sync
[[email protected] ~]# cobbler sync
五、创建repo和distro
导入了镜像会自动生成与之对应的profile和distro
[[email protected] ~]# cobbler distro list
centos6.7-64-x86_64
[[email protected] ~]# cobbler profile list
centos6.7-64-x86_64
补充:
1.导入镜像就是将镜像中的文件复制到/var/www/cobbler/ks_mirror/centos6.7_x86-64/
2.安装了cobbler之后,会自动生成一个apache的子配置文件cobbler.conf,用于将上面的目录发布出去,在这个文件中定义了别名,实现可以通过http://ip/cobbler就可以访问cobble的镜像资源
测试所导入的镜像
通过浏览器访问:http://10.220.5.117/cobbler
六、准备kickstart文件
1.ks1.cfg
此时安装树文件所在位置http://192.168.100.86/cobbler/ks_mirror/centos6.7_x86-64/
所以应该把ks1.cfg模板中的url --url=http://192.168.100.85/installtree/
改为http://192.168.100.86/cobbler/ks_mirror/centos6.7_x86-64/
2.将ks文件放在规定的位置
[[email protected] ~]# mv ks1.cfg /var/lib/cobbler/kickstarts/
七、创建profile
1.创建profile
[[email protected] ~]# cobbler distro list
centos6.7-64-x86_64
[[email protected] ~]# cobbler profile add --distro=centos6.7-64-x86_64 --kickstart=/var/lib/cobbler/kickstarts/ks1.cfg --name=profile_for_centos6
2.执行一次sync
[[email protected] ~]# cobbler sync
八、测试
新开一台虚拟机,设置网络连接为vmnet3,开机就会自动安装系统了