原理和概念:html
一 什么是PXEnode
严格来讲,PXE 并非一种安装方式,而是一种引导的方式。进行 PXE 安装的必要条件是要安装的计算机中包含一个 PXE 支持的网卡(NIC),即网卡中必需要有 PXE Client。PXE (Pre-boot Execution Environment)协议使计算机能够经过网络启动。协议分为 client 和 server 端,PXE client 在网卡的 ROM 中,当计算机引导时,BIOS 把 PXE client 调入内存执行,由 PXE client 将放置在远端的文件经过网络下载到本地运行。运行 PXE 协议须要设置 DHCP 服务器和 TFTP 服务器。DHCP 服务器用来给 PXE client(将要安装系统的主机)分配一个 IP 地址,因为是给 PXE client 分配 IP 地址,因此在配置 DHCP 服务器时须要增长相应的 PXE 设置。此外,在 PXE client 的 ROM 中,已经存在了 TFTP Client。PXE Client 经过 TFTP 协议到 TFTP Server 上下载所需的文件。linux
二 什么是KickStartios
KickStart是一种无人职守安装方式。KickStart的工做原理是经过记录典型的安装过程当中所需人工干预填写的各类参数,并生成一个名为ks.cfg的文件;在其后的安装过程当中(不仅局限于生成KickStart安装文件的机器)当出现要求填写参数的状况时,安装程序会首先去查找KickStart生成的文件,当找到合适的参数时,就采用找到的参数,当没有找到合适的参数时,才须要安装者手工干预。这样,若是KickStart文件涵盖了安装过程当中出现的全部须要填写的参数时,安装者彻底能够只告诉安装程序从何处取ks.cfg文件,而后去忙本身的事情。等安装完毕,安装程序会根据ks.cfg中设置的重启选项来重启系统,并结束安装。nginx
三 PXE + KickStart安装的条件vim
执行 PXE + KickStart安装须要的设备为:centos
• DHCP 服务器;服务器
• TFTP 服务器;网络
• KickStart所生成的ks.cfg配置文件app
四 详细步骤
1.加载光盘到/mnt/下
mount /dev/cdrom /mnt/
cp -rf /mnt/* /var/www/html/ #拷贝光盘里面的全部内容到nginx根目录下,做为安装源
2.安装tftp-server
yum install tftp-server*
配置tftp
vim /etc/xinetd.d/tftp
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot #开机必需的程序路径(根据的tftpboot路径更改)
disable = yes #把这边的yes改成no
per_source = 11
cps = 100 2
flags = IPv4
}
3.配置tftpboot的内容
mkdir /tftpboot
cp /usr/share/syslinux/pxelinux.0 /tftpboot/
cp /mnt/p_w_picpaths/pxeboot/initrd.img /tftpboot/
cp /mnt/p_w_picpaths/pxeboot/initrd.img /tftpboot/
cp /mnt/isolinux/*.msg /tftpboot/ #开机引导文件
mkdir /tftpboot/pexlinux.cfg
cp /mnt/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
chmod -R 777 /tftpdboot/ #将TFTP目录开发权限,不然,tftp下载可能会出问题
4.安装配置 DHCP server
ddns-update-style interim;
ignore client-updates;
subnet 192.168.1.0 netmask 255.255.255.0 { #//所属网段及掩码。
# --- default gateway
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
filename "pxelinux.0"; #//PXE获得IP之后的引导文件
next-server 192.168.1.91;//tftp服务器IP地址。
# option nis-domain "domain.org";
# option domain-name "domain.org";
option domain-name-servers 192.168.1.91;
option time-offset -18000; # Eastern Standard Time
# option ntp-servers 192.168.1.1;
# option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
# option netbios-node-type 2;
range dynamic-bootp 192.168.1.20 192.168.1.25; #//IP地址池范围。
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed address
host ns {
next-server marvin.redhat.com;
hardware ethernet 12:34:56:78:AB:CD;
fixed-address 207.175.42.254;
}
}
5.配置 nginx或者http
使用默认80端口,将跟目录指向到 /var/www/html/ //光盘源复制到的目录
6.安装配置 kickstart
yum install system-config-kickstart
在桌面环境下执行图形化kickstart生成工具 system-config-kickstart来生成ks.cfg
7.修改 ks.cfg
chmod -R 777 /tftpboot/
cp ks.cfg /var/www/html/
vim /tftpboot/pxelinux.cfg/default
在最后面添加一下内容:
label linux
kernel vmlinuz
append initrd=initrd.img ks=http://192.168.1.91/ks.cfg #ks.cfg的路径
8.关闭防火墙
/etc/init.d/iptables stop
getenforce 来检测selinux是否开启 ,若是开启 getenforce 0来进行关闭。
9.启动服务
/etc/init.d/dhcpd start
/etc/init.d/xinetd start
/etc/init.d/httpd start
10.不出意外,进能够全自动安装 centos 的系统了