RHEL5 kickstart 安装小结
系统版本:RHEL5 32位
内核版本:2.6.18-8.el5 i686
系统所需服务:tftp、dhcp、ftp、yum
[root@rhel5-1 ~]# rpm -qa | grep vsftp
vsftpd-2.0.5-10.el5
如上面所示安装好vsftp后可以做下面工作。
这里使用创建本地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
[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
[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
}
[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/images/pxeboot/initrd.img /tftpboot/
[root@rhel5-1 pub]#cp/mnt/images/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 -
[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默认不用配置,将yum本地源配置在/var/ftp/pub后,启动FTP服务即可。
在图形界面的终端里输入: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网卡执行安装程序。