1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | yum install nginx -y #安装web服务 vim /etc/nginx/conf.d/default.conf server { listen 80 default_server; listen [::]:80 default_server; server_name _; autoindex on; #重要设置参数 root /usr/share/nginx/html; include /etc/nginx/default.d/*.conf; location / { } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } |
2, 准备centos系列镜像
1 2 3 4 | mount /dev/sr0 centos-images/ #挂载centos系列镜像 然后将镜像你面的内容copy到网站的发布目录 cp -rfv /centos-images/* /usr/share/nginx/html/centos6.10/ cp -rfv /centos-images/* /usr/share/nginx/html/centos7.2009/ |
3, 配置DHCP服务
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | yum install dhcp -y # # DHCP Server Configuration file. # see /usr/share/doc/dhcp*/dhcpd.conf.sample # see 'man 5 dhcpd.conf' subnet 172.80.20.0 netmask 255.255.255.0 { #指定网络IP地址 range 172.80.20.10 172.80.20.254; #从那里开始分配IP地址 option subnetw-mask 255.255.255.0; #子网掩码 default-lease-time 600; #租逾时间 max-lease-time 7200; #租逾到期时间 next-server 172.80.20.14; #指定远程IP地址 filename "/pxelinux.0"; #下载远程的最小文件 } service dhcpd restart |
4,配置tftp服务
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | yum install tftp-server -y sed -i '14s/yes/no/g' /etc/xinetd.d/tftp #14代表行修改 cat /etc/xinetd.d/tftp # default: off # description: The tftp server serves files using the trivial file transfer \ # protocol. The tftp protocol is often used to boot diskless \ # workstations, download configuration files to network-aware printers, \ # and to start the installation process for some operating systems. 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 } service xinetd start netstat -lnutp |grep -Eai "80|67|69" #查看启动的服务端口是否存在 |
5,配置PXE服务
1 2 3 4 5 | yum install syslinux -y cp -rd /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ cp -rd /usr/share/nginx/html/centos6.10/isolinux/* /var/lib/tftpboot/ mkdir -pv /var/lib/tftpboot/pxelinux.cfg cp -rd /usr/share/nginx/html/centos6.10/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default |
6, 配置default文件
1 2 3 4 5 6 | cat default default ks prompt 0 label ks kernel vmlinuz append initrd=initrd.img ks=http://172.90.30.14/ks-config6.10/centos-6.10-ks.cfg ksdevice=eth0 |
7,配置文件解释
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | cat /usr/share/nginx/html/ks-config6.10/centos-6.10-ks.cfg # Kickstart file centos6 automatically generated by anaconda. #version=DEVEL install url --url=http://172.90.30.14/centos6.10 #网络安装地址 text #文本方式安装 lang en_US.UTF-8 #安装语言 keyboard us #键盘方式 network --onboot yes --device eth0 --bootproto dhcp --noipv6 #获取网络开启yes network --onboot no --device eth1 --bootproto dhcp --noipv6 #关闭网络no rootpw --iscrypted $6$Fn/mlYxGMoxt5IaE$HZm2KLQwxVuyUMsAiaOFSjIdvvoXb.zUJvqG6msyM1MfYvbLoIbdlPZao0/HK6eVgNKoOh2YPNkrL66G.lpo5/ #密码加密,密码是web123 authconfig --enableshadow --passalgo=sha512 #用户认证配置,useshadow 表示使用本地认证,--passalgo 表示密码加密算法 firewall --disabled #永久关闭防火墙 selinux --disabled #关闭selinux timezone --utc Asia/Shanghai #设置上海时区 bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet" # 指明 bootloader 的安装位置,指明驱动器的排序,指明操作系统安装完成之后,向内核传递的参数 zerombr yes #清除 MBR 引导记录 clearpart --all --initlabel #清除硬盘上的所有数据 #自定义分区 part /boot --fstype=ext4 --size=1024 #创建一个 1024M 大小的分区挂载 / boot 类型为 ext4 part / --fstype=ext4 --size=20480 #创建一个 20480M 大小的分区挂载 / 类型为 ext4 part swap --size=512 #创建一个 512M 大小的 SWAP 分区 part /data --fstype=ext4 --grow --size=200 #创建一个磁盘全部大小存储空间的分区挂载 /data 类型为 ext4 reboot --eject #设置完成之后重启 %packages --nobase #核心最小化安装 @core vim wget %post #增加安装后运行脚本 #配置yum镜像源 rm -rfv /etc/yum.repos.d/* wget -O /etc/yum.repos.d/epel.repo http://172.90.30.14/ks-config6.10/epel.repo wget -O /etc/yum.repos.d/CentOS-Base.repo http://172.90.30.14/ks-config6.10/CentOS-Base.repo wget -O /etc/yum.repos.d/epel-testing.repo http://172.90.30.14/ks-config6.10/epel-testing.repo yum clean all yum makecache yum update -y sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config wget -O /data/config.sh http://172.90.30.14/ks-config6.10/config.sh chmod o+x /data/config.sh /data/config.sh %end #结束自动化部署 |
「梦想一旦被付诸行动,就会变得神圣,如果觉得我的文章对您有用,请帮助本站成长」
上一篇:第一章,什么是PXE ?