項目目的:
該服務環境搭建完畢後,應能夠爲同一網絡(局域網)內的考試機提供考試過程中所涉及的所有網絡服務及資源服務。
項目分析:
根據RHCE考場環境、現有的RHCE考試題目及相關資料,分析可知,考試服務器應提供以下服務:
序號 |
服務種類 |
服務內容 |
a |
HTTP服務 |
用於考試題目及相關說明的展示,和考試過程中所需資源的下載 |
b |
FTP服務 |
用於考試過程中所需資源的下載及PXE自助裝機安裝源 |
c |
RHEL YUM源 |
用於提供考試過程中所需服務的安裝來源 |
d |
DNS服務 |
用於考試環境中所需的域名解析 |
e |
DHCP服務 |
用於PXE裝機過程中網絡參數自動分配 |
f |
TFTP服務 |
用於提供PXE裝機時所需啓動文件 |
g |
PXE裝機服務 |
用於實現考試用機統一標準化快速部署(網絡無人值守安裝) |
h |
ISCSI服務 |
用於提供考試過程中ISCSI網絡硬盤 |
i |
LDAP服務 |
用於實現考試過程中LDAP相關操作 |
注:能力有限,LDAP服務的實現加TLS CA認證短期內還搞不明白,後期補上。 |
項目實現:(以RHEL6.4版本爲例)
考場網絡參數聲明
域: example.com
網段: 192.168.0.0/24
服務器: instructor.example.com
服務器地址: 192.168.0.254/24
網關地址: 192.168.0.254/24
服務器網絡參數設定
[root@local ~]# vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=instructor.example.com
[root@local ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
UUID=8036a915-dc88-47bc-a67b-4eebc77fb308
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.254
NETMASK=255.255.255.0
HWADDR=00:0C:29:DA:32:B2
HTTP服務實現
插入光盤,配置YUM源
[root@localhost Desktop]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# rm -rf *
[root@localhost yum.repos.d]# vim abc.repo
[abc]
name=RHEL YUM Source
baseurl=file:///misc/cd/
enabled=1
gpgcheck=0
安裝httpd
[root@localhost Desktop]# yum install -y httpd
[root@localhost Desktop]# service httpd start
[root@localhost Desktop]# chkconfig httpd on
FTP服務實現
[root@localhost Desktop]# yum install -y vsftpd
[root@localhost Desktop]# service vsftpd start
[root@localhost Desktop]# chkconfig vsftpd on
[root@localhost Desktop]# cp cdrom.iso /var/ftp/pub/ ;考試用iso鏡像
YUM源實現(http、ftp兩種方式)
ftp方式實現
[root@localhost ~]# mkdir -p /var/ftp/pub/rhel6/dvd
[root@localhost ~]# mkdir -p /var/ftp/pub/rhel6/site
[root@instructor ~]# cp -r /misc/cd/* /var/ftp/pub/rhel6/dvd/
[root@instructor ~]# echo station.domain.example.com > \
> /var/ftp/pub/rhel6/site/station.html ;創建考試用三個首頁文件
[root@instructor ~]# echo www.domain.example.com > \
> /var/ftp/pub/rhel6/site/station.html
[root@instructor ~]# echo Confidential > /var/ftp/pub/rhel6/site/
confidential.html
http方式實現
[root@instructor ~]# vim /etc/httpd/conf/httpd.conf
Options Indexes FollowSymLinks ;實現自動索引啓用符號鏈接
[root@instructor ~]# ln -s /var/ftp/pub/ /var/www/html/
DNS服務實現
[root@instructor ~]# yum install -y bind bind-chroot
[root@instructor ~]# vim /var/named/chroot/etc/named.conf
options {
directory "/var/named";
};
zone "example.com" IN{
type master;
file "example.com.zone";
};
[root@instructor ~]# vim /var/named/chroot/var/named/example.com.zone
$TTL 86400
@ IN SOA example.com. root.example.com. (
0000000001
4H
15M
4H
1D
)
@ IN NS instructor.example.com.
instructor IN A 192.168.0.254
$GENERATE 1-200 station.domain$ IN A 192.168.0.$
[root@instructor ~]# service named start
[root@instructor ~]# chkconfig named on
DHCP服務實現
[root@instructor ~]# yum install -y dhcp
[root@instructor ~]# vim /etc/dhcp/dhcpd.conf
ddns-update-style none;
ignore client-updates;
subnet 192.168.0.0 netmask 255.255.255.0
{
option routers 192.168.0.254;
option subnet-mask 255.255.255.0;
option domain-name "example.com";
option domain-name-servers 192.168.0.254;
range 192.168.0.1 192.168.0.250;
}
[root@instructor ~]# service dhcpd start
[root@instructor ~]# chkconfig dhcpd on
TFTP服務實現
[root@instructor ~]# yum install -y tftp-server
[root@instructor ~]# service xinetd start
[root@instructor ~]# chkconfig tftp on
[root@instructor ~]# chkconfig xinetd on
PXE網絡安裝服務
PXE網絡安裝
[root@instructor ~]# cd /var/ftp/pub/rhel6/dvd/isolinux/
[root@instructor isolinux]# cp vmlinuz initrd.img /var/lib/tftpboot/
[root@instructor isolinux]# yum install -y syslinux
[root@instructor isolinux]# cd /usr/share/syslinux/
[root@instructor syslinux]# cp pxelinux.0 /var/lib/tftpboot/
[root@instructor ~]# mkdir /var/lib/tftpboot/pxelinux.cfg/
[root@instructor ~]# cd /var/lib/tftpboot/pxelinux.cfg/
[root@instructor pxelinux.cfg]# cp /var/ftp/pub/rhel6/dvd/isolinux/isolinux.cfg default
無人值守
[root@instructor ~]# yum install -y system-config-kickstart
[root@instructor ~]# system-config-kickstart ;自定義無人值守安裝應答文件並保存至/var/ftp/pub/ks.cfg
[root@instructor ~]# vim /var/lib/tftpboot/pxelinux.cfg/default
default linux
#prompt 1
timeout 600
label linux
kernel vmlinuz
append ks=ftp://192.168.0.254/pub/ks.cfg initrd=initrd.img
ISCSI服務
[root@instructor ~]# yum install -y scsi-target-utils
[root@instructor ~]# fdisk -cu /dev/sdb
Command (m for help): p
Device Boot Start End Blocks Id System
/dev/sdb1 2048 41943039 20970496 83 Linux
[root@instructor ~]# partx -a /dev/sdb
[root@instructor ~]# vim /etc/tgt/targets.conf
<target iqn.2008-09.com.example:rdisk.server>
backing-store /dev/sdb1
allow-in-use yes
</target> ;添加ISCSI硬盤