您的位置:首页 > 理论基础 > 计算机网络

基于PXE,kickstart实现通过网络自动安装CentOS6.5

2014-07-30 16:45 876 查看
PXE(preboot execute environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持工作站通过网络从远端服务器下载映像,并由此支持通过网络启动操作系统,在启动过程中,终端要求服务器分配IP地址,再用TFTP(trivial file transfer protocol)或MTFTP(multicast trivial file transfer protocol)协议下载一个启动软件包到本机内存中执行,由这个启动软件包完成终端(客户?)基本软件设置,从而引导预先安装在服务器中的终端操作系统。接下来,就让我们通DHCP+HTTP+TFTP来实现通过PXE安装CentOS 6.5.1.安装DHCP服务器,使网卡可以获取到IP地址,并且可以找到有安装文件的TFTP服务器,并编辑dhcp服务的配置文件.
[root@localhost ~]# yum install dhcp
[root@localhost ~]# rpm -q dhcp
dhcp-4.1.1-38.P1.el6.centos.x86_64
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf


接着我们启动DHCP服务,并开启一台无操作系统虚拟机,监测网卡是否可以获得IP地址[root@localhost ~]# service dhcpd startStarting dhcpd: [ OK ]启动虚拟机,可以看到地址获取成功,但是由于我们还没有安装TFTP,所以安装过程也就进不去了接下来我们就需要配置TFTP服务了.

2.我们需要安装TFTP服务,将/etc/xintetd.d/tftp文件中的disable改为no,接着启动xinetd服务,
[root@localhost ~]# yum install tftp-server tftp
[root@localhost ~]# rpm -q tftp-server tftp
[root@localhost ~]# rpm -q tftp-server tftp
tftp-server-0.49-7.el6.x86_64
tftp-0.49-7.el6.x86_64


通过查看端口,可以看到TFTP的69号端口已经打开

3.接下来,我们需要把PXE启动需要的文件和引导内核文件都拷贝到TFTP的工作目录/var/lib/tftproot下#安装syslinux软件包
[root@localhost tftpboot]# yum install syslinux
[root@localhost tftpboot]# rpm -q syslinux
syslinux-4.02-8.el6.x86_64
[root@localhost tftpboot]# rpm -ql syslinux |grep 0$
/usr/share/syslinux/gpxelinux.0
/usr/share/syslinux/pxelinux.0
[root@localhost tftpboot]# cp /usr/share/syslinux/pxelinux.0 ./
#复制引导内核文件
[root@localhost ~]# mount /dev/cdrom /mnt/cdrom/
[root@localhost ~]# cp /mnt/cdrom/images/pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot/
[root@localhost ~]# mkdir /var/lib/tftpboot/pxelinux.cfg
[root@localhost /]# cp /mnt/cdrom/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
此时我们应该已经可以进入安装界面,

4.基于HTTPD配置yum软件仓库为PXE提供安装源[root@localhost /]# rpm -q httpdhttpd-2.2.15-29.el6.centos.x86_64#通过光盘提供yum仓库[root@localhost /]# mount --bind /mnt/cdrom/ /var/www/html/cdrom/#启动服务[root@localhost /]# service httpd startStarting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName [ OK ]#通过浏览器测试源是否可以正常访问

5.提供ks.cfg文件#安装system-config-kickstart
[root@localhost /]# yum install system-config-kickstart
[root@localhost /]# rpm -q system-config-kickstart
system-config-kickstart-2.8.6.5-1.el6.noarch
#通过xstart运行systm-config-kickatart,生成ks.cfg文件



#ks.kfg文件详细内容
[root@localhost /]# cat ~/ks.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url="http://172.16.21.250/cdrom"
# Root password
rootpw --iscrypted $1$8kLebhx5$XaCCpB3fvBnQutl9iQW3S1
# 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 --disabled
# Installation logging level
logging --level=info

# System timezone
timezone  Asia/Chongqing
# Network information
network  --bootproto=dhcp --device=eth0 --onboot=on
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all
# Disk partitioning information
part / --fstype="ext4" --ondisk=sda --size=8000
part /boot --fstype="ext4" --ondisk=sda --size=500
part swap --fstype="swap" --size=1000

%packages
@chinese-support
@ftp-server
@internet-browser
@web-server

%end
6.测试可否通过网络远程自动安装系统#指定ks文件位置并回车运行

#可以看到系统已经在自动分区

#正在安装软件包,可见yum源配置也没有问题

#系统安装完成

本文出自 “淡淡” 博客,请务必保留此出处http://dddbk.blog.51cto.com/6837943/1532889
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: