systemctl status firewalld # 查看防火墙的状态
systemctl stop firewalld # 关闭防火墙
systemctl disable firewalld # 设置开机不启动
systemctl is-enabled firewalld # 查看是否设置开机启动
yum install -y httpd dhcp tftp-server xinetd syslinux system-config-kickstart
yum groupinstall -y 'X Window System'
rpm -q httpd dhcp tftp-server xinetd syslinux system-config-kickstart
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
vim /etc/dhcp/dhcpd.conf
egrep -v "^#|^$" /etc/dhcp/dhcpd.conf
systemctl status dhcpd # 查看dhcp的状态
systemctl start dhcpd # 启动dhcp
systemctl enable dhcpd # 设置开机启动
systemctl is-enabled dhcpd # 查看是否设置开机启动
ss -nulp | grep dhcpd
mount -o loop /dev/sr0 /var/www/html/CentOS7/
mount -o loop /dev/sr0 /mnt/cdrom/
systemctl status httpd # 查看httpd的状态
systemctl start httpd # 启动httpd
systemctl enable httpd # 设置开机启动
systemctl is-enabled httpd # 查看是否设置开机启动
systemctl start tftp.socket # 启动tftp.socket
systemctl status tftp.socket # 查看状态
systemctl enable tftp.socket # 设置开机启动
systemctl is-enabled tftp.socket # 查看是否设置为开机启动
systemctl start tftp.service # 启动tftp.service
systemctl status tftp.service # 查看状态
systemctl enable tftp.service # 设置开机启动
systemctl is-enabled tftp.service # 查看是否设置为开机启动
systemctl start xinetd # 启动xinetd
systemctl status xinetd # 查看状态
systemctl enable xinetd # 设置开机启动
systemctl is-enabled xinetd # 查看是否设置为开机启动
需要导入TFTP服务器的主要文件有:
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
cp /mnt/cdrom/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/
cp /mnt/cdrom/isolinux/{vesamenu.c32,boot.msg,splash.png} /var/lib/tftpboot/
cp /usr/share/syslinux/{chain.c32,mboot.c32,menu.c32,memdisk} /var/lib/tftpboot/
system-config-kickstart
出现以下窗口,进行配置,设置语言,键盘,时区,root密码,安装完毕后重启等
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install ## 告知这是一次安装程序
# Keyboard layouts
keyboard 'us' ## 设置系统键盘类型为us
# Root password
rootpw --iscrypted $1$gL0CThj6$3LwF2Dh5oqg3Sz9kU9qvm. ## 加密的root密码
# Use network installation
url --url="http://192.168.120.11/CentOS7" ## 通过ftp或http从远程服务器安装的地址
# System language
lang en_US ## 设置安装过程中使用的语言字符集
# System authorization information
auth --useshadow --passalgo=sha512 ## 系统认证信息,这里要是写密文密码需加 设置密码加密方式为sha512 启用shadow文件
# Use text mode install
text ## 使用文本模式安装
# SELinux configuration
selinux --disabled ## 关闭selinux
# Do not configure the X Window System
skipx
# Firewall configuration
firewall --disabled ## 关闭防火墙
# Network information
network --bootproto=dhcp --device=ens32 ## 动态配置ip网络信息的写法
# Reboot after installation
reboot ## 设置安装完成后重启,必须存在
# System timezone
timezone Asia/Shanghai ## 设置时区为亚洲上海
# System bootloader configuration
bootloader --location=mbr ## 指定引导记录被写入的位置
# Clear the Master Boot Record
zerombr ## 清除mbr引导信息
# Partition clearing information
clearpart --all --initlabel ## 清空分区,清空所有分区
# Disk partitioning information ## 为分区设置文件系统类型为xfs,size设置大小
part /boot --fstype="xfs" --size=1024
part swap --fstype="swap" --size=1024
part / --fstype="xfs" --grow --size=1
%packages ## 这一部分是要安装的一些包 以%packages开头,以%end结束
@^minimal
@core
@development
kexec-tools
wget
vim
%end
%addon com_redhat_kdump --enable --reserve-mb='auto'
%end
## 以%pre开头,以%end结束,在安装完系统之前执行的相关Linux命令、脚本
%post ## 安装后执行的命令,如果要一键化搭建集群,这里可以执行写好的shell或ansible剧本进行搭建
systemctl disable postfix.service ## 以%post开头,以%end结束,在安装完系统之后执行的相关Linux命令、脚本
%end
mkdir -pv /var/www/html/ksdir
cp /root/CentOS7.cfg /var/www/html/ksdir/
chmod +r /var/www/html/ksdir/CentOS7.cfg
cp /mnt/cdrom/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
vim /var/lib/tftpboot/pxelinux.cfg/default
default linux
label linux
kernel vmlinuz
append initrd=initrd.img inst.repo=http://192.168.120.11/CentOS7 inst.ks=http://192.168.120.11/ksdir/ks.cfg ksdevice=ens32