实验 pxe 实现系统自动化安装

nmcli con modify ens34 ipv4.method manual ipv4.address 192.168.183.131/24
手动分配ip
1 yum install vsftpd tftp-server dhcp syslinux
2 systemctl start tftp vsftpd
3 cp /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.conf 配置dhcp服务
vi /etc/dhcp/dhcpd.conf
subnet 192.168.184.0 netmask 255.255.255.0 {
range 192.168.184.150 192.168.184.160;
filename “pxelinux.0”;
next-server 192.168.184.131;
}
systemctl start dhcpd
mkdir /var/ftp/pub/c6
mkdir /var/ftp/pub/c7
mount /dev/sr0 /var/ftp/pub/c6
mount /dev/sr1 /var/ftp/pub/c7
mkdir /var/ftp/pub/ks-6
mkdir /var/ftp/pub/ks-7
mv anaconda.ks.cfg /var/ftp/pub/ks-6/centos6.cfg
mv anaconda.ks.cfg /var/ftp/pub/ks-7/centos7.cfg
vi /var/ftp/pub/ks-6/centos6.cfg
url –url=http://192.168.8.131/pub/c6
vi /var/ftp/pub/ks-7/centos7.cfg
url –url=http://192.168.8.131/pub/c7
chmod a+r /var/www/html/ks-7/centos7.cfg
chmod a+r /var/www/html/ks-6/centos6.cfg
mkdir /var/lib/tftpboot/pxelinux.cfg/

mkdir /var/lib/tftpboot/centos6
mkdir /var/lib/tftpboot/centos7
cp /var/ftp/pub/c6/isolinux/vmlinuz /var/lib/tftpboot/centos6
cp /var/ftp/pub/c6/isolinux/initrd.img /var/lib/tftpboot/centos6

cp /var/ftp/pub/c7/isolinux/vmlinuz /var/lib/tftpboot/centos7
cp /var/ftp/pub/c7/isolinux/initrd.img /var/lib/tftpboot/centos7
cp /usr/share/syslinux/{pxelinux.0,menu.c32} /var/lib/tftpboot/
cp /var/ftp/pub/c7/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
vi /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
timeout 600

menu title PXE CentOS Linux 7 and 6 Install Menu
label autocentos7
menu label ^Automatic Mini Install CentOS 7
kernel centos7/vmlinuz
append initrd=centos7/initrd.img ks=ftp://192.168.184.131/pub/ks-7/centos7.cfg
label autocentos6
menu label Automatic ^Desktop Install CentOS 6
kernel centos6/vmlinuz
append initrd=centos6/initrd.img ks=ftp://192.168.184.131/pub/ks-6/centos6.cfg

实现cobbler

nmcli connection modify ens34 ipv4.method manual ipv4.address
192.168.184.131/24 配置ip

yum install cobbler dhcp

systemctl start cobblerd dhcpd httpd tftp 启动服务
2 cobbler check 检查条件
*1 : The ‘server’ field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work. This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.
*2 : For PXE to be functional, the ‘next_server’ field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.
3 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
https://github.com/cobbler/cobbler/wiki/Selinux
4 : change ‘disable’ to ‘no’ in /etc/xinetd.d/tftp
5 : some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run ‘cobbler get-loaders’ to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent version of the syslinux package installed and can ignore this message entirely. Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The ‘cobbler get-loaders’ command is the easiest way to resolve these requirements.
6 : enable and start rsyncd.service with systemctl
7 : debmirror package is not installed, it will be required to manage debian deployments and repositories
*8 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to ‘cobbler’ and should be changed, try: “openssl passwd -1 -salt ‘random-phrase-here’ ‘your-password-here’” to generate new one
9 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

Restart cobblerd and then run ‘cobbler sync’ to apply changes.
3 vim /etc/cobbler/settings 配置cobbler设置
next_server: 192.168.8.100
manage_dhcp: 1 dhcp受其管理
server: 192.168.8.100
default_password_crypted: “ 1 FJZMSs1z$V4P4ZL/EPhSRIWi3ZLr3m.” #openssl passwd -1 生成密令

配置dhcp服务
vim /etc/cobbler/dhcp.template
subnet 192.168.8.0 netmask 255.255.255.0 {
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.8.10 192.168.8.20

systemctl restart cobblerd
cobbler sync 同步设置

5 导入系统安装源文件
cobber import –path=/misc/cd –name=centos7.3
cobber import –path=/mnt/cd –name=centos6.9

6 定制kickstart
cobbler profile list 列出ks文件
cobbler profile remove –name=centos7.3-x86_64

cp centos7.cfg centos6.cfg /var/lib/cobbler/kickstarts/
添加自己配置的kickstart
cobbler profile add –name=centos7.3-custom –kickstart=/var/lib/cobbler/kickstarts/centos7.cfg –distro=centos7.3-x86_64

cobbler profile add –name=centos6.9-custom –kickstart=/var/lib/cobbler/kickstarts/centos6.cfg –distro=centos6.9-x86_64

cat /var/lib/tftpboot/pxelinux.cfg/default

vim /var/lib/cobbler/kickstarts/centos7.cfg
url –url=http://192.168.184.131/cblr/links/centos7.3-x86_64

vim /var/lib/cobbler/kickstarts/centos6.cfg
url –url=http://192.168.184.131/cblr/links/centos6.9-x86_64

若是自己配置的kickstart文件则添加这行,否则使用
url –url=$tree

猜你喜欢

转载自blog.csdn.net/qq_42635996/article/details/82118646