[关闭]
@mrz1 2018-01-13T18:52:47.000000Z 字数 5022 阅读 1721

PXE自动化安装CentOS 7实验

自动化


安装前准备:关闭防火墙和SELINUX,DHCP服务器静态IP

服务器端配置

安装tftp-server及配置

  1. 1.安装软件包
  2. yum insatll tftp-server (服务器口号69)
  3. 2.启动服务并且开机启动
  4. systemctl start dhcpd 启动服务
  5. systemctl is-enabled tftp #查询服务是否开机启动
  6. systemctl enable tftp #开机运行服务
  7. systemctl disable tftp #取消开机运行
  8. 3.配置文件
  9. /var/lib/tftpboot/(tftp客户端连接的目录默认是这个目录下)
  10. 4.yum install syslinux(安装这个包)
  11. 5.cp /usr/share/syslinux/{pxelinux.0,menu.c32} /var/lib/tftpboot/
  12. cp /misc/cd/isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/
  13. mkdir /var/lib/tftpboot/pxelinux.cfg/
  14. cp /misc/cd/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
  15. 6.[root@centos7 ~]#Vim /var/lib/tftpboot/pxelinux.cfg/default(默认菜单)
  16. default menu.c32
  17. timeout 600
  18. menu title PXE INSTALL CentOS 7
  19. label desktop
  20. menu label ^Install desktop CentOS 7
  21. kernel vmlinuz
  22. append initrd=initrd.img ks=http://192.168.109.143/ksdir/ks7-pxe.cfg
  23. label mini
  24. menu label install ^Mini CentOS 7
  25. kernel vmlinuz
  26. append initrd=initrd.img ks=http://192.168.109.143/ksdir/ks7-mini.cfg
  27. label local
  28. menu default
  29. menu label Boot from ^local drive
  30. localboot 0xffff
  31. menu end
  32. 7.

安装dhcp及配置

  1. 1.安装软件包
  2. yum install dhcp
  3. 2.rpm -ql dhcp //找到这两个
  4. /etc/dhcp/dhcpd.conf (空的)
  5. /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example
  6. 3.cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf //可以复制过来参考 也可以直接进行第四步
  7. 4.[root@centos7 ~]#vim /etc/dhcp/dhcpd.conf //编写这个文件
  8. option domain-name "zhangqifei.com";
  9. option domain-name-servers 114.114.114.114,8.8.8.8; //DNS解析
  10. option routers 192.168.109.1;//全局默认网关
  11. default-lease-time 84600; //有效期
  12. max-lease-time 84600; //特殊要求最大有效期
  13. log-facility local7;
  14. subnet 192.168.109.0 netmask 255.255.255.0 { //网段
  15. range 192.168.109.100 192.168.109.200; //分配ip范围 如果这里写网关,就是这些范围ip,外面的网关是全局的这里不设置网关会是全局网关
  16. filename "pxelinux.0";/文件名网络中启动程序的文件名
  17. next-server "192.168.109.143";(tftp)//程序的文件名地址
  18. }
  19. 例也可以这样:
  20. host fantasia { //绑定mac地址,分配默认ip
  21. hardware ethernet 08:00:07:26:c0:a5;
  22. fixed-address 192.168.109.101;
  23. 这里网关和DNS都可以单独设置
  24. }
  25. 5.启动服务并且设置开机启动
  26. systemctl start dhcpd 启动服务
  27. systemctl is-enabled dhcpd #查询服务是否开机启动
  28. systemctl enable dhcpd #开机运行服务
  29. systemctl disable dhcpd #取消开机运行
  30. 查看端口 ss -ntlup //服务器端udp67端口,客户端udp68端口
  31. dhcp数据库 /var/lib/dhcpd/dhcpd.leases

安装httpd服务

  1. 1.安装软件包
  2. yum insatll httpd (服务器口号69)()
  3. 2.启动服务并且开机启动
  4. systemctl start httpd 启动服务
  5. systemctl is-enabled httpd #查询服务是否开机启动
  6. systemctl enable httpd #开机运行服务
  7. systemctl disable httpd #取消开机运行
  8. 3.配置文件
  9. /var/www/html(web页面在这个下面)
  10. 4.直接打开本地浏览器查看ip地址是否你能打开网页
  11. 5.mkdir -p centos/{6,7};mkdir ksdir
  12. 6.cp /root/anaconda-ks.cfg /var/www/html/ksdir/ks7-pxe.cfg
  13. 7.[root@centos7 ksdir]#cat ks7-pxe.cfg (编辑这个脚本)
  14. #version=DEVEL
  15. # System authorization information
  16. auth --enableshadow --passalgo=sha512
  17. # Use CDROM installation media
  18. url --url=http://192.168.109.143/centos/7(url这里我们用光盘看8)
  19. # Use graphical install
  20. firewall --disabled
  21. selinux --disabled
  22. text (文本安装)
  23. reboot
  24. # Run the Setup Agent on first boot
  25. firstboot --disable
  26. ignoredisk --only-use=sda
  27. # Keyboard layouts
  28. keyboard --vckeymap=us --xlayouts='us'
  29. # System language
  30. lang en_US.UTF-8
  31. # Network information
  32. network --bootproto=dhcp --device=ens33 --onboot=on --ipv6=auto --activate
  33. network --hostname=centos7.qifei.com
  34. # Root password
  35. rootpw --iscrypted $6$zvNPHt.AnyhKAFGT$GhLgXK5VyYGIgFr60TopFHzVUersaacruSe0MYnVZB4vbGNLHCDPTfbiKW1Ry.V9S9NdGis.qmnP/MSnfXt7R0
  36. # System services
  37. services --disabled="chronyd"
  38. # System timezone
  39. timezone Asia/Shanghai --isUtc --nontp
  40. user --name=fei --password=$6$wrdu0VH2CF1hufHn$FpKs8T.4z65C9HFoDiB8Z6SmERCjBJt2LGhNOvnnDhYzm4Lt58qJ2dryg8mqHvYTnGDp6igP8M0748Hx7i8XW. --iscrypted --gecos="fei"
  41. # X Window System configuration information
  42. xconfig --startxonboot
  43. # System bootloader configuration
  44. bootloader --location=mbr --boot-drive=sda
  45. # Partition clearing information
  46. zerombr(清空)
  47. clearpart --all --initlabel (清空)
  48. # Disk partitioning information
  49. part swap --fstype="swap" --ondisk=sda --size=2048
  50. part / --fstype="xfs" --ondisk=sda --size=51200
  51. part /boot --fstype="xfs" --ondisk=sda --size=1024
  52. part /app --fstype="xfs" --ondisk=sda --size=20480
  53. eula --agreed (默认提示协议是否同意这里不用手动选)
  54. %packages
  55. @base
  56. @core
  57. @dial-up
  58. @fonts
  59. @gnome-desktop
  60. @guest-agents
  61. @guest-desktop-agents
  62. @internet-browser
  63. @multimedia
  64. @network-file-system-client
  65. @networkmanager-submodules
  66. @print-client
  67. @x11
  68. %end
  69. %addon com_redhat_kdump --disable --reserve-mb='auto'
  70. %end
  71. %anaconda
  72. pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
  73. pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
  74. pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
  75. %end
  76. %post
  77. rm -f /etc/yum.repo.d/*
  78. cat > /etc/yum.repos.d/base.repo <<EOF
  79. [base]
  80. name = centos7base
  81. baseurl = file:///misc/cd/
  82. gpgcheck = 0
  83. EOF
  84. echo magedu |passwd --stdin fei &> /dev/null
  85. systemctl set-default multi-user.target
  86. %end
  87. 8.[root@centos7 ksdir]#cat /etc/fstab (把下面添加进去并且挂载maunt -a)
  88. /dev/sr0 /var/www/html/centos/7 iso9660 defaults 0 0

服务器端总结

  1. [root@centos7 ~]#rpm -q dhcp httpd tftp-server (三个包必须的)
  2. dhcp-4.2.5-58.el7.centos.x86_64
  3. httpd-2.4.6-67.el7.centos.x86_64
  4. tftp-server-5.2-13.el7.x86_64
  5. httpd端口(80
  6. tftp端口(服务器端69
  7. dhcp端口(服务器端udp67端口,客户端udp68端口)
  8. [root@centos7 tftpboot]#tree
  9. .
  10. ├── initrd.img
  11. ├── menu.c32
  12. ├── pxelinux.0
  13. ├── pxelinux.cfg
  14.    └── default
  15. └── vmlinuz

客户端

tftp

  1. 1.安装软件包
  2. yum install tftp(客户端连接的目录默认服务器端/var/lib/tftpboot/这个目录下)命令 get file //是下载这个目录下文件

DHCP

  1. 查看端口 ss -ntlup //服务器端udp67端口,客户端udp68端口
  2. 查看网关 route -n
  3. 查看DNS cat /etc/resolv.conf
  4. [root@centos7 ~]#cat /var/lib/dhclient/dhclient-eth0.leases //接受地址的数据库 可以看到从哪里获取的多有信息

安装httpd服务

最后

安装软件即可
问题 硬盘需大于200G因为配置文件是200Gde
图形内存必须大于1024 (1100)多一点点就行
权限问题 /var/www/html/ksdir/目录下文件权限644

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注