实施原理:TFTP+DHCP+NFS+VSFTPD
利用TFTP广播,使客户端获得相应的安装信息
利用DHCP来获取网络地址信息
利用NFS共享安装过程中需要的TFTP文件
利用FTP来下载安装过程中的光盘信息
实施步骤:
(一):安装YUM,以简化服务器搭建时RPM包的安装
(1)挂载光盘,并进入目录安装ftp,
[root@localhost Server]# rpm -ivh vsftpd-2.0.5-12.el5.i386.rpm
(2)将光盘内容复制到/var/ftp/pub/
[root@localhost RHEL_5.2 i386 DVD]# cp -R /media/RHEL_5.2\ i386\ DVD/* /var/ftp/pub/
(3) 安装套件yum、createrepo
[root@localhost Server]# rpm -ivh yum-3.2.8-9.el5.noarch.rpm
[root@localhost Server]# rpm -ivh createrepo-0.4.11-3.el5.noarch.rpm
(4)制作解决依赖性问题
[root@localhost Server]# createrepo -g /var/ftp/pub/Server/repodata/comps-rhel5-server-core.xml /var/ftp/pub/Server/
[root@localhost Server]# createrepo –g /var/ftp/pub/VT/repodata/comps-rhel5-vt.xml /var/ftp/pub/VT/
[root@localhost Server]# createrepo -g /var/ftp/pub/Cluster/repodata/comps-rhel5-cluster.xml /var/ftp/pub/Cluster
[root@localhost Server]# createrepo -g /var/ftp/pub/ClusterStorage/repodata/comps-rhel5-cluster.xml /var/ftp/pub/ClusterStorage/
(4)配置yum库
[root@localhost Server]# cp -p /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/base.repo
[root@localhost Server]# vim /etc/yum.repos.d/base.repo
[server]
name=Red Hat Enterprise Linux-server
baseurl=ftp://192.168.1.254/pub/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-RedHat-release
[vt]
name=Red Hat Enterprise Linux-vt
baseurl=ftp://192.168.1.254/pub/VT
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[Cluster]
name=Red Hat Enterprise Linux-cluster
baseurl=ftp://192.168.1.254/pub/Cluster
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[clusterstorage]
name=Red Hat Enterprise Linux-clusterStorage
baseurl=ftp://192.168.1.254/pub/ClusterStorage
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
~至此yum安装已经完成了。www.linuxidc.com
(二):安装并配置DHCP
(1)安装包
[root@localhost Server]# yum -y install dhcpd
(2)配置DHCP
[root@localhost ~]# cat /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample >>/etc/dhcpd.conf
(3)在配置文件中加入选项支持pxe功能,具体内容见文件
option space PXE;
option PXE.mtftp-ip code 1 = ip-address;
option PXE.mtftp-cport code 2 = unsigned integer 16;
option PXE.mtftp-sport code 3 = unsigned integer 16;
option PXE.mtftp-tmout code 4 = unsigned integer 8;
option PXE.mtftp-delay code 5 = unsigned integer 8;
option PXE.discovery-control code 6 = unsigned integer 8;
option PXE.discovery-mcast-addr code 7 = ip-address;
class “pxeclients” {
match if substring (option vendor-class-identifier, 0, 9) = “PXEClient”;
option vendor-class-identifier “PXEClient”;
vendor-option-space PXE;
option PXE.mtftp-ip 0.0.0.0;
filename “pxelinux.0”;
next-server 192.168.1.254;
option broadcast-address 192.168.1.255; }
ddns-update-style interim;
ignore client-updates;
subnet 192.168.1.0 netmask 255.255.255.0 {
# — default gateway
option routers 192.168.1.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.254;
option time-offset -18000; # Eastern Standard Time
# option ntp-servers 192.168.1.1;
# option netbios-name-servers 192.168.1.1;
# — Selects point-to-point node (default is hybrid). Don’t change this unless
# — you understand Netbios very well
# option netbios-node-type 2;
range dynamic-bootp 192.168.1.128 192.168.1.245;
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed address
host ns {
next-server marvin.RedHat.com;
hardware ethernet 12:34:56:78:AB:CD;
fixed-address 207.175.42.254;
}
}
(4)启动dhcp服务:
[root@localhost ~]# service dhcpd start
(三)安装tftp套件
(1)[root@localhost Server]# yum -y install tftp
(2)配置tftp服务器:主要将disabled=yes 修改为no
[root@localhost Server]# vim /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
{
disable = no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
per_source = 11
cps = 100 2
flags = IPv4
(四)配置nfs
(1)安装套件:[root@localhost Server]# yum -y install nfs-utils
(2)配置nfs:
[root@localhost Server]# vim /etc/exports
/var/ftp/pub/* *(ro,sync,root_squash)
/tftpboot *(ro,sync,root_squash)
(五):将tftp需要的文件复制到/tftpboot
(1)将光盘中的isolinux目录中的文件复制到/tftpboot
[root@localhost tftpboot]# cp -p /var/ftp/pub/isolinux/ /tftpboot/
(2)新建目录,并在目录中新建文件
[root@localhost isolinux]# mkdir /tftpboot/pxelinux.cfg/
[root@localhost isolinux]# cp -p /var/ftp/pub/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/
[root@localhost pxelinux.cfg]# mv isolinux.cfg default
然后将/usr/lib/syslinux/pxelinux.0复制到/tftp
(六):至此所有的工作已经做完了,只需重启所有的服务
[root@localhost pxelinux.cfg]# chkconfig tftp on
[root@localhost pxelinux.cfg]# chkconfig nfs on
[root@localhost pxelinux.cfg]# chkconfig vsftpd on
[root@localhost pxelinux.cfg]# chkconfig dhcpd on
给另外一台机器加电测试:如图: