首页 > 代码库 > pxe

pxe

######pxe#########

 

 

1.install

 

yum install httpd tftp-server dhcp syslinux -y

 

httpd        ##共享安装资源

dhcp          ##分配ip以及让客户主机获取pexlinux.0文件

pxelinux.0       ##预安装环境头文件,用来指定读取后续文件的程序

tftp-server     ##提供tftp协议,令客户主机可以读取到预安装环境

syslinux       ##提供pxelinux.0文件

 

2.启用服务

1)关闭火墙

systemctl stop firewalld

systemctl disable firewalld

 

2)打开http服务

systemctl start httpd

systemctl enable httpd

 

3)开启tftp服务:

[root@localhost ~]# netstat -anutlpe | grep xinetd

[root@localhost ~]# vim /etc/xinetd.d/tftp

14         disable                 = no

[root@localhost ~]# systemctl restart xinetd.service

[root@localhost ~]# netstat -anutlpe | grep xinetd

udp        0      0 0.0.0.0:69              0.0.0.0:*                           0          92471      5130/xinetd         

 

[root@localhost ~]# chkconfig --list

xinetd based services:

chargen-dgram: off

chargen-stream:off

daytime-dgram: off

daytime-stream:off

discard-dgram: off

discard-stream:off

echo-dgram:    off

echo-stream:   off

tcpmux-server: off

tftp:          on

time-dgram:    off

time-stream:   off

 

4)启用dhcp服务

[root@localhost ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf

cp: overwrite ‘/etc/dhcp/dhcpd.conf’? y

[root@localhost ~]# vim /etc/dhcp/dhcpd.conf

  1 option domain-name "example.com";    ##客户主机域名

  2 option domain-name-servers 172.25.254.254;    ##客户主机获得到的dns

  3 default-lease-time 600;    ##默认租约期

  4 max-lease-time 7200;    ##最长租约期

  5 log-facility local7;    ##日志级别

  6 subnet 172.25.254.0 netmask 255.255.255.0 {    ##网段,子网掩码

  7   range 172.25.254.77 172.25.254.88;    ##ip地址池

  8   option routers 172.25.254.250;    ##客户主机获得到的网关

  9   filename "pxelinux.0";    ##客户主机获得到的预安装环境头文件

 10   next-server 172.25.254.139;    ##指定头文件所在主机的ip

 11 }

[root@localhost ~]# systemctl start dhcpd

[root@localhost ~]# systemctl enable dhcpd

 

 

3.设定共享文件

1)制作安装源

mkdir /var/www/html/rhel7.0

mkdir /iso

mv /root/rhel-server-7.0-x86_64-dvd.iso /iso/

mount /iso/rhel-server-7.0-x86_64-dvd.iso  /var/www/html/rhel7.0/

vim /etc/rc.d/rc.local    ##永久挂载

 3 mount /iso/rhel-server-7.0-x86_64-dvd.iso  /var/www/html/rhel7.0/

chmod +x /etc/rc.d/rc.local

 

2)制作预安装环境

cp /var/www/html/rhel7.0/isolinux/*  /var/lib/tftpboot/    ##isolinux/目录下有目录有内核和初始化文件等,复制到/var/lib/tftpboot/,在pexlinux.0引导客户主机访问tftp时,访问这些文件

cp /usr/share/syslinux/pxelinux.0   /var/lib/tftpboot/    ##复制pxelinux.0程序到此处

mkdir /var/lib/tftpboot/pxelinux.cfg

cp /var/lib/tftpboot/isolinux.cfg  /var/lib/tftpboot/pxelinux.cfg/default    ##pexlinux.0的配置文件是/var/lib/tftpboot/pxelinux.cfg/default

 

 

3)设定自动化部署

yum install system-config-kickstart -y

system-config-kickstart    -----> /var/www/html/ks.cfg

 

vim /var/lib/tftpboot/pxelinux.cfg/default

 

label autoinstall    ##选项标签

 menu label ^Autoinstall RHEL7.0    ##标题

 kernel vmlinuz##启动的内核文件

 append initrd=initrd.img repo=http://172.25.254.139/rhel7.0 ks=http://172.25.254.139/ks.cfg quiet   ##初始化镜像      /        ##安装资源      /        ##自动安装脚本

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


本文出自 “AELY木” 博客,请务必保留此出处http://12768057.blog.51cto.com/12758057/1942049

pxe