RHEL5 kickstart 安裝小結
環境簡介
系統版本:RHEL5 32位
內核版本:2.6.18-8.el5 i686
系統所需服務:tftp、dhcp、ftp、yum
創建ftp
[root@rhel5-1 ~]# rpm -qa | grep vsftp
vsftpd-2.0.5-10.el5
如上面所示安裝好vsftp後可以做下面工作。
搭建YUM源
這裏使用創建本地yum源,並且yum源所在根目錄爲ftp默認目錄
[root@rhel5-1 ~]# mount /dev/cdrom /mnt/
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@rhel5-1 ~]# cp -Rap /mnt/* /var/ftp/pub/
[root@rhel5-1 ~]# vi /etc/yum.repos.d/rhel5.repo
[Server]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///var/ftp/pub/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[VT]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///var/ftp/pub/VT
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[Cluster]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///var/ftp/pub/Cluster
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[ClusterStorage]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///var/ftp/pub/ClusterStorage
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[root@rhel5-1 pub]# yum clean all
Loading "rhnplugin" plugin
Loading "installonlyn" plugin
Repository 'Cluster' is missing name in configuration, using id
Repository 'ClusterStorage' is missing name in configuration, using id
Repository 'VT' is missing name in configuration, using id
Repository 'Server' is missing name in configuration, using id
This system is not registered with RHN.
RHN support will be disabled.
Cleaning up Everything
[root@rhel5-1 pub]#cd /var/ftp/pub
[root@rhel5-1 pub]# createrepo .
2045/2208 - Server/jakarta-commons-collections-testframework-javadoc-3.1-6jpp.1.2208/2208 - VT/Virtualization-ko-KR-5.0.0-7.noarch.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata
[root@rhel5-1 pub]# yum update
Loading "rhnplugin" plugin
Loading "installonlyn" plugin
Repository 'Cluster' is missing name in configuration, using id
Repository 'ClusterStorage' is missing name in configuration, using id
Repository 'VT' is missing name in configuration, using id
Repository 'Server' is missing name in configuration, using id
This system is not registered with RHN.
RHN support will be disabled.
Setting up Update Process
Setting up repositories
Cluster 100% |=========================| 1.3 kB 00:00
ClusterStorage 100% |=========================| 1.3 kB 00:00
VT 100% |=========================| 1.3 kB 00:00
Server 100% |=========================| 1.3 kB 00:00
Reading repository metadata in from local files
primary.xml.gz 100% |=========================| 6.4 kB 00:00
################################################## 32/32
primary.xml.gz 100% |=========================| 4.2 kB 00:00
################################################## 32/32
primary.xml.gz 100% |=========================| 6.0 kB 00:00
################################################## 31/31
primary.xml.gz 100% |=========================| 663 kB 00:00
################################################## 2113/2113
No Packages marked for Update/Obsoletion
利用YUM安裝服務
[root@rhel5-1 pub]# yum install tftp
[root@rhel5-1 pub]# yum install tftp-server
[root@rhel5-1 pub]# yum install dhcp
[root@rhel5-1 pub]# yum install system-config-kickstart
配置服務
配置tftp
[root@rhel5-1 pub]# vi /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
}
配置PXE啓動
[root@rhel5-1 ~]# mount /dev/cdrom /mnt/
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@rhel5-1 pub]#cp/usr/lib/syslinux/pxelinux.0 /tftpboot/
[root@rhel5-1 pub]#cd /tftpboot/
[root@rhel5-1 pub]#mkdir/tftpboot/pxelinux.cfg
[root@rhel5-1 pub]#cp/mnt/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
[root@rhel5-1 pub]#cp/mnt/p_w_picpaths/pxeboot/initrd.img /tftpboot/
[root@rhel5-1 pub]#cp/mnt/p_w_picpaths/pxeboot/vmlinuz /tftpboot/
[root@rhel5-1 pub]#chmodu+w/tftpboot/pxelinux.cfg/default //文件默認只讀
[root@rhel5-1 pub]#vi /tftpboot/pxelinux.cfg/default
default linux
prompt 1
timeout 100 #超時原來爲600s,這裏配置100s
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
kernel vmlinuz
append initrd=initrd.img ks=ftp://192.168.10.50/pub/ks.cfg #指向ks.cfg的配置文件。
label text
kernel vmlinuz
append initrd=initrd.img text
label ks
kernel vmlinuz
append ks initrd=initrd.img
label local
localboot 1
label memtest86
kernel memtest
append -
配置DHCP
[root@rhel5-1 pub]# vi /etc/dhcpd.conf
ddns-update-style none;
ignore client-updates;
subnet 192.168.10.0 netmask 255.255.255.0 {
filename "pxelinux.0";
next-server 192.168.10.50;#next-server即PXE服務器
# --- default gateway
option routers 192.168.10.254;
option subnet-mask 255.255.255.0;
# option nis-domain "domain.org";
# option domain-name "domain.org";
# option domain-name-servers 192.168.1.1;
option time-offset -18000; # Eastern Standard Time
# option ntp-servers 192.168.1.1;
# option netbios-name-servers 192.168.1.1;
# option netbios-node-type 2;
range dynamic-bootp 192.168.10.200 192.168.10.202;#地址池
default-lease-time 21600;
max-lease-time 43200;
配置ftp
FTP默認不用配置,將yum本地源配置在/var/ftp/pub後,啓動FTP服務即可。
配置kickstart
在圖形界面的終端裏輸入:system-config-kickstart後,kickstart會以圖形界面的形式出現,根據要求配置後會生成一個ks.cfg的kickstart的配置引導文件,將此文件複製到/var/ftp/pub下。ks.cfg的內容如下:
#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth --useshadow --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --linux --initlabel
# Use graphical install
graphical
# Firewall configuration
firewall --disabled
# Run the Setup Agent on first boot
firstboot --disable
key --skip
# System keyboard
keyboard us
# System language
lang en_US
# Installation logging level
logging --level=info
# Use network installation
url --url=ftp://192.168.10.50/pub
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot
#Root password
rootpw 123456
# SELinux configuration
selinux --disabled
# System timezone
timezone Asia/Urumqi
# Install OS instead of upgrade
install
# X Window System configuration information
xconfig --defaultdesktop=GNOME --depth=8 --resolution=640x480 --startxonboot
# Disk partitioning information
part /boot --bytes-per-inode=4096 --fstype="ext3" --size=1028
part swap --bytes-per-inode=4096 --fstype="swap" --size=2048
part / --bytes-per-inode=4096 --fstype="ext3" --grow --size=1
%packages
@admin-tools
@base
@chinese-support
@core
@development-libs
@development-tools
@dialup
@editors
@ftp-server
@gnome-desktop
@gnome-software-development
@java
@java-development
@legacy-software-development
@legacy-software-support
@ruby
@system-tools
@text-internet
@x-software-development
@base-x
kexec-tools
device-mapper-multipath
imake
emacs
audit
mesa-libGLU-devel
xorg-x11-utils
xorg-x11-server-Xnest
xorg-x11-server-Xvfb
啓動服務
[root@rhel5-1 pub]#service dhcpd start
[root@rhel5-1 pub]#service vsftpd start
[root@rhel5-1 pub]#service xinetd start
[root@rhel5-1 pub]#chkconfig dhcpd on
[root@rhel5-1 pub]#chkconfig vsftpd on
[root@rhel5-1 pub]#chkconfig xinetd on
注意在配置過程要關閉防火牆和selinux。
測試客戶端
將客戶端服務器通過pxe啓動後,如果配置正確所有安裝均會無人職守化安裝。
問題備註:
問題1:
在kickstart安裝過程中常會遇到各種錯誤,現在將我在配置中所遇到的錯誤進行註解。
如上錯誤是顯示關於在安裝過程中無法找到鏡像文件的庫信息和安裝目錄樹,在這裏要明確注意,如果你的YUM和發佈的安裝源文件都是一個目錄文件,那麼就會造成如圖上面的問題,原因是在搭建YUM過程中要重新的生成其庫安裝索引,這個會與安裝源文件的MD5校驗產生衝突,所以會顯示YUM可以使用,但是在kickstart安裝過程中會產生各種蹊蹺的問題。
解決辦法
爲了解決這個問題最好YUM源和安裝文件源使用兩個不同的文件目錄,並且將對應修改的內容添加至ks.cfg文件。在安裝文件的發佈我使用原來光盤鏡像掛載的方法,這樣就可以減少對安裝源文件的修改,從而避免錯誤的發生。
問題2:
在真實的安裝環境當中,很多服務器都是雙網卡,如果在按照上面配置去做,不能真正實現kicksart無人值守化安裝,在多網卡環境當中,雖然安裝時只接入一塊網卡,但是在anaconda安裝執行時會自動監測到系統存在雙網卡,安裝過程會讓手動選擇從哪個網卡啓動,在RHEL6中也有同樣問題存在。雖然在ks文件中寫明瞭eth0網卡用dhcp獲得地址,但是還會有問題存在,如下所示:
network --bootproto=dhcp --device=eth0 --onboot=on
上面說明了eth0網卡用dhcp獲得地址,但是在安裝過程中,anaconda安裝執行時會自動監測到系統存在雙網卡,安裝過程會讓手動選擇從哪個網卡啓動,所以上面配置無法解決現有的問題。
若有很多服務器同時安裝那麼選擇網卡也是很麻煩的問題。在REDhat kickstart中,這個問題可以在tftp服務器引導文件照中解決,在default 中添加一個ksdevice參數,如下所示:
label linux
kernel vmlinuz
append ksdevice=eth0 initrd=initrd.img ks=ftp://192.168.2.1/pub/ks.cfg
ksdevice=eth0,即從第一塊網卡啓動,這樣就制定了啓動網卡,而anaconda也會從eth0網卡執行安裝程序。