实现cobbler+pxe自动化装机

实现cobbler+pxe自动化装机

注意:因为本实验将在Cobbler服务器上开启DHCP服务和PXE自动安装操作系统,因此禁止在任何公司或生产网络进行。
否则,如果其他主机的PXE启动项刚好是默认选项,而且刚好重启,那么那些主机将可能通过PXE完成自动安装覆盖原操作系统。

建议Cobbler服务器是一个CentOS 7的虚拟机,通过NAT模式在PC机Workstation下运行。由于存在NAT,不影响该PC机所在网络的其他主机。 请谨慎操作,后果自负。

  1. 将预装的CentOS7 的网卡调整到NAT模式
    在这里插入图片描述
    在这里插入图片描述
  2. 安装epel源,因为cobbler安装包需要epel源
    yum install -y epel-release

在这里插入图片描述
在这里插入图片描述默认没有dhcpd服务器,因此单独安装
在这里插入图片描述
3. 安装后对cobbler所在操作系统配置

[root@localhost ~]# vi /etc/selinux/config 

在这里插入图片描述

[root@localhost ~]# reboot
[root@localhost ~]# systemctl start cobblerd httpd tftp dhcpd
Job for dhcpd.service failed because the control process exited with error code. See "systemctl status dhcpd.service" and "journalctl -xe" for details.

dhcpd启动有些问题,先放一边
在这里插入图片描述
在这里插入图片描述

[root@localhost ~]# vim /etc/cobbler/settings 

next_server: 127.0.0.1 -> next_server: 192.168.75.131
server: 127.0.0.1 > server: 192.168.75.131
manage_dhcp: 0 -> manage_dhcp: 1

注意:该配置文件也定义了通过Cobbler管理的PXE自动化安装的新操作系统的root默认密码是cobbler

[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]# cobbler get-loaders

在这里插入图片描述
在这里插入图片描述
4. 执行cobbler sync命令
把刚才cobbler下载的文件都拷贝到tftp目录,未来用于安装阶段的引导菜单和引导程序
在这里插入图片描述5. 开始配置dhcpd服务

[root@localhost ~]# vi /etc/cobbler/dhcp.template 

因为上面配置了让cobbler托管dhcpd服务,直接修改 cobbler目录下的dhcpd.conf模板,后面会自动覆盖到 /etc/dhcp/dhcpd.conf
修改内容就是要和Cobbler服务器所在的IP网段匹配,网关和DNS服务器都指向网段的网关(这里就是运行workstation的PC机的虚拟网卡的IP地址192.168.75.1/24)
在这里插入图片描述

[root@localhost ~]# systemctl start dhcpd
[root@localhost ~]# cat /etc/dhcp/dhcpd.conf 

在这里插入图片描述
重新运行cobbler sync命令,更新配置

[root@localhost ~]# cobbler sync

在这里插入图片描述
[root@localhost ~]# tree /var/lib/tftpbo

在这里插入图片描述

[root@localhost ~]# tree /var/www/cobbler/

在这里插入图片描述在这里插入图片描述
6. 调试功能
尝试用一个空白的VM进行PXE启动,但发现TFTP服务超时

在这里插入图片描述排查后发现是默认的防火墙阻断了服务,
[root@localhost ~]# systemctl disable firewalld

[root@localhost CentOS7-x86_64]# systemctl stop cobblerd dhcpd tftp httpd
[root@localhost CentOS7-x86_64]# systemctl start cobblerd dhcpd tftp httpd

然后重新尝试,发现成功

在这里插入图片描述
7. 挂载光盘镜像,通过TFTP对外提供服务
下一步就是把centos 安装镜像 复制到tftp目录,让PXE客户端通过网络直接获取

在Cobbler服务器上,加载光盘,挂载到/mnt

[root@localhost mnt]# mount /dev/sr0 /mnt

在这里插入图片描述
用cobbler命令 加载

[root@localhost mnt]# cobbler import --path=/mnt/ --name=CentOS7 --arch=x86_64

在这里插入图片描述
上述过程其实是在将光盘拷贝到 cobbler的http文件 目录/var/www/cobbler目录

在这里插入图片描述
8. 一切就绪,开始启动空白虚拟机

在这里插入图片描述
在这里插入图片描述在这里插入图片描述在这里插入图片描述
如前所述,由于在cobbler/settings文件中使用默认的cobbler作为root密码。

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值