One, Cobbler
Cobbler is an open source project developed using Python. It provides a fully automated and batch network installation environment for quickly establishing a Linux system by concentrating all the services involved in the deployment system.
(1) Experiment preparation
- One Linux server and one blank virtual machine
- This experiment uses the configuration of this machine (Centos7 system, IP: 192.168.85.20)
- Need to be connected to the Internet, and all virtual machines use NAT mode
- Related software package Netdisk password: desg
Second, the experimental construction steps
(1) Import the epel source (this source is the relevant software package above)
rpm –ivh epel-release-latest-7.noarch.rpm //安装依赖包
yum list //自动加载在线更新源
(2)#Install Cobbler and its related service packages
yum install -y cobbler dhcp tftp-server pykickstart httpd rsync xinetd
//安装软件包
#各软件作用如下
cobbler //用来快速建立Linux网络安装环境
dhcp //用来为空白主机自动分配IP地址
tftp-server //提供引导镜像文件的下载
pykickstart //实现无人值守安装
httpd //作为控制台程序运行
rsync //实现数据同步
xinetd //提供访问控制、加强的日志和资源管理功能
If the installation package cannot be installed normally, it is recommended to install the online yum source before installing
#阿里云在线yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all && yum makecache //清除刷新yum仓库
(3) Modify the main configuration file of cobbler
vim /etc/cobbler/settings //修改配置文件
(4) Start related services and close the firewall and selinux
systemctl start httpd.service //开启http服务
systemctl start cobblerd.service //开启cobbler服务
systemctl stop firewalld //关闭防火墙
setenforce 0
(5) Use the cobbler check command
Check the settings of Cobbler, and query items that need to be changed.
cobbler check //检查Cobbler配置文件
(6) Modify the configuration file of tftp
vim /etc/xinetd.d/tftp //进入配置文件
(7) Start service
systemctl restart xinetd.service //重启xinetd服务
systemctl start rsyncd.service //重启rsyncd服务
(8) Download the boot operating system file
cobbler get-loaders
(9) Set the initial password of the Cobbler user
使用盐值加密方式生成密钥
openssl passwd -1 -salt 'abc123' 'abc123' //用户:root 密码:abc123
将生成的密钥加入Cobbler配置文件中
vim /etc/cobbler/settings //编辑Cobbler配置文件
(10) Configure dhcp service
vim /etc/cobbler/dhcp.template //编辑dhcp配置文件
cobbler sync //将配置好的模板文件同步到DHCP服务的配置文件中
systemctl restart dhcpd.service //重启DHCP服务
(11) Import ISO image file
mount /dev/sr0 /mnt //挂载镜像文件
cobbler import --path=/mnt/ --name=CentOS-7-x86_64 --arch=x86_64
//导入iso镜像中的Linux 内核、初始化镜像文件
#--path 表示镜像所挂载的目录
#--name 表示为安装源定义的名字
#--atch 表示指定安装源的系统位数
#默认导入存放路径为/var/www/cobbler/ks_mirror/CentOS-7-x86_64
查看内核和初始化文件是否在在tftp-server 共享目录中
yum install -y tree //系统默认没有安装,需手动安装tree
tree /var/lib/tftpboot/images //查看文件是否存在
(12) Restart all services
systemctl restart cobblerd.service //重启cobbled服务
systemctl restart dhcpd.service //重启dhcpd服务
systemctl restart xinetd.service //重启xinetd服务
systemctl restart httpd.service //重启httpd服务
(13) Use cobbler check to check the settings of Cobbler
cobbler check //检查Cobbler配置文件