安装需要软件
systemctl stop firewalld
yum -y install syslinux dhcp httpd tftp-server xinetd
图形化kickstart
yum -y install system-config-kickstart
创建一个目录CentOS用来挂载镜像
mkdir /var/www/html/centos
mount /dev/sr0 /var/www/html/centos
#修改tftp服务
vim /etc/xinetd.d/tftp
disable = no //修改
#拷贝引导文件到tftp服务根目录下
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
mkdir /var/lib/tftpboot/pxelinux.cfg
cp /var/www/html/centos/isolinux/* /var/lib/tftpboot/
cp /var/lib/tftpboot/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
#修改配置文件
vim /var/lib/tftpboot/pxelinux.cfg/default
修改default文件(修改大概第64行,并删除大概第69行的“menu default”)
label linux
menu label ^Install CentOS Linux 7
kernel vmlinuz
64 menu default
65 append initrd=initrd.img repo=http://172.16.40.197/centos/ ks=http://172.16.40.197/ks.cfg
//设置文件文件权限
chmod -R 644 /var/lib/tftpboot/pxelinux.cfg/default
#ddns-update-style interim; //设置DHCP服务器模式
#修改dhcp文件
vim /etc/dhcp/dhcpd.conf
cat /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example >>/etc/dhcp/dhcpd.conf
subnet 172.16.40.0 netmask 255.255.255.0 {
range 172.16.40.10 172.168.40.200;
option routers 172.16.40.255;
filename "pxelinux.0";
next-server 172.16.40.197;
}
[root@localhost ~]# vim /etc/sysconfig/dhcpd
DHCPDARGS=ens33 //设置dhcp服务器模式
[root@localhost ~]# dhcpd //测试dhcp服务配置是否正确
[root@localhost ~]# systemctl start dhcpd //启动dhcpd服务
[root@localhost ~]# systemctl enable dhcpd //
#检查tftp
chkconfig --list
#安装kickstart图形化程序时注意添加一下配置
vim /etc/yum.repos.d/lxy.repo
[development] //添加
name=my-centos7
baseurl=file:///var/www/html/os/
enabled=1
gpgcheck=0
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard --vckeymap=cn --xlayouts='cn'
# Root password
rootpw --iscrypted $1$iUCD6VMp$t4IC/N5H2u8iDChXvr/RY.
# System language
lang en_US
#zh_CN.UTF-8
# System authorization information
auth --useshadow --passalgo=sha512
# Use graphical install
graphical
firstboot --disable
# SELinux configuration
selinux --disabled
# Firewall configuration
firewall --disabled
# Network information
#network --bootproto=dhcp --device=wlp3s0
network --bootproto=static --device=enp0s3 --gateway=172.21.40.1 --ip=172.21.40.166 --nameserver=114.114.114.114 --netmask=255.255.255.0 --ipv6=auto --activate
network --hostname=netinstall
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai --isUtc
# Use network installation
url --url="http://172.21.40.151/centos/"
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --size=200
part swap --fstype="swap" --size=4096
part / --fstype="xfs" --grow --size=1
%packages
@core
@compat-libraries
@debugging
@development
kexec-tools
tree
nmap
sysstat
lrzsz
ntpdate
gcc
gcc-c++
subversion
net-tools
dos2unix
telnet
wget
vim
bash-completion
%end
%post
systemctl disable postfix.service
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum -y install docker-ce
yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc
yum -y install gcc perl-ExtUtils-MakeMaker
yum -y remove git
mkdir /root/software
mkdir /root/environment
cd /root/environment
wget https://www.kernel.org/pub/software/scm/git/git-2.19.1.tar.xz
tar -vxf git-2.19.1.tar.xz
cd git-2.19.1
make prefix=/root/environment/git all
make prefix=/root/environment/git install
cd /root/environment
wget http://172.21.40.151/jdk-8u211-linux-x64.tar.gz
wget http://172.21.40.151/maven.tar
tar -zxvf jdk-8u211-linux-x64.tar.gz
tar -xvf maven.tar
mv jdk1.8.0_211 jdk
echo "export JAVA_HOME=/root/environment/jdk" >> /etc/profile
echo "export JRE_HOME=\${JAVA_HOME}/jre" >> /etc/profile
echo "export CLASSPATH=.:\${JAVA_HOME}/lib/tools.jar:\${JRE_HOME}/lib/dt.jar" >> /etc/profile
echo "export MAVEN_HOME=/root/environment/maven" >> /etc/profile
echo "export GIT_HOME=/root/environment/git" >> /etc/profile
echo "export PATH=\$PATH:\${JAVA_HOME}/bin:\${JRE_HOME}/bin:\${MAVEN_HOME}/bin:\${GIT_HOME}/bin" >> /etc/profile
source /etc/profile
ntpdate 218.186.3.36
timedatectl set-timezone Asia/Shanghai
%end
%addon com_redhat_kdump --enable --reserve-mb='auto'
%end
systemctl restart xinetd httpd dhcpd