Introduction: we may not encounter the need for my automatic installation of Centos system in our life, because one or two completely their own manual solution, but we may encounter a large number of work, 100, 200. Then we can use this way of automatic deployment to greatly increase our work efficiency! Blah, blah, blah, blah, blah, blah, blah, blah!
1. Deploy DHCP and configure it.
The purpose of DHCP is to automatically assign IP addresses to the VMS we want to install. We no longer need to manually configure IP addresses.
[root@a ~]# yum install -y dhcp
[root@a ~]# vim /etc/dhcp/dhcpd.conf
allow booting;
allow bootp;
ddns-update-style interim;
ignore client-updates;
subnet 192.16810.. 0 netmask 255.255255.. 0 {
option subnet-mask 255.255255.. 0;
option domain-name-servers 192.16810.10.;
range dynamic-bootp 192.16810.100. 192.16810.200.;
default-lease-time 21600;
max-lease-time 43200;
next-server 192.16810.10.;
filename "pxelinux.0";
}
[root@a ~]# systemctl restart dhcpd
[root@a ~]# systemctl enable dhcpd
Copy the code
2. Configure the TFTP service
[root@a ~]# yum install -y tftp-server
[root@a ~]# vim /etc/xinetd.d/tftp
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
**disable = no**
per_source = 11
cps = 100 2
flags = IPv4
}
[root@a ~]# systemctl restart tftp
[root@a ~]# systemctl enable tftp
Created symlink from /etc/systemd/system/sockets.target.wants/tftp.socket to /usr/lib/systemd/system/tftp.socket.
Copy the code
3. Deploy sysLinux and configure it
[root@a ~]# yum install -y syslinux
[root@a ~]# cd /var/lib/tftpboot/
[root@a tftpboot]# cp /usr/share/syslinux/pxelinux. 0 .
[root@a tftpboot]# cp /mnt/images/pxeboot/{vmlinuz,initrd.img} .
[root@a tftpboot]# cp /mnt/isolinux/{vesamenu.c32,boot.msg} .
[root@a tftpboot]# mkdir pxelinux.cfg
[root@a tftpboot]# cp /mnt/isolinux/isolinux.cfg pxelinux.cfg/default
[root@a tftpboot]# vim pxelinux.cfg/default
1 default linux
64 append initrd=initrd.img inst.stage2=ftp:/ / 192.168.10.10
/pub/ks.cfg quiet
Copy the code
4. Configure the Vsftpd service and configure the firewall and Selinux
[root@a tftpboot]# systemctl restart vsftpd
[root@a tftpboot]# systemctl enable vsftpd
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.
[root@a tftpboot]# cp -r /mnt/* /var/ftp
[root@a tftpboot]# systemctl stop firewalld
[root@a tftpboot]# setenforce 0
Copy the code
5. Create the Kickstart reply file
[root@a tftpboot]# cp ~/anaconda-ks.cfg /var/ftp/pub/ks.cfg
[root@a tftpboot]# chmod +r /var/ftp/pub/ks.cfg
[root@a tftpboot]# vim /var/ftp/pub/ks.cfg
5 url --url=ftp:/ / 192.168.10.10
25 timezone Asia/Shanghai --isUtc
30 clearpart --all --initlabel
Copy the code
Finally, create virtual machine, virtual machine can automatically install centos system!
Done!! Please, please!!