搭建PXE Server-woyouhaoduo
实验拓扑:-----PXE Server(vmnet1)-------------Client(vmnet1)------
实验一:搭建PXE Server
服务器IP为192.168.10.253,可以给192.168.10.0/24安装RHEL5.9
分别给每台客户端分配主机名,格式如下(1-100)
stationx.tarena.com 192.168.10.x
安装所需要的软件包存放在/data/iso/rhel5.9
前期准备:
1、设置网络参数
# ifconfig eth0 | grep "inetaddr"
inetaddr:192.168.10.253 Bcast:192.168.10.255Mask:255.255.255.0
# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=server01.tarena.com
# grep server01 /etc/hosts
192.168.10.253 server01.example.com server01
2、创建YUM源
# mkdir -p /data/iso/rhel5.9
//放入rhel5.9 iso
# cp -rpf /misc/cd/* /data/iso/rhel5.9/
3、配置YUM客户端
# cd /etc/yum.repos.d/
# cp rhel-debuginfo.reporhel5.9.repo
# cat rhel5.9.repo
name=Red Hat Enterprise Linux Server
baseurl=file:///data/iso/rhel5.9/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
实验步骤:
1、配置DHCP(给需要安装系统的主机分配ip)
# rpm -q dhcp //检查是否安装了dhcp
package dhcp is not installed //提示没有安装
# yum -y install dhcp //安装dhcp
# cat /etc/dhcpd.conf //dhcp主配置文件
ddns-update-style interim;
default-lease-time 21600;
max-lease-time 43200;
optionrouters 192.168.10.254;//网关
optiondomain-name "tarena.com";//域名
optiondomain-name-servers 192.168.10.253;//DNS
next-server192.168.10.253; //tftp服务器地址
filename"pxelinux.0"; //网卡引导文件名
subnet 192.168.10.0 netmask 255.255.255.0 {
rangedynamic-bootp 192.168.10.1 192.168.10.100;
}
# service dhcpd restart //开启服务
# chkconfig dhcpd on //开机自启
# netstat -tulnp | grep :67 //查看dhcp端口
udp 0 0 0.0.0.0:67 0.0.0.0:* 5219/dhcpd
2、配置DNS
# rpm -q bind bind-chrootcaching-nameserver
package bind is not installed
package bind-chroot is not installed
package caching-nameserver is not installed
# yum -y install bind bind-chrootcaching- nameserver
# cd /var/named/chroot/etc/
# cp -pnamed.caching-nameserver.confnamed.conf
# vim named.conf
...
15 listen-on port 53 { 192.168.10.253; };
16 // listen-on-v6port 53 { ::1; };
...
27 allow-query { any; };
28 allow-query-cache { any; };
...
37 match-clients { any; };
38 match-destinations { any; };
# vim named.rfc1912.zones
...
51zone"tarena.com" IN {
52 type master;
53 file "tarena.com.zone";
54 };
55
56 zone "10.168.192.arpa" IN {
57 typemaster;
58 file "10.168.192.arpa";
#named-checkconf named.conf//检测语法是否出错
# cd /var/named/chroot/var/named/
# cp -p named.local tarena.com.zone
# cat tarena.com.zone
$TTL 86400
@ IN SOA localhost. root.localhost.(
2014061801 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400) ; Minimum
IN NS server01.tarena.com.
server01 IN A 192.168.10.253
$GENERATE 1-100 station$ IN A192.168.10.$
# cat 10.168.192.arpa
$TTL 86400
@ IN SOA localhost. root.localhost.(
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS server01.tarena.com.
253 IN PTR server01.tarena.com.
$GENERATE 1-100$IN PTRstation$
# service named restart
# chkconfig named on
3、配置TFTP
# rpm -q tftp-server
tftp-server-0.49-2
# vim /etc/xinetd.d/tftp
...
13 server_args = -s /tftpboot //文件路径
14 disable = no //启用服务
...
# service xinetd restart
# chkconfig xinetd on
# netstat -tulnp | grep xinetd
udp 0 0 0.0.0.0:69 0.0.0.0:* 5842/xinetd
# rpm -ql syslinux | grep pxelinux.0
/usr/share/syslinux/gpxelinux.0
/usr/share/syslinux/pxelinux.0
# mkdir /tftpboot/pxelinux.cfg //创建目录
# cp/data/iso/rhel5.9/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default //改名为default
# cp /usr/share/syslinux/pxelinux.0/tftpboot/
# cp /data/iso/rhel5.9/isolinux/vmlinuz/tftpboot///内核、镜像到TFTP根目录
# cp/data/iso/rhel5.9/isolinux/initrd.img /tftpboot/
4、配置NFS共享
# cat /etc/exports
/data/iso/rhel5.9 *(ro)
# service portmap restart
# service nfs restart
# chkconfig portmap on
# chkconfig nfs on
或者配置FTP
# yum -y install vsftpd
# tail -n 1 /etc/vsftpd/vsftpd.conf
anon_root=/data/iso/rhel5.9
# service vsftpd restart
# chkconfig vsftpd on
在或者配置HTTP
# yum -y install httpd
# grep DocumentRoot/etc/httpd/conf/httpd.conf |grep -v"^#"
DocumentRoot "/data/iso/rhel5.9"
# grep Indexes/etc/httpd/conf.d/welcome.conf
Options Indexes
# service httpd restart
# chkconfig httpd on
实验二:通过Kickstart实现无人值守安装(接着实验一)
# yum -y installsystem-config-kickstart
操作过程见图片
在/root/ks.cfg文件中添加key --skip
# cp /root/ks.cfg /data/iso/rhel5.9/
//将应答文件不是在客户机可以访问的位置
# vim /tftpboot/pxelinux.cfg/default
...
10 label linux
11 kernel vmlinuz
12 append initrd=initrd.imgks=http://192.168.10.253/ks.cfg
//修改
页:
[1]