pxe+kickstart简单搭建,我这里写得比较粗略,不过比较容易看懂
[root@ha1 ~]# yum -y install tftp tftp-server httpd syslinux dhcp
复制dhcp样例配置文件到dhcp的配置文件目录下
[root@ha1 dhcp]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
cp: overwrite `/etc/dhcp/dhcpd.conf‘? y
[root@ha1 dhcp]# vim dhcpd.conf
配置文件内容如下
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
主要添加以下内容,其他内容视实际情况而定
subnet 172.16.0.0 netmask 255.255.0.0 {
range 172.16.6.99 172.16.6.199;
#option routers 172.16.0.1; 网关
option routers 172.16.6.20; #vm 调整为
next-server 172.16.6.20;
filename "pxelinux.0";
}
修改xinetd超级守护线程的配置文件
[root@ha1 dhcp]# vim /etc/xinetd.d/tftp
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,把yes改为no
per_source = 11
cps = 100 2
flags = IPv4
}
[root@ha1 dhcp]# service xinetd restart
Stopping xinetd: [FAILED]
Starting xinetd: [ OK ]
[root@ha1 dhcp]# ls /usr/share/syslinux
复制pxelinux.0文件到/var/lib/tftpboot/目录下
[root@ha1 dhcp]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
[root@ha1 dhcp]# ls /var/lib/tftpboot/
pxelinux.0
测试tftp服务是否正常
[root@ha1 dhcp]# cd /tmp/
[root@ha1 tmp]# tftp 172.16.6.20
tftp> get pxelinux.0 #使用get下载pxelinux.0文件
tftp> quit
[root@ha1 tmp]# ls #查看是否能下载pxelinux.0文件
pulse-KLoEGFAUVElg pxelinux.0
[root@ha1 tmp]# cd ~
[root@ha1 ~]# mkdir -pv /media/cdrom
mkdir: created directory `/media/cdrom
在vm虚拟机上挂载centos6.6.iso镜像
[root@ha1 ~]# mount -r /dev/cdrom /media/cdrom/ #把系统镜像文件挂载到centos6.6.iso镜像
[root@ha1 ~]# cd /media/cdrom/
[root@ha1 cdrom]# ls
CentOS_BuildTag isolinux RPM-GPG-KEY-CentOS-Debug-6
EFI Packages RPM-GPG-KEY-CentOS-Security-6
EULA RELEASE-NOTES-en-US.html RPM-GPG-KEY-CentOS-Testing-6
GPL repodata TRANS.TBL
images RPM-GPG-KEY-CentOS-6
复制文件到/var/lib/tftpboot/目录
[root@ha1 images]# cd /media/cdrom/images/pxeboot/
[root@ha1 pxeboot]# ls
initrd.img TRANS.TBL vmlinuz
[root@ha1 pxeboot]# cp vmlinuz initrd.img /var/lib/tftpboot/
[root@ha1 pxeboot]# cd /media/cdrom/isolinux/
[root@ha1 isolinux]# ls
boot.cat grub.conf isolinux.bin memtest TRANS.TBL vmlinuz
boot.msg initrd.img isolinux.cfg splash.jpg vesamenu.c32
[root@ha1 isolinux]# cp boot.msg splash.jpg vesamenu.c32 /var/lib/tftpboot/
[root@ha1 isolinux]# cp isolinux.cfg isolinux.bin /var/lib/tftpboot/
[root@ha1 isolinux]# cd /var/lib/tftpboot/
[root@ha1 tftpboot]# mkdir pxelinux.cfg
[root@ha1 tftpboot]# cp isolinux.cfg pxelinux.cfg/default
[root@ha1 tftpboot]# cd
[root@ha1 ~]# mkdir /var/www/html/centos6
[root@ha1 ~]# mount --bind /media/cdrom/ /var/www/html/centos6
[root@ha1 ~]# ls /var/www/html/centos6
CentOS_BuildTag isolinux RPM-GPG-KEY-CentOS-Debug-6
EFI Packages RPM-GPG-KEY-CentOS-Security-6
EULA RELEASE-NOTES-en-US.html RPM-GPG-KEY-CentOS-Testing-6
GPL repodata TRANS.TBL
images RPM-GPG-KEY-CentOS-6
[root@ha1 html]# wget http://172.16.0.1/rhel6.x86_64.cfg
--2015-01-27 14:42:06-- http://172.16.0.1/rhel6.x86_64.cfg
Connecting to 172.16.0.1:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2249 (2.2K) [text/plain]
Saving to: “rhel6.x86_64.cfg”
100%[======================================================>] 2,249 --.-K/s in 0s
2015-01-27 14:42:06 (349 MB/s) - “rhel6.x86_64.cfg” saved [2249/2249]
[root@ha1 html]# ls
centos6 rhel6.x86_64.cfg
[root@ha1 html]# mv rhel6.x86_64.cfg centos6.cfg
[root@ha1 html]# vim centos6.cfg
修改url路径为httpd的web路径
url --url http://172.16.6.20/centos6 #此次服务可能是http、ftp等,注意修改
[root@ha1 html]# cd /var/lib/tftpboot/
[root@ha1 tftpboot]# vim pxelinux.cfg/default
在第一个label下面的append initrd=initrd.img后面添加
ks=http://172.16.6.20/centos6.cfg
label linux
menu label ^Install or upgrade an existing system
menu default
kernel vmlinuz
append initrd=initrd.img ks=http://172.16.6.20/centos6.cfg
本文出自 “源洁则流清,形端则影直” 博客,请务必保留此出处http://zhouxt.blog.51cto.com/8743763/1641581
原文地址:http://zhouxt.blog.51cto.com/8743763/1641581