无人值守安装部署linux系统——kickstart
关于无人值守方式安装系统,每个厂商都有各自的软件与机制实现,下面就关于红帽公司(RedHat)系统的kickstart技术进行详细部署实践。
Kickstart是一个利用Anconda工具实现服务器自动化安装的方法;通过生成的kickstart配置文件ks.cfg,服务器安装可以实现从裸机到全功能服务的的非交互式(无人值守式)安装配置。
1、
使用kickstart优势:
2、
无人值守部署系统的结构(采用C/S结构)
3、
部署配置(Server端)
部署配置环境是redhat 6.1
内核版本是2.6.32-131.0.15.e16.x86_64
1)安装dhcp软件包
# rpm -ivh dhcp-4.1.1-19.P1.el6.x86_64.rpm
2)修改dhcp配置文件
# vi /etc/dhcp/dhcpd.conf(rhel6.1系统)
===================================================================================
dhcp配置文件实例:
ddns-update-style interim;
ignore client-updates;
allow booting;
allow bootp;
subnet 172.21.0.0 netmask 255.255.255.0 {
range 172.21.0.100 172.21.0.110;
option routers 172.21.0.200;
option subnet-mask 255.255.255.0;
default-lease-time 21600;
max-lease-time 43200;
next-server 172.21.0.200;
filename "pxelinux.0";
}
===================================================================================
3)重启dhcp服务
# service dhcpd restart
4)修改dhcp服务的启动项
# chkconfig dhcpd on
1)安装tftp服务
# rpm -ivh xinetd-2.3.14-31.el6.x86_64.rpm(tftp软件包的依赖包)
# rpm -ivh tftp-server-0.49-5.1.el6.x86_64.rpm
2)修改tftp配置文件
# vi /etc/xinetd.d/tftp
===================================================================================
tftp配置文件实例:
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot -c(增加-c选项)
disable = no(把yes修改为no)
per_source = 11
cps = 100 2
flags = IPv4
}
===================================================================================
由以上信息得知/var/lib/tftpboot为tftp服务的根目录位置
3)重启xinetd服务
# /etc/init.d/xinetd restart
1)安装syslinux软件包
# rpm -ivh mtools-4.0.12-1.el6.x86_64.rpm(syslinux软件包的依赖包)
# rpm -ivh syslinux-4.02-4.el6.x86_64.rpm
2)拷贝pxelinux.0文件到tftp目录中
# rpm -ql syslinux |grep "pxelinux.0"(找出pxelinux.0文件的位置)
# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/(把pxelinux.0的文件拷贝到tftp的根目录中)
# cp isolinux/* /var/lib/tftpboot/(把rhel6.1光盘的isolinux文件中的所有文件拷贝到tftp服务的根目录中)
# cd /var/lib/tftpboot/(进入tftp根目录中)
# mkdir pxelinux.cfg
# mv isolinux.cfg pxelinux.cfg/default
# vi default
===================================================================================
default配置文件实例:
default linux
prompt 1
timeout 60
menu background splash.jpg
menu title Welcome to Red Hat Enterprise Linux 6.1!
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 linux
menu label ^Install or upgrade an existing system
menu default
kernel vmlinuz
append ks=nfs:172.21.0.200:/share/install/ks.cfg initrd=initrd.img(应答文件存储位置——nfs共享文件夹中)
label vesa
menu label Install system with ^basic video driver
kernel vmlinuz
append initrd=initrd.img xdriver=vesa nomodeset
label rescue
menu label ^Rescue installed system
kernel vmlinuz
append initrd=initrd.img rescue
label local
menu label Boot from ^local drive
localboot 0xffff
label memtest86
menu label ^Memory test
kernel memtest
append -
===================================================================================
1)安装nfs服务
# rpm -qa |grep nfs(默认情况下nfs已经安装完毕)
2)创建nfs共享
# mkdir /share/install(根据自己的实际情况进行设定)
# cp /media/rhel6.1/* /share/install
# vi /etc/exports
===================================================================================
exports配置文件实例:
/share/install * (ro,sync)
===================================================================================
3)重启nfs服务
# service rpcsvcgssd restart
# service nfs restart
4)检测nfs共享状态
# showmount -e localhost
5)设置nfs服务启动项
# chkconfig nfs on
1)基于系统自带的配置文件进行修改
# cp /root/anaconda-ks.cfg /share/install/ks.cfg
# chmod a+r /share/install/ks.cfg
# vi /share/install/ks.cfg
===================================================================================
ks.cfg配置文件实例:
# Kickstart file automatically generated by anaconda.
#version=DEVEL
installnfs --server=172.21.0.200 --dir=/share/install(第一处修改)
lang en_US.
UTF-8keyboard us
key -skip(增加一项)
network --onboot=on --bootproto=dhcp --device eth0(第二处修改)
rootpw --iscrypted $6$E4MDxbyTP29uEBJ.$EoLlx0sAUr9FDCOSPA2R4XnSQ3jeTVPgZjtZWBvxhPhjAXuVCBTiibYpC6Z8FBjwd7s/JoBE2lxUs2I1Ta8mu1
firewall --disabled(第三处修改)
authconfig --enableshadow --enablemd5(第四处修改)
selinux --disabled(第五处修改)
timezone Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
clearpart --all --drives=sda --initlabel(第六处修改)
part /boot --fstype=ext4 --asprimary --size=1024(第七处修改)
part / --fstype=ext4 --size=20480(第八处修改)
part swap --size=1024(第九处修改)
%packages
@base
@client-mgmt-tools
@console-internet
@core@debugging
@directory-client
@hardware-monitoring
@java-platform
@large-systems
@network-file-system-client
@performance
@perl-runtime
@server-platform
@server-policy
pax
python-dmide
code
oddjob
sgpio
certmonger
pam_krb5
krb5-workstation
perl-DBD-SQLite
%end
===================================================================================
4、客户端配置
在客户机中配置网卡启动服务器即可,剩下的就是自动化的无应答方式的安装linux系统了。