部署過程基於centos7
環境準備
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# getenforce
準備安裝源
安裝DHCP服務
[root@localhost ~]# yum install dhcp ntpdate syslinux -y
[root@localhost ~]# timedatectl set-timezone Asia/Shanghai
[root@localhost ~]# ntpdate time.windows.com
[root@localhost ~]# cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bak_$(date +%Y-%m-%d-%H-%M)
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 192.168.217.0 netmask 255.255.255.0 {
range 192.168.217.10 192.168.217.100;
option domain-name-servers 114.114.114.114;
option routers 192.168.217.155;
next-server 192.168.217.155;
filename "pxelinux.0";
}
[root@localhost ~]# systemctl start dhcpd.service
[root@localhost ~]# systemctl enable dhcpd.service
安裝ftp
[root@localhost ~]# yum install -y vsftpd
[root@localhost ~]# mount /dev/cdrom /mnt
[root@localhost ~]# cp -rf /mnt/* /var/ftp/pub/
[root@localhost ~]# systemctl start vsftpd
[root@localhost ~]# systemctl enable vsftpd
tftp安裝
[root@localhost ~]# yum install -y tftp-server tftp syslinux-tftpboot
[root@localhost ~]# cp /etc/xinetd.d/tftp /etc/xinetd.d/tftp.bak_$(date +%Y-%m-%d-%H-%M)
[root@localhost ~]# 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 #此處將yes該爲no
per_source = 11
cps = 100 2
flags = IPv4
}
配置tftp-server
[root@localhost ~]# cp -rf /usr/share/syslinux/* /var/lib/tftpboot
[root@localhost ~]# mkdir /var/lib/tftpboot/pxelinux.cfg
[root@localhost ~]# mkdir /var/lib/tftpboot/centos7
[root@localhost ~]# cp /mnt/images/pxeboot/vmlinuz /var/lib/tftpboot/centos7
[root@localhost ~]# cp /mnt/images/pxeboot/initrd.img /var/lib/tftpboot/centos7
[root@localhost ~]# touch /var/lib/tftpboot/pxelinux.cfg/default
[root@localhost ~]# chmod 755 /var/lib/tftpboot/pxelinux.cfg/default
[root@localhost ~]# vim /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
prompt 1
timeout 10
menu title ########## PXE Boot Menu ##########
label 1
menu label ^1) Install CentOS 7 x64 with Local Repo
menudefault
kernel centos7/vmlinuz
append initrd=centos7/initrd.img text ks=ftp://192.168.217.155/pub/ks.cfg
label 2
menu label ^2) Install CentOS 7 x64 with http://mirror.centos.org Repo
kernel centos7/vmlinuz
append initrd=centos7/initrd.img method=http://mirror.centos.org/centos/7/os/x86_64/ devfs=nomount ip=dhcp
label 3
menu label ^3) Install CentOS 7 x64 with Local Repo using VNC
kernel centos7/vmlinuz
append initrd=centos7/initrd.img method=ftp://192.168.217.155/pub devfs=nomount inst.vnc inst.vncpassword=password
配置Kickstart
[root@localhost ~]# vim /var/ftp/pub/ks.cfg
#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use network installation
url --url="ftp://192.168.217.155/pub"
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Network information
network --bootproto=dhcp --device=ens33 --ipv6=auto --no-activate
network --hostname=localhost.localdomain
# Root password
rootpw --iscrypted $6$zfuB8B9/c1HSQYHs$00O4mwv9RrjmrsA6bxFlqe0mhW9nLiOdNNvhJD217V5DbEYrJn.fo4qmB/QXeyA79vK75xgDlNM83Yyl7wHTe0
# System services
services --enabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc
user --groups=wheel --name=abc --password=$6$FseXU1ogh.yrPKOW$SITVcIB1ti2K1bpK9dbM1aChM3cosniGiGKKko6FkdgybGR8r3.PLRPPwe1uUdpm86MTAH16.GM.TQTV2W3Rc1 --iscrypted --gecos="abc"
# System bootloader configuration
bootloader --location=mbr --boot-drive=sda
# Partition clearing information
clearpart --none --initlabel
# Disk partitioning information
part / --fstype="ext4" --ondisk=sda --size=10240
part /boot --fstype="ext4" --ondisk=sda --size=200
part swap --fstype="swap" --ondisk=sda --size=1024
%packages
@^minimal
@core
chrony
%end
%addon com_redhat_kdump --disable --reserve-mb='auto'
%end
%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end
適當的給權限,
[root@localhost ~]# chmod 777 /var/ftp/pub/ks.cfg
啓動相應服務
[root@localhost ~]# systemctl restart tftp
[root@localhost ~]# systemctl restart vsftpd
[root@localhost ~]# systemctl restart dhcpd
測試
新建虛擬機