在生産環境中,經常要安裝不同版本的linux作業系統,以及各種安裝需求;每次安裝作業系統的時候如果用傳統的CD光牒方式安裝,費時又費力!下面介紹下如何在同一個時刻,使用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
這些檔案可以在對應的系統CD光牒或者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
複制rhel5CD光牒下的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為安裝提供CD光牒源鏡像
[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