LINUX无人值守安装多台服务器

前言:本文介绍了PC平台上的一种快速Red Hat Linux 5.9安装方案。它具有很高的自动化程度,用户只需要手工启动机器并选择从网络启动,就可以完成整个安装过程。在需要批量安装大量Red Hat Linux5.9系统的情况下,这种方案可以节省大量的时间。而且由于不需要额外的软件和光驱等硬件设备,在成本上也有很大的有事。最后希望安装Red Hat Linux的开放/测试人员和IT支持人员都能够从本人获益

一、实验拓扑:

                       -----PXE Servervmnet1-------------Clientvmnet1------


二、具体实现:

1、配置DHCP(给需要安装系统的主机分配ip

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

inet addr:192.168.10.10  Bcast:192.168.10.255  Mask:255.255.255.0  

              //设置PXE Server IP

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

[root@localhostyum.repos.d]# cp rhel-debuginfo.repo rhel.repo

[root@localhostyum.repos.d]# cat rhel.repo

[rhel-server]

name=Red HatEnterprise Linux 5.9 Server

baseurl=file:///misc/cd/Server

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release  

                 //配置yum数据库

[root@localhost~]# rpm -q dhcp

package dhcp isnot installed

[root@localhost~]# yum -y install dhcp                  

                 //安装dhcp服务软件包

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

ddns-update-styleinterim;

next-server192.168.10.10;

filename"pxelinux.0";

subnet192.168.10.0 netmask 255.255.255.0 {

       option subnet-mask              255.255.255.0;

       option domain-name              "tarena.com";

       option domain-name-servers      192.168.10.10;

       range dynamic-bootp 192.168.10.50192.168.10.100;

       default-lease-time 21600;

       max-lease-time 43200;

}                                  

                  //修改dhcp服务配置文件

[root@localhost~]# service dhcpd restart    

[root@localhost~]# chkconfig dhcpd on

              //启动服务并设置开机自启动

[root@localhost~]# netstat -tulnp | grep :67

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

               //查看服务是否启动

2、配置TFTP

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

tftp-server-0.49-2                    

               //查看tftp服务软件包已经安装

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

...

13        server_args             = -s/tftpboot

14        disable                 = no

.. .                                                  //修改tftp配置文件

[root@localhost~]# service xinetd restart

[root@localhost~]# chkconfig xinetd on        

                //开启服务并设置开机自启动

[root@localhost~]# netstat -tulnp | grep :69

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

               //查看服务状态,确认服务已启动

3、配置VSFTP

[root@localhost~]# yum -y install vsftp*

                                                 //安装vsftpd服务软件包

[root@localhost~]# service vsftpd restart

[root@localhost~]# chkconfig vsftpd on

                //启动服务

4、配置DNS

[root@localhost ~]# yum -yinstall bind bind-chroot caching- nameserver

               //安装软件包

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


[root@localhostetc]# cp -p named.caching-nameserver.conf named.conf

[root@localhostetc]# vim named.conf

...

15        listen-on port 53 { 192.168.10.10; };

...

27        allow-query     { any; };

28        allow-query-cache { any; };

...

37        match-clients      { any; };

38        match-destinations { any; };

               //进入主配置文件named.conf进行配置

[root@localhostetc]# vim named.rfc1912.zones

...

51 zone "tarena.com" IN {

52        type master;

53        file "tarena.com.zone";

54 };

55

56 zone "10.168.192.in-addr.arpa" IN{

57        type master;

58        file "tarena.com.arpa";

59 };

             //进入主配置文件named.rfc1912.zones配置

[root@ser1 etc]#named-checkconf named.conf    

              //检测配置文件语法是否正确

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

               //修改数据库文件

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

[root@localhostnamed]# cp -p named.local tarena.com.arpa

                //复制数据库文件模板修改

[root@localhostnamed]# cat tarena.com.zone    


$TTL    86400

@       IN     SOA     localhost.root.localhost.  (

                                    1997022700 ; Serial

                                    28800      ; Refresh

                                    14400      ; Retry

                                    3600000    ; Expire

                                     86400)    ; Minimum

       IN     NS      dns1.tarena.com.

dns1    IN     A       192.168.10.10

www     IN     A       192.168.10.11

bbs     IN     A       192.168.10.12

$GENERATE 50-100station$  IN  A  192.168.10.$           //泛域名正向解析

               //配置正向解析文件

[root@localhost named]# cat tarena.com.arpa    

$TTL    86400

@       IN     SOA     localhost.root.localhost.  (

                                     1997022700; Serial

                                    28800      ; Refresh

                                    14400      ; Retry

                                    3600000    ; Expire

                                     86400)    ; Minimum

       IN     NS      dns1.tarena.com.

10      IN     PTR     dns1.tarena.com.

11      IN     PTR     www.tarena.com.

12      IN     PTR     bbs.tarena.com.

$GENERATE 50-100  $ IN PTR  station$.tarena.com        //泛域名反向解析

              //配置反向解析文件

[root@localhost~]#named-checkzone  tarena.com  tarena.com.zone

zonetarena.com/IN: loaded serial 1997022700

OK

[root@localhostnamed]# named-checkzone tarena.com tarena.com.arpa

zonetarena.com/IN: loaded serial 1997022700

OK                                        

               //检测正向解析文件是否有语法错误

[root@localhostnamed]# service named restart    

[root@localhostnamed]# chkconfig named on

               / /启动服务

5、将所需文件放置在固定位置

[root@localhost~]# cd /misc/cd/p_w_picpaths/pxeboot/

[root@localhostpxeboot]# cp initrd.img vmlinuz /tftpboot/

             //将内核文件和初始化文件放在/tftpboot

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

                                       //将引导文件也复制在/tftpboot/

[root@localhostpxeboot]# mkdir /tftpboot/pxelinux.G    

[root@localhostpxeboot]#cp/misc/cd/isolinux/isolinux.G /tftpboot/pxelinux.G/default      

              //将光盘中的isolinux.G文件拷贝成pxelinux.G下的default

[root@localhostpxeboot]#mkdir /var/ftp/rhel

[root@localhostpxeboot]#mount /dev/cdrom /var/ftp/rhel

                             //将光盘挂载在FTP共享位置以便于找到镜像文件

[root@localhostpxeboot]#vim /tftpboot/pxelinux.0/default

….

F4 param.msg

F5 rescue.msg

label linux

 kernel vmlinuz

 append ks=ftp://192.168.10.10/ks.Ginitrd=initrd.img

label text

kernel vmlinuz

 appendinitrd=initrd.img text

                                                     //添加ks的文件位置

6、使用软件system-config-kickstart形成ks文件

[root@localhostpxeboot]#yum  -y  install  system-config-kickstart

[root@localhostpxeboot]#system-config-kickstart

形成ks文件的步骤如下图所示:


wKiom1NTTdzDARzQAAMKKcLWr6I523.jpg

wKioL1NTTbPB-4K3AAJ7iHnOFJs591.jpg

wKioL1NTTbOiXlSoAAJLEVNyGII646.jpg

wKiom1NTTd2gHp5KAAKoCbR1flo139.jpg

wKiom1NTTd2hwLY0AAGwbE9nznA534.jpg

wKioL1NTTbSwqf0jAAIiIBjxFf0110.jpg

wKiom1NTTd_wrdkPAAIG7Pk8rcU931.jpg

wKioL1NTTbbgbR9gAAJZkwet2aw161.jpg

wKiom1NTTd_zAm8QAAJSIYauCKw209.jpg

wKioL1NTTbezXtOLAALaRe2LV0Q633.jpg

7、在ks文件中添加一行,来实现跳过安装序列号的那个步骤

[root@localhostpxeboot]#vim  /var/ftp/ks.G

…..

clearpart --none

# Use graphical install

graphical

key --skip

# Firewall configuration

firewall --enabled  

……  

8、开启多台服务器,进入BOS选择从网络启动就可以实现无人值守安装了


注:由于小写G在文章中不允许出现,故将小写全部替换成大写。