搭建PXE Server

实验拓扑:

                         

-----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、设置网络参数

[root@localhost ~]# ifconfig eth0 | grep "inetaddr"

          inetaddr:192.168.10.253 Bcast:192.168.10.255  Mask:255.255.255.0

[root@localhost ~]# cat /etc/sysconfig/network

NETWORKING=yes

NETWORKING_IPV6=yes

HOSTNAME=server01.tarena.com

[root@localhost ~]# grep server01 /etc/hosts

192.168.10.253 server01.example.com    server01

2、创建YUM源

[root@localhost ~]# mkdir -p /data/iso/rhel5.9

//放入rhel5.9 iso

[root@localhost ~]# cp -rpf /misc/cd/* /data/iso/rhel5.9/

3、配置YUM客户端

[root@localhost ~]# cd /etc/yum.repos.d/

[root@localhost yum.repos.d]# cp rhel-debuginfo.reporhel5.9.repo

[root@localhost yum.repos.d]# cat rhel5.9.repo

[rhel-server]

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)

[root@server01 ~]# rpm -q dhcp                    //检查是否安装了dhcp

package dhcp is not installed                          //提示没有安装

[root@server01 ~]# yum -y install dhcp          //安装dhcp

[root@server01 ~]# 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;

}

[root@server01 ~]# service dhcpd restart             //开启服务

[root@server01 ~]# chkconfig dhcpd on              //开机自启

[root@server01 ~]# netstat -tulnp | grep :67         //查看dhcp端口

udp        0      0 0.0.0.0:67               0.0.0.0:*                     5219/dhcpd   

2、配置DNS

[root@server01 ~]# rpm -q bind bind-chrootcaching-nameserver

package bind is not installed

package bind-chroot is not installed

package caching-nameserver is not installed

[root@server01 ~]# yum -y install bind bind-chrootcaching- nameserver

[root@server01 ~]# cd /var/named/chroot/etc/

[root@server01 etc]# cp -pnamed.caching-nameserver.conf  named.conf

[root@server01 etc]# 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; };

[root@server01 etc]# vim named.rfc1912.zones

...

    51  zone"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";

 [root@server01 etc]#named-checkconf named.conf  //检测语法是否出错

[root@server01 etc]# cd /var/named/chroot/var/named/

[root@server01 named]# cp -p named.local tarena.com.zone

[root@server01 named]# 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 A  192.168.10.$

[root@localhost named]# 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 PTR  station$

 

[root@server01 named]# service named restart

[root@server01 named]# chkconfig named on

3、配置TFTP

[root@server01 ~]# rpm -q tftp-server

tftp-server-0.49-2

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

...

 13         server_args             = -s /tftpboot        //文件路径

 14         disable                 = no                    //启用服务

...

[root@server01 ~]# service xinetd restart

[root@server01 ~]# chkconfig xinetd on

[root@server01 ~]# netstat -tulnp | grep xinetd

udp        0      0 0.0.0.0:69                  0.0.0.0:*                 5842/xinetd 

[root@server01 ~]# rpm -ql syslinux | grep pxelinux.0

/usr/share/syslinux/gpxelinux.0

/usr/share/syslinux/pxelinux.0

[root@server01 ~]# mkdir /tftpboot/pxelinux.cfg       //创建目录

[root@server01 ~]# cp/data/iso/rhel5.9/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default     //改名为default

[root@server01 ~]# cp /usr/share/syslinux/pxelinux.0/tftpboot/

[root@server01 ~]# cp /data/iso/rhel5.9/isolinux/vmlinuz/tftpboot/  //内核、镜像到TFTP根目录

[root@server01 ~]# cp/data/iso/rhel5.9/isolinux/initrd.img /tftpboot/

4、配置NFS共享

[root@localhost ~]# cat /etc/exports

/data/iso/rhel5.9      *(ro)

[root@localhost ~]# service portmap restart

[root@localhost ~]# service nfs restart

[root@localhost ~]# chkconfig portmap on

[root@localhost ~]# chkconfig nfs on

或者配置FTP

[root@server01 ~]# yum -y install vsftpd

[root@server01 ~]# tail -n 1 /etc/vsftpd/vsftpd.conf

anon_root=/data/iso/rhel5.9

[root@server01 ~]# service vsftpd restart

[root@server01 ~]# chkconfig vsftpd on

在或者配置HTTP

[root@server01 ~]# yum -y install httpd

[root@server01 ~]# grep DocumentRoot/etc/httpd/conf/httpd.conf |  grep -v"^#"

DocumentRoot "/data/iso/rhel5.9"

[root@server01 ~]# grep Indexes/etc/httpd/conf.d/welcome.conf

    Options Indexes

[root@server01 ~]# service httpd restart

[root@server01 ~]# chkconfig httpd on

 

实验二:通过Kickstart实现无人值守安装(接着实验一)

[root@localhost ~]# yum -y installsystem-config-kickstart

操作过程见图片

在/root/ks.cfg文件中添加key --skip

[root@localhost ~]# cp /root/ks.cfg /data/iso/rhel5.9/ 

//将应答文件不是在客户机可以访问的位置

[root@server01 ~]# vim /tftpboot/pxelinux.cfg/default

...

 10 label linux     

 11   kernel vmlinuz

 12   append initrd=initrd.imgks=http://192.168.10.253/ks.cfg

//修改


你可能感兴趣的:(server,搭建,pxe)