基于cobbler实现自动安装系统

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cx55887/article/details/82865192

说明:安装cobbler、dhcp、tftp的虚拟机两块网卡eth0:10.220.5.117(桥接)用于连接xshell,eth1:192.168.100.86(vmnet3)作为自动安装系统的服务器使用。

一、安装配置cobbler

cobbler安装和基本配置

二、安装配置dhcp

1.安装dhcp

[root@BIGboss ~]# yum install dhcp dhcp-common -y

2.配置dhcp

root@BIGboss ~]# 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

[root@BIGboss ~]# service dhcpd restart

三、安装配置tftp

1.安装

[root@BIGboss ~]# yum install tftp tftp-server xinetd -y

2.启动

[root@BIGboss ~]# service xinetd restart
[root@BIGboss ~]# chkconfig xinetd on
[root@BIGboss ~]# chkconfig tftp on
[root@BIGboss ~]# chkconfig --list | grep tftp
	tftp:          	on

四、以导入的方式创建repo

1.挂在光盘

[root@BIGboss ~]# mount /dev/cdrom /mnt/

2.在cobbler中导入镜像数据

[root@BIGboss ~]# cobbler import --path=/mnt/ --name=centos6.7_x86-64

导入需要一定时间耐心等待一下

3.执行一次sync

扫描二维码关注公众号,回复: 3748109 查看本文章
[root@BIGboss ~]# cobbler sync

五、创建repo和distro

导入了镜像会自动生成与之对应的profile和distro

[root@BIGboss ~]# cobbler distro list
   centos6.7-64-x86_64
[root@BIGboss ~]# 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文件放在规定的位置

[root@BIGboss ~]# mv ks1.cfg /var/lib/cobbler/kickstarts/

七、创建profile

1.创建profile

[root@BIGboss ~]# cobbler distro list
   centos6.7-64-x86_64
[root@BIGboss ~]# cobbler profile add --distro=centos6.7-64-x86_64  --kickstart=/var/lib/cobbler/kickstarts/ks1.cfg --name=profile_for_centos6

2.执行一次sync

[root@BIGboss ~]# cobbler sync

八、测试

新开一台虚拟机,设置网络连接为vmnet3,开机就会自动安装系统了

猜你喜欢

转载自blog.csdn.net/cx55887/article/details/82865192