Kickstart自動化安裝平台
随着公司業務不斷增加,經常需要采購新伺服器,并要求安裝Linux系統,并且要求Linux版本要一緻,友善以後的維護和管理,每次人工安裝linux系統會浪費掉更多時間,如果我們有辦法能節省一次一次的時間豈不更好呢?
大中型網際網路公司一次采購伺服器上百台,如果采用人工手動一台一台的安裝,一個人得搞壞N張CD光牒,得多少個加班加點才能完成這項”艱巨”的任務呢,我們可以看到全人工來完成這樣的工作太浪費人力了,有沒有自動化安裝平台呢,通過一台已存在的系統然後克隆或者複制到新的伺服器呢。Kickstart可以毫不費力的完成這項工作。
要使用kickstart安裝平台,包括的完整架構為:Kickstart+DHCP+NFS+TFTP+PXE,從架構可以看出,大緻需要安裝的服務,例如dhcp、tftp、nfs、kickstart/pxe等。
[root@192_168_77_199 ~]# cat /etc/issue
CentOS release 6.6 (Final)
Kernel \r on an \m
[root@192_168_77_199 ~]# uname -r
2.6.32-504.el6.x86_64
yum install -y dhcp* tftp* nfs* syslinux -y
首先配置tftp服務:vi /etc/xinetd.d/tftp,隻需要把disable = yes改成disable = no即可。
ln -s /var/lib/tftpboot/ / 連結到根目錄下面
cd /tftpboot/; cp /usr/share/syslinux/pxelinux.0 . ; cp /mnt/images/pxeboot/{vmlinuz,initrd.img} . ; mkdir pxelinux.cfg ; cp /mnt/isolinux/isolinux.cfg ./default
在default中添加:label centos6.6
kernel vmlinuz
append ks=nfs:192.168.77.199:/data/centos/ks.cfg ksdevice=eth0 initrd=initrd.img
<a href="http://s3.51cto.com/wyfs02/M00/6F/8D/wKioL1Wf7hTBbzB4AAGs6-ods9E741.jpg" target="_blank"></a>
mkdir -p /data/centos ; cd /data/centos/ 共享centos目錄vi /etc/exports添加:/data/centos *(rw,sync) ;nohup cp /mnt/* . -a &背景把CD光牒檔案copy到共享目錄centos下
配置ks.cfg cd /data/centos vi /etc/ks.cfg添加以下配置内容:ks.cfg也可以通過複制root目錄下面的anaconda-ks.cfg進行修改
<code># Kickstart file automatically generated by anaconda.</code>
<code>#version=DEVEL</code>
<code>install</code>
<code>text</code>
<code>nfs --server=192.168.77.199 --</code><code>dir</code><code>=</code><code>/data/centos/</code>
<code>lang zh_CN.UTF-8</code>
<code>keyboard us</code>
<code>network --onboot no --device eth0 --bootproto dhcp --noipv6</code>
<code>rootpw 123456</code>
<code>firewall --disabled</code>
<code>authconfig --enableshadow --passalgo=sha512</code>
<code>selinux --disabled</code>
<code>reboot</code>
<code>timezone Asia</code><code>/Shanghai</code>
<code>bootloader --location=mbr --driveorder=sda --append=</code><code>"rhgb quiet"</code>
<code>zerombr</code>
<code># The following is the partition information you requested</code>
<code># Note that any partitions you deleted are not expressed</code>
<code># here so unless you clear all partitions first, this is</code>
<code># not guaranteed to work</code>
<code>#clearpart --none</code>
<code>clearpart --all --initlabel --drives=sda</code>
<code>part </code><code>/boot</code> <code>--fstype ext4 --size=200</code>
<code>part swap --size=2000</code>
<code>part / --fstype ext4 --size=10000</code>
<code>part </code><code>/data</code> <code>--fstype ext4 --size=1 --grow</code>
<code>#clearpart --all --initlabel</code>
<code>#part /boot --fstype=ext4 --size=200</code>
<code>#part / --fstype=ext4 --size=10000</code>
<code>#part swap --size=2000</code>
<code>#part /data --fstype=ext4 --size=1 --grow</code>
<code>#part /data --fstype=ext4 --grow --size=200</code>
<code>#repo --name="CentOS" --baseurl=cdrom:sr0 --cost=100</code>
<code>%packages</code>
<code>@chinese-support</code>
<code>@core</code>
<code>@development</code>
<code>@eclipse</code>
<code>@emacs</code>
<code>@server-policy</code>
<code>@tex</code>
<code>@workstation-policy</code>
<code>ant</code>
<code>rpmdevtools</code>
<code>jpackage-utils</code>
<code>rpmlint</code>
<code>%end</code>
配置dhcpd服務:
<code>ddns-update-style interim;</code>
<code>ignore client-updates;</code>
<code>next-server 192.168.77.199;</code>
<code>filename </code><code>"pxelinux.0"</code><code>;</code>
<code>allow booting;</code>
<code>allow bootp;</code>
<code>subnet 192.168.77.0 netmask 255.255.255.0 {</code>
<code># --- default gateway</code>
<code>option routers 192.168.77.1;</code>
<code>option subnet-mask 255.255.255.0;</code>
<code>range dynamic-bootp 192.168.77.100 192.168.77.200;</code>
<code>host ns {</code>
<code>hardware ethernet 00:1a:a0:2b:38:81;</code>
<code>fixed-address 192.168.77.101;}</code>
<code>}</code>
service xinetd restart
service nfs restart
service dhcpd restart重新開機服務之後就可以自動安裝了但是需要手動輸入centos6.6
自動安裝不需要輸入任何東西:ks.cfg檔案配置不用改變隻需改一下default裡面的配置如下:
default vesamenu.c32
#prompt 1
default ks
timeout 600
display boot.msg
menu background splash.jpg
menu title Welcome to CentOS 6.6!
menu color border 0 #ffffffff #00000000
menu color sel 7 #ffffffff #ff000000
menu color title 0 #ffffffff #00000000
menu color tabmsg 0 #ffffffff #00000000
menu color unsel 0 #ffffffff #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color scrollbar 0 #ffffffff #00000000
#label ks
# kernel vmlinuz
# append ks=http://192.168.77.199/ks.cfg initrd=initrd.img
label ks
label linux
menu label ^Install or upgrade an existing system
menu default
kernel vmlinuz
append initrd=initrd.img
label vesa
menu label Install system with ^basic video driver
append initrd=initrd.img xdriver=vesa nomodeset
label rescue
menu label ^Rescue installed system
append initrd=initrd.img rescue
label local
menu label Boot from ^local drive
localboot 0xffff
label memtest86
menu label ^Memory test
kernel memtest
append -
以上就是全部配置安裝詳細請參考:
http://www.xue163.com/332/1654/3327690.html
本文轉自 Anonymous123 51CTO部落格,原文連結:http://blog.51cto.com/woshitieren/1673196