Dhcpd+vsFTPd+TFTP+KickStart+PXE 自动安装RHEL5.4

一 通过网络安装RHEL5.x 系统的原因 为解决大量裸机安装系统,并对系统进行简单的系统调优 在用vsftpd+dhcp+tftp+kickstart 通过网络安装RHEL5.x,kickstart 这里用来定制系统,是安装系统的引导文件

二 系统需求

1 在系统环境下vsftpd tftpd dhcp 为同一台Server ,确保一下软件包已经安装,如果没有安装请安装 Vsftpd-2.0.5-16.el5.i386 Tftp-server-0.49-2.i386 Xinetd-2.3.14-10.el5 system-config-kickstart-2.6.19.8-2.el5 dhcp-3.0.5-21.el5 libdhcp4client-3.0.5-21.el5 libdhcp-1.20-10.el5 dhcp-devel-3.0.5-21.el5 libdhcp4client-devel-3.0.5-21.el5 libdhcp-devel-1.20-10.el5 2 配置dhcp 服务,vsftp 服务等 (注:在此省略了dhcp 服务器的配置) 在dhcp 服务的主配置文件中添加以下两行 next-server 192.168.2.19 ; 注: 该处指定的是tftp 服务器的ip地址 filename “pxelinux.0” #pxe获得IP地址后的引导文件 3 配置tftp 服务,并重启tftp服务 #cd /etc/xinetd.d #vim tftp 修改tftp 配置文件如下 disable=yes ; 修改为disable=no ; #chkconfig tftpd on #service xinetd restart 4 挂载系统光盘,并复制系统安装时必须的引导文件 #mkdir /media/cdrom #mount /dev/cdrom /media/cdrom #cd /tftpboot #cp /usr/lib/syslinux/pxelinux.0 /tftpboot/ #mkdir pxelinux.cfg #cp /media/cdrom/isolinux/isolinux.cfg pxelinux.cfg/default #cp /media/cdrom/images/pxeboot/initrd.img /tftpboot #cp /media/cdrom/images/pxeboot/vmlinuz /tftpboot 5 修改/tftpboot/default 文件如下 #cat /tftpboot/default default linux prompt 1 timeout 10 display boot.msg F1 boot.msg F2 options.msg F3 general.msg F4 param.msg F5 rescue.msg label linux kernel vmlinuz append linux ks=ftp://192.168.2.19/pub/ks.cfg initrd=initrd.img #注 该处是指定ks.cfg 文件.该文件是kickstart 安装配置文件,系统安装该文件进行安装 label text kernel vmlinuz append initrd=initrd.img text label ks kernel vmlinuz append ks=ftp://192.168.2.19/pub/ks.cfg initrd=initrd.img #注 该处是指定ks.cfg 文件.该文件是kickstart 安装配置文件,系统安装该文件进行安装 label local localboot 1 label memtest86 kernel memtest append - 6 配置ks.cfg 文件,可以参照现有的系统上anaconda-ks.cfg ,可以用各种文本编辑器进行修改该文件,当然在这是用system-config-kickstart 编译工具来修改kickstart 文件,同样需要参照anaconda-ks.cfg 文件 #system-config-kickstart & 7 确认在ks.cfg 中的配置文件中key –skip #vim ks.cfg text 注:该处是用文本模式进行安装系统 auth --useshadow --enablemd5 #注: 用户的密码使用md5进行加密 bootloader --append="rhgb quiet" --location=mbr --driveorder=sda zerombr clearpart --linux --drives=sda graphical firewall --disabled firstboot --disable keyboard us key –skip 注:一定要有该选项否则安装时需要手动输入系统的序列号 lang en_US logging --level=info url --url=ftp://192.168.2.19/pub/OS 注:是ftp进行安装系统 network --bootproto=dhcp --device=eth0 --onboot=on reboot rootpw --iscrypted $1$2t748Yno$qJJYHyXe4CioPhP6hjj650 selinux –disabled 注:关闭selinux 系统 skipx timezone --isUtc Asia/Shanghai install clearpart --linux --drives=sda #下面是磁盘分区,当然在此可以手动指定各个分区的大小,注: 磁盘分区根据需求进行划分 part /boot --fstype ext3 --size=100 --ondisk=sda part pv.2 --size=0 --grow --ondisk=sda volgroup VolGroup00 --pesize=32768 pv.2 logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=1000 --grow --maxsize=4000 #系统安装完后执行的脚本;关闭无关的服务及其调优 参照  %post # 注: 系统在安装完后执行的脚本 #set open max file Num sed -i '/# End of file/i * soft nofile 819200' /etc/security/limits.conf sed -i '/# End of file/i * hard nofile 819200' /etc/security/limits.conf #some service are stop chkconfig apmd off chkconfig autofs off chkconfig avahi-daemon off chkconfig avahi-dnsconfd off chkconfig bluetooth off chkconfig hidd off chkconfig hcid off chkconfig dund off chkconfig pand off chkconfig capi off chkconfig cups off chkconfig firstboot off chkconfig iptables off chkconfig ip6tables off chkconfig irda off chkconfig isdn off chkconfig kudzu off chkconfig netplugd off chkconfig pcscd off chkconfig rpcgssd off chkconfig rpcidmapd off chkconfig rpcsvcgssd off chkconfig sendmail off chkconfig wpa_supplicant off chkconfig ypbind off chkconfig yum-updatesd off chkconfig xend off chkconfig setroubleshoot off chkconfig winbind off #System optimization 系统调优 echo "#System Optimization" >>/etc/sysctl.conf sed -i '/#System Optimization/a net.ipv4.tcp_keepalive_intvl = 2' /etc/sysctl.conf sed -i '/#System Optimization/a net.ipv4.tcp_keepalive_probes = 2' /etc/sysctl.conf sed -i '/#System Optimization/a net.ipv4.cp_keepalive_time = 30' /etc/sysctl.conf sed -i '/#System Optimization/a net.ipvtcp_tw_recycle = 1' /etc/sysctl.conf sed -i '/#System Optimization/a net.ipv4.tcp_tw_reuse = 1' /etc/sysctl.conf sed -i '/#System Optimization/a fs.file-max = 819200' /etc/sysctl.conf #set character sed -i 's/en\_US\.UTF\-8/zh\_CN\.GBK/g' /etc/sysconfig/i18n sed -i '/LANG/a LANGUAGE="en_US.GBK' /etc/sysconfig/i18n sed -i '/LANGUAGE/a LC_CTYPE="zh_CN.GBK"' /etc/sysconfig/i18n 8 把ks.cfg 复制在ftp工作目录中 #cp ks.cfg /var/ftp/pub 注: 该处一定要和/tftpboot/pxelinux.cfg 中default 中指定的ks.cfg 的配置位置相同.否则不能通过网络进行安装系统 9 并把系统盘中的镜像文件放在/var/ftp/pub/OS 下面,重启需要安装的物理主机,启动从网络进行启动

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/pxxps.html