关闭防火墙、关闭selinux
1、配置DHCP服务
# yum install dhcp -y
dhcp配置文件如下
# vi /etc/dhcp/dhcpd.conf
查看路径
# rpm -ql dhcp | grep ample
# cat /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example > /etc/dhcp/dhcpd.conf
# vi /etc/dhcp/dhcpd.conf
没修改前
修改后
subnet 192.168.100.0 netmask 255.255.255.0 { //网段和子网掩码 range 192.168.100.26 192.168.100.30; //网络地址池 option domain-name-servers 192.168.100.2; //域名服务器 option domain-name "djl.cc"; //域名、主机名 option routers 192.168.100.2; //路由、网关 option broadcast-address 192.168.100.255; //广播域 filename "/pxelinux.0"; next-server 192.168.100.3; default-lease-time 600; max-lease-time 7200; }
重启服务
# systemctl start dhcpd
设置开机自启动
# systemctl enable dhcpd
2、配置tftp服务
安装tftp服务
# yum install tftp-server -y
# yum install xinetd -y
把disable=yes改成no
# vi /etc/xinetd.d/tftp
# systemctl restart xinetd
# netstat -ntulp | grep 69
tftp共享目录位置
/var/lib/tftpboot/
查看pxeliunx.0所需要的包
# yum whatprovides */pxeliunx.0
安装
# yum install syslinux -y
# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
到挂载光盘文件中复制vmlinuz 和 initrd.img
# cp vmlinuz initrd.img /var/lib/tftpboot/
查看一下
# cd /var/lib/tftpboot/
# ls
创建pxe的配置文件
# mkdir pxelinux.cfg
到挂载文件中复制pxe配置文件的内容
# cp isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
赋予可写权限
# chmod u+w /var/lib/tftpboot/pxelinux.cfg/default
安装系统的提示界面,不是必须的文件,可有可无
# cp boot.msg /var/lib/tftpboot/
# chmod u+w /var/lib/tftpboot/boot.msg
查看一下共享的内容
# cd /var/lib/tftpboot/
编辑pxe的配置文件
# vi pxelinux.cfg/default
原文件如下
修改后
3、配置第三个服务http服务
安装服务
# yum install httpd -y
修改配置文件添加如下内容
# vi /etc/httpd/conf/httpd.conf
重启httpd服务,并设置成开机自启动
# systemctl restart httpd
# systemctl enable httpd
创建镜像仓库
上传安装镜像系统,挂载到dvd下使用
基本上已经完成!
写应答文件实现自动化安装Linux
安装kickstart
# yum install system-config-kickstart -y
运行界面
# system-config-kickstart &
基本设置完毕并保存,ks.cfg
ks.cfg文件内容如下
#platform=x86, AMD64, or Intel EM64T #version=DEVEL # Install OS instead of upgrade install # Keyboard layouts keyboard 'us' # Root password rootpw --iscrypted $1$NZJG0oqx$s0dgSEq5GsvPvgrdPdahB/ # System timezone timezone Asia/Shanghai # Use network installation url --url="http://192.168.100.3/dvd" # System language lang en_US # Firewall configuration firewall --disabled # System authorization information auth --useshadow --passalgo=sha512 # Use graphical install graphical firstboot --disable # SELinux configuration selinux --permissive # Network information network --bootproto=dhcp --device=eth0 # Reboot after installation reboot # System bootloader configuration bootloader --location=mbr # Clear the Master Boot Record zerombr # Partition clearing information clearpart --all --initlabel # Disk partitioning information part / --fstype="xfs" --size=6000 part swap --fstype="swap" --size=1000 %packages @base %end
# cp ks.cfg /var/www/html/
重新配置pxelinux.cfg
#vi /var/lib/tftpboot/pxelinux.cfg/default
成功!!!