有時候並不需要部署那麼多的服務器,只是幾臺而已,但是又沒有Kickstart全自動的環境,又不想到每一臺上在那點下一步下一步,就可以用半自動咯。
這裏不做過多說明,ks.cfg文件是必不可少的:
- #platform=x86, AMD64, 或 Intel EM64T
- #version=DEVEL
- # Firewall configuration
- #firewall --enabled
- firewall --disabled
- # Install OS instead of upgrade
- install
- # Use network installation
- url --url="http://192.168.1.39/pub/rhel/6.3/i386/"
- # Root password
- rootpw --iscrypted $1$p2FwPn7z$Fq7pmzmu4WUvbOQz06Gif1
- # System authorization information
- auth --useshadow --passalgo=sha512
- # Use text mode install
- text
- # System keyboard
- keyboard us
- # System language
- lang en_US
- # SELinux configuration
- #selinux --enforcing
- selinux --disabled
- # Do not configure the X Window System
- skipx
- # Installation logging level
- logging --level=info
- # Reboot after installation
- reboot
- # System timezone
- timezone Asia/Shanghai
- # Network information
- network --bootproto=static --device=eth0 --gateway=192.168.1.1 --ip=192.168.1.175 --nameserver=8.8.8.8 --netmask=255.255.255.0 --onboot=on
- # System bootloader configuration
- bootloader --location=mbr
- # Clear the Master Boot Record
- zerombr
- # Partition clearing information
- clearpart --all
- # Disk partitioning information
- part /boot --asprimary --fstype=ext4 --size=200
- part pv.01 --size=10240
- volgroup vg01 --pesize=4096 pv.01
- logvol swap --name=lv_swap --vgname=vg01 --size=512
- logvol / --fstype=ext4 --name=lv_root --vgname=vg01 --grow --size=1
- %post
- #!/bin/bash
- # Post_install Script For RHEL 6
- rm -rf /etc/yum.repo/*
- cat >/etc/yum.repo/rhel6.repo<< EOF
- [base]
- name= RedHat Enterprise Linux 6.3 x86 - DVD Mirror
- baseurl=file:///media/cdrom
- enabled=1
- gpgcheck=0
- EOF
- mkdir /media/cdrom
- mount /dev/cdrom /media/cdrom
- yum -y remove rhnlib yum-rhn-plugin rhn-client-tools rhn-setup rhn-check rhnsd subscription-manager
- echo "set nu" >> /etc/vimrc
- echo "set nu" >> /etc/virc
- ## Disables IPv6
- echo "install ipv6 /bin/true" > /etc/modprobe.d/ipv6.disable.conf
- echo "IPV6INIT=no" >> /etc/sysconfig/network
- ## Disables services
- all_services=(`chkconfig --list | grep 3:on | awk '{print $1}' | grep -Ev "network|sshd"`)
- for i in ${all_services[*]}
- do
- #service $i stop
- chkconfig --level 345 $i off
- done
- echo "/usr/bin/setterm -blank 0" >> /etc/rc.local
- cat >> /etc/bashrc << EOF
- export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
- export HISTFILESIEZE=100000
- export HISTSIZE=10000
- EOF
- source /etc/bashrc
- history -c
- echo "" > ~/.bash_history
- exit
- %end
- %packages
- @base
- %end
分區是使用的LVM,針對以後的應用可能方便點,root密碼是123456。上面的腳本也加入了一些優化參數在安裝後腳本里,可以針對實際情況就行修改。
簡單說下怎麼實現半自動,起碼都的一臺http服務器,有個yum源吧,保證網絡暢通。那光盤啓動,菜單界面按Tab鍵,加入ks文件的路徑:
使用“ks=”寫具體路徑就行了,可以是ftp或者http,建議http,因爲部署容易些。敲回車後就自動安裝了,不用去管下一步下一步了。如果沒有DHCP可能以開始要首先指定下IP地址。
另外還有一個問題,實體服務器一般至少會有兩個以上的網卡(現在一般都4個了),在全自動部署rhel6的時候,就會彈出一下界面進行網卡選擇
必須選擇網卡才能進行下面的自動安裝,這是RHEL5裏沒有這一步。解決方法並沒在ks.cfg裏
看上圖,解決方法在指定ks路徑的時候加上"ksdevice=eth0",指定爲你對應的網卡就行。當然在全自動部署的環境裏,就要在default文件裏在“ks=...”的後面加上ksdevice指定設備去才能實現在生產環境中實體服務器的真正的全自動部署!