CentOS6.3 x86_64搭建RHCE6实验环境:
1.搭建ftp服务(使用vsftpd软件包):
mount /dev/sr0 /media
cat >> /etc/yum.repo.d/CentOS-DVD.repo<# This is CentOS 6.3 x86_64 DVD repo
[DVD]
name=CentOS 6.3 DVD repo
baseurl=file:///media/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
EOF
[ -r /etc/init.d/vsftpd ] || yum install -y --disablerepo=\* --enablerepo=DVD vsftpd
service vsftpd restart
chkconfig vsftpd on
mkdir /var/ftp/pub/CentOS6
cp -R /media/* /var/ftp/pub/CentOS6/
umount /media
cat >> /etc/yum.repo.d/CentOS-DVD.repo<# This is CentOS 6.3 x86_64 DVD repo
[DVD]
name=CentOS 6.3 DVD repo
baseurl=file:///var/ftp/pub/CentOS6/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
EOF
2.安装system-config-kickstart
mkdir /etc/yum.repo.d/backup
下面将系统原本的yum仓库备份:
find /etc/yum.repo.d/ ! -name "*DVD*" -exec mv {} /etc/yum.repo.d/backup/ \;
yum install -y --disablerepo=\* --enablerepo=DVD system-config-kickstart
配置kickstart文件,我用xshell登录服务器,同时将服务器x window映射回我的win7
setenforce 0
iptables -F
xhost +
system-config-kickstart
保存kickstart文件到/var/ftp/pub/vt_ks.cfg,下面在服务器安装虚拟化相关的包
lsmod | grep kvm &> /dev/null || yum groupinstall "virtualization*"
好啦,现在可以用kvm虚拟机测试下,前面配置vt_ks.cfg时选择的包最好最小使得安装虚拟机变快,这样实
现ftp安装
xhost +
virt-manager
3.安装httpd服务,从http启动安装,配置文件在/etc/httpd/下
yum install -y httpd
yum install -y links
echo 'It works!' > /var/www/html/index.html
service httpd start
chkconfig httpd on
好啦,测试下服务
links http://instructor.example.com
ln -s /var/ftp/pub/centos6 /var/www/html/inst
再用system-config-kickstart配置个从httpd安装的kickstart文件,保存在/var/www/html/下即可
可以测试http boot安装了。
4.安装nfs服务
[ -r /etc/init.d/nfs ] || yum install nfs*
service nfs start
chkconfig nfs on
vim /etc/exports
5.安装tftp服务,tftp目录为/var/lib/tftpboot,该目录可配置PXE
yum install -y tftp
修改配置文件/etc/xinetd.d
disable = no #将yes改为no
通过重启xinetd 启动tftp服务
配置pxe tftpboot目录
mkdir /var/lib/tftpboot/pxelinux.cfg
cp /usr/share/syslinux/vesamenu.c32 /var/lib/tftpboot/
cp /var/ftp/pub/centos6/isolinux/vmlinuz /var/lib/tftpboot/vmlinuz_centos63_x64
cp /var/ftp/pub/centos6/isolinux/initrd.img /var/lib/tftpboot/initrd_centos63_x64.img
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
cp /var/ftp/pub/centos6/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
chmod u+w /var/lib/tftpboot/pxelinux.cfg/default
vim /var/lib/tftpboot/pxelinux.cfg/default #内容如下
default vesamenu.c32
#prompt 1
timeout 600
#display boot.msg
menu background splash.jpg
menu title Welcome to my kickstart PXE station!
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 CentOS linux 6.3
menu label ^Install CentOS 6.3_x64 system
menu default
kernel vmlinuz_centos63_x64
append ks=ftp://192.168.201.254/pub/vtks.cfg initrd=initrd_centos63_x64.img
#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 -
#
6.安装dhcp,实现动态分配ip地址
yum install -y dhcp
修改配置文件/etc/dhcpd.d/dhcpd.conf
subnet 192.168.201.0 netmask 255.255.255.0 {
range 192.168.201.10 192.168.201.30;
# option domain-name-servers ns1.internal.example.org;
next-server 192.168.201.254;
filename "pxelinux.0";
option domain-name-servers 192.168.201.254;
option domain-name "example.com";
option routers 192.168.201.254;
option broadcast-address 192.168.201.255;
default-lease-time 600;
max-lease-time 7200;
}
7.创建kickstart文件,用system-config-kickstart,保存文件为/var/ftp/pub/vtks.cfg,内容如下:
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url=" ftp://192.168.201.254/pub/centos6"
# Root password
rootpw --iscrypted $1$4GsqExZv$ObJLH8rkTqvC5umLLUH4q1
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install
text
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --enforcing
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone --isUtc Asia/Shanghai
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="ext4" --size=100
part swap --fstype="swap" --size=1000
part / --fstype="ext4" --size=5000
%post
#Configure hostname
NUM=$(ifconfig eth0 | grep 'inet addr' | awk '{print $2}' | cut -d. -f4)
if [ -z "$NUM" ]
then
echo -e "\033[31mWrong number, please check network settings\033[0m"
exit 2
else
echo -e "NETWORKING=yes" > /etc/sysconfig/network
echo -e "HOSTNAME=station$NUM.example.com" >> /etc/sysconfig/network
fi
#finished log
echo "Installation finished via ftp boot" >> /root/ftpboot-$(date +%Y-%m-%d).log
%end
10.最后重启下network,dhcpd,xinetd确保pxe环境都起来
service network restart
service network xinetd
service network dhcpd
11.好啦,找个客户机装下系统,记住进BIOS看看,确保网卡ROM的PXE功能打开。
总结:该PXE功能较简单,主要靠dhcp+tftp/vsftp+kickstart,且ftp中系统安装目录单一,做好每个版本
下设有x86,x64版本,还有没加入windows的安装项,也没用DNS服务因而直接使用了ip地址作为ftp服务确保安装过程不出错。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27795363/viewspace-750944/,如需转载,请注明出处,否则将追究法律责任。