天天看点

Kickstart 同时push多个linux操作系统

 在生产环境中,经常要安装不同版本的linux操作系统,以及各种安装需求;每次安装操作系统的时候如果用传统的光盘方式安装,费时又费力!下面介绍下如何在同一个时刻,使用kickstart push不同的版本的linux,主要有三个版本centos4.8,rhel5.4,rhel6.0和一个linux rescue环境!

一:配置dhcp服务,ks服务器地址为192.168.50.7/24

[root@rhel5 ~]# rpm -qa |grep dhcp  

dhcpv6-client-1.0.10-17.el5  

dhcp-3.0.5-23.el5_5.2  

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

option domain-name "766.com";  

default-lease-time 6000;  

max-lease-time 11400;  

authourtative;  

next-server 192.168.50.7;  

ddns-update-style ad-hoc;  

log-facility local7;  

subnet 192.168.50.0 netmask 255.255.255.0{  

range 192.168.50.150 192.168.50.195;  

option domain-name-servers 192.168.50.254;  

option netbios-name-servers 192.168.50.254;  

option routers 192.168.50.254;  

option broadcast-address 192.168.50.255;  

filename "/kickstart/ks.cfg";  

}  

option space PXE;  

class "PXE" {  

    match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";  

    option vendor-encapsulated-options 01:04:00:00:00:00:ff;  

    option boot-size 0x1;  

    filename "pxelinux.0";  

    option tftp-server-name "192.168.50.7";  

    option vendor-class-identifier "PXEClient";  

    vendor-option-space PXE;  

二:配置tftp-server,准备vmlinz和initrd.img文件

[root@rhel5 ~]# rpm -qa |egrep 'tftp|xinetd'  

tftp-0.49-2.el5.centos  

tftp-server-0.49-2.el5.centos  

xinetd-2.3.14-10.el5  

[root@rhel5 ~]# cat /etc/xinetd.d/tftp   

# default: off  

# description: The tftp server serves files using the trivial file transfer \  

#       protocol.  The tftp protocol is often used to boot diskless \  

#       workstations, download configuration files to network-aware printers, \  

#       and to start the installation process for some operating systems.  

service tftp  

{  

        socket_type             = dgram 

        protocol                = udp 

        wait                    = yes 

        user                    = root 

        server                  = /usr/sbin/in.tftpd  

        server_args             = -s /tftpboot  

        disable                 = no   

        per_source              = 11 

        cps                     = 100 2  

        flags                   = IPv4 

这些文件可以在对应的系统光盘或者ISO文件下的isolinux目录下找到  

[root@rhel5 ~]# ls /tftpboot/rhel5.4_64/  

initrd.img  vmlinuz  

[root@rhel5 ~]# ls /tftpboot/rhel6_64/  

[root@rhel5 ~]# ls /tftpboot/centos4.8_64/  

initrd.img  vmlinuz 

三:配置相关文件

复制pxelinux.0文件至/tftpboot目录下,该文件由syslinux软件包提供,用来pxe启动linux使用

[root@rhel5 ~]# rpm -qf /usr/lib/syslinux/pxelinux.0 

syslinux-3.11-4

复制rhel5光盘下的isolinux目录下的文件至/tftpboot目录下,其中vmlinuz和initrd.img文件可以不用复制,在/tftpboot目录下创建一个名为pxelinux.cfg的目录,并将/tftpboot目录下的isolinux.cfg文件移到到该目录,重命名为default;KS文件可以在安装好的linux上使用system-config-kickstart命令生成

[root@rhel5 ~]# ls /tftpboot/  

boot.cat  centos4.8_64  isolinux.bin  memtest      param.msg   pxelinux.cfg  rhel5.4_64  splash.lss  

boot.msg  general.msg   isolinux.cfg  options.msg  pxelinux.0  rescue.msg    rhel6_64    TRANS.TBL  

[root@rhel5 ~]# cat /tftpboot/pxelinux.cfg/default   

default rhel5_rescue  

prompt 1  

timeout 600  

display boot.msg  

F1 boot.msg  

F2 options.msg  

F3 general.msg  

F4 param.msg  

F5 rescue.msg  

label rhel5_rescue  

 kernel rhel5.4_64/vmlinuz   

 append ksdevice=eth0 load_ramdisk=1 initrd=rhel5.4_64/initrd.img noipv6  

label rhel5.4_64  

  kernel rhel5.4_64/vmlinuz  

  append ksdevice=eth0 load_ramdisk=1 initrd=rhel5.4_64/initrd.img ks=ftp://192.168.50.7/ks/ks5_64.cfg noipv6  

label rhel6_64  

  kernel rhel6_64/vmlinuz  

  append ksdevice=eth0 load_ramdisk=1 initrd=rhel6_64/initrd.img   ks=ftp://192.168.50.7/ks/ks6_64.cfg  noipv6  

label centos4.8_64  

  kernel centos4.8_64/vmlinuz  

  append ksdevice=eth0 load_ramdisk=1 initrd=centos4.8_64/initrd.img   ks=ftp://192.168.50.7/ks/ks4.8_64.cfg  noipv6  

[root@rhel5 ~]# cat /tftpboot/boot.msg   

#To decide  install  os type and enter command to continue  

linux resuce       --->     rhel5_rescue  rescue  

rhel5.4 64bit      --->     rhel5.4_64  

rhel6.0 64bit      --->     rhel6_64  

centos4.8 64bit    --->     centos4.8_64   

四:配置FTP和autofs,这里将利用ftp和autofs为安装提供光盘源镜像

[root@rhel5 ~]# rpm -qa |egrep 'vsftpd|autofs'  

vsftpd-2.0.5-16.el5_5.1  

autofs-5.0.1-0.rc2.131.el5  

[root@rhel5 ~]# tail -1 /etc/auto.master   

/var/ftp/pub /etc/auto.ftp  

[root@rhel5 ~]# cat /etc/auto.ftp   

iso5        -fstype=iso9660,ro,loop :/data/ISO/rhel-server-5.4-x86_64-dvd.iso  

iso4.8      -fstype=iso9660,ro,loop :/data/ISO/CentOS-4.8-x86_64-binDVD.iso  

iso6        -fstype=iso9660,ro,loop :/data/ISO/rhel6.iso 

五:启动服务和测试 

[root@rhel5 ~]# service dhcpd restart  

Shutting down dhcpd: [  OK  ]  

Starting dhcpd: [  OK  ]  

[root@rhel5 ~]# service vsftpd restart  

Shutting down vsftpd: [  OK  ]  

Starting vsftpd for vsftpd: [  OK  ]  

[root@rhel5 ~]# service autofs restart  

Stopping automount: [  OK  ]  

Starting automount: [  OK  ]  

[root@rhel5 ~]# service xinetd restart  

Stopping xinetd: [  OK  ]  

Starting xinetd: [  OK  ]  

[root@rhel5 ~]# tail -f /var/log/messages  

Jun 13 17:40:42 rhel5 dhcpd: DHCPDISCOVER from 00:0c:29:4c:0f:d5 via br0  

Jun 13 17:40:43 rhel5 dhcpd: DHCPOFFER on 192.168.50.184 to 00:0c:29:4c:0f:d5 via br0  

Jun 13 17:40:44 rhel5 dhcpd: DHCPREQUEST for 192.168.50.184 (192.168.50.7) from 00:0c:29:4c:0f:d5 via br0  

Jun 13 17:40:44 rhel5 dhcpd: DHCPACK on 192.168.50.184 to 00:0c:29:4c:0f:d5 via br0  

Jun 13 17:40:44 rhel5 xinetd[1794]: START: tftp pid=2829 from=192.168.50.184  

[root@rhel5 ~]# tail -f /var/log/xferlog  

Mon Jun 13 08:46:25 2011 1 192.168.50.184 0 /pub/iso5/RELEASE-NOTES-en_US.UTF-8.html b _ o a anonymous@ ftp 0 * i  

Mon Jun 13 08:46:25 2011 1 192.168.50.184 0 /pub/iso5/RELEASE-NOTES.en_US.UTF-8 b _ o a anonymous@ ftp 0 * i  

Mon Jun 13 08:46:25 2011 1 192.168.50.184 0 /pub/iso5/RELEASE-NOTES-en_US.html b _ o a anonymous@ ftp 0 * i  

Mon Jun 13 08:46:25 2011 1 192.168.50.184 0 /pub/iso5/RELEASE-NOTES.en_US b _ o a anonymous@ ftp 0 * i  

Mon Jun 13 08:46:26 2011 1 192.168.50.184 80344 /pub/iso5/RELEASE-NOTES-en.html b _ o a anonymous@ ftp 0 * c  

Mon Jun 13 08:49:48 2011 1 192.168.50.184 0 /pub/iso5/images/updates.img b _ o a rhinstall@ ftp 0 * i  

Mon Jun 13 08:49:48 2011 1 192.168.50.184 0 /pub/iso5/disc1/images/updates.img b _ o a rhinstall@ ftp 0 * i  

Mon Jun 13 08:49:48 2011 1 192.168.50.184 0 /pub/iso5/images/product.img b _ o a rhinstall@ ftp 0 * i  

Mon Jun 13 08:49:48 2011 1 192.168.50.184 0 /pub/iso5/disc1/images/product.img b _ o a rhinstall@ ftp 0 * i  

Mon Jun 13 08:49:56 2011 8 192.168.50.184 91160576 /pub/iso5/images/stage2.img b _ o a rhinstall@ ftp 0 * c 

<a target="_blank" href="http://blog.51cto.com/attachment/201106/174357142.jpg"></a>

<a href="http://down.51cto.com/data/2358361" target="_blank">附件:http://down.51cto.com/data/2358361</a>

本文转自斩月博客51CTO博客,原文链接http://blog.51cto.com/ylw6006/587303如需转载请自行联系原作者

ylw6006

继续阅读