原理图:
Centos7
一、环境准备
ip:192.168.100.192
1、虚拟机挂载7.2的ISO文件
mount /opt/***.iso /mnt/
2、关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
3、关闭selinux
setenforce 0
改配置文件(/etc/selinux/config)
二、DHCP
1、安装:
yum -y install dhcp
2、配置DHCP(/etc/dhcp/dhcpd.conf):
cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bak_$(date+%Y-%m-%d-%H-%M)
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 192.168.100.0 netmask 255.255.255.0 {#设置地址段
option routers 192.168.100.254;#设置网关
option domain-name-servers 192.168.100.192;
option time-offset -18000; # Eastern Standard Time range dynamic-bootp
192.168.100.100 192.168.100.220;#设置地址池
default-lease-time 21600; max-lease-time 43200;
next-server 192.168.100.192;#提供引导文件的服务器IP
filename "pxelinux.0";#指明引导文件名称
}
3、启动:
systemctl start dhcpd.service
systemctl enable dhcpd.service
三、TFTP:
1、安装
yum install -y tftp-server xinetd syslinux
2、配置TFTP(/etc/xinetd.d/tftp):
3、配置网络启动:
cp -rf /usr/share/syslinux/* /var/lib/tftpboot
mkdir /var/lib/tftpboot/pxelinux.cfg
mkdir /var/lib/tftpboot/centos7
cp /mnt/images/pxeboot/vmlinuz /var/lib/tftpboot/centos7
cp /mnt/images/pxeboot/initrd.img /var/lib/tftpboot/centos7
touch /var/lib/tftpboot/pxelinux.cfg/default
chmod 755 /var/lib/tftpboot/pxelinux.cfg/default
4、添加配置文件(/var/lib/tftpboot/pxelinux.cfg/default):
default menu.c32
prompt 1
timeout 30
menu title ########## GXM-PXE Boot Menu ##########
label linux
menu label Install CentOS 7.2 x86_64
menudefault
kernel centos7/vmlinuz
append initrd=centos7/initrd.img text inst.repo=http://192.168.100.192/CentOS-7.2-x86_64 ks=http://192.168.100.192/CentOS-7.2-x86_64/CentOS-7.2-x86_64.cfg
5、启动:
systemctl start xinetd tftp
systemctl enable xinetd tftp
四、http:
1、安装:
yum install -y httpd createrepo
2、配置安装系统脚本:
cp -r /mnt/* /var/www/html/CentOS-7.2-x86_64/
cat /var/www/html/CentOS-7.2-x86_64/CentOS-7.2-x86_64.cfg(编写kickstart配置文件)
# System authorization information
auth --enableshadow --passalgo=sha512
#install OS
install
# Use network installation
url --url=http://192.168.100.192/CentOS-7.2-x86_64
#Use graphical install(使用图形安装)
graphical
# Run the Setup Agent on first boot
selinux --disabled
firstboot --enable
ignoredisk --only-use=/dev/sda
#keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Network information
network --bootproto=dhcp --device=eno16777736 --onboot=yes --ipv6=auto
network --hostname=localhost.localdomain
#Root password(123456)
rootpw --iscrypted $1$password$7ZK8mMeLGXxbNPeJEFJOU0
# System timezone
timezone Asia/Shanghai --isUtc
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype ext3 --size=1024
part swap --size=4096
part / --fstype ext4 --size=102400
part /anjutu --fstype ext4 --grow#分配剩余空间
# Partition clearing information
clearpart --none --initlabel
%packages
@^minimal
@core
kexec-tools
vim
wget
net-tools
%end
%addon com_redhat_kdump --enable --reserve-mb='auto'
%end
shutdown
3、启动:
systemctl start httpd.service
4、测试
curl --head http://192.168.100.192/CentOS-7.2-x86_64/CentOS-7.2-x86_64.cfg#验证是否可以访问,可以则返回200
#服务器启动选择网络,安装完后必须修改启动项(选择硬盘启动)
Centos6
ip:192.168.100.193
1、虚拟机挂载6.10的ISO文件
mount /opt/***.iso /mnt/
2、关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
3、关闭selinux
setenforce 0
改配置文件(/etc/selinux/config)
二、DHCP
1、安装:
yum -y install dhcp
2、配置DHCP(/etc/dhcp/dhcpd.conf):
cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bak_$(date+%Y-%m-%d-%H-%M)
subnet 192.168.100.0 netmask 255.255.255.0 {
range 192.168.100.100 192.168.100.220;
option subnet-mask 255.255.255.0;
default-lease-time 21600;
max-lease-time 43200;
next-server 192.168.100.193;
filename "pxelinux.0";
}
3、启动:
systemctl start dhcpd.service
systemctl enable dhcpd.service
三、TFTP:
1、安装
yum install -y tftp-server xinetd syslinux
2、配置TFTP(/etc/xinetd.d/tftp):
3、配置网络启动:
cp -rf /usr/share/syslinux/* /var/lib/tftpboot
mkdir /var/lib/tftpboot/pxelinux.cfg
kdir /var/lib/tftpboot/centos6
mkdir /var/lib/tftpboot/centos6
cp /mnt/isolinux/initrd.img /var/lib/tftpboot/centos6/
cp /mnt/isolinux/vmlinuz /var/lib/tftpboot/centos6/
touch /var/lib/tftpboot/pxelinux.cfg/default
chmod 755 /var/lib/tftpboot/pxelinux.cfg/default
4、添加配置文件(/var/lib/tftpboot/pxelinux.cfg/default):
default menu.c32
prompt 1
timeout 30
menu title ########## GXM-PXE Boot Menu ##########
label linux
menu label Install CentOS 7.2 x86_64
menudefault
kernel centos6/vmlinuz
append initrd=centos6/initrd.img text inst.repo=http://192.168.100.193/centos6 ks=http://192.168.100.193/centos6/centos6.cfg
5、启动:
systemctl start xinetd tftp
systemctl enable xinetd tftp
四、安装http服务器:
1、安装:
yum install -y httpd createrepo
2、配置安装系统脚本:
cp -r /mnt/* /var/www/html/centos6/
cat /var/www/html/centos6/centos6.cfg
install
url --url=http://192.168.100.193/centos6
graphical
zerombr
bootloader --location=mbr --driveorder=/dev/sda --append="crashkernel=auto quiet"
lang en_US.UTF-8
keyboard us
network --onboot=yes --device=eth0 --bootproto=dhcp --noipv6
rootpw --iscrypted $6$sazpQ1mq5PsmMZli$/T4U.ni5RDc35EsaT6B/d3s97o3Fb5/5GXW55IAjMP1Yt5ziayWW5yUeGuFTrVpkpswuVfEdZPNjr4LL9ZcTJ0
firewall --disable
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone Asia/Shanghai
clearpart --all --initlabel --drives=sda
ignoredisk --only-use=sda
part /boot --fstype=ext4 --size=1024
part swap --size=2048
part / --fstype=ext4 --size=100000
part /anjutu --fstype=ext4 --grow --size=50000
%packages
@base
@core
@debugging
@development
@dial-up
@hardware-monitoring
@performance
@server-policy
@workstation-policy
sgpio
device-mapper-persistent-data
systemtap-client
%end
shutdown
3、启动:
systemctl start httpd.service
4、测试
curl --head http://192.168.100.193/centos6/centos6.cfg#验证是否可以访问,可以则返回200
#服务器启动选择网络,安装完后必须修改启动项(选择硬盘启动)
参考链接:https://blog.51cto.com/net881004/2346909 https://www.cnblogs.com/chimeiwangliang/p/8279175.html