配置 node02
提供 NFS 服务
-
安装 NFS 服务:
sudo yum install nfs-utils -y
-
创建共享目录:
sudo mkdir -p /nfs/rhce
-
配置 NFS 共享:
编辑/etc/exports
文件并添加以下行:/nfs/rhce node01(rw,sync,no_root_squash)
-
启动并启用 NFS 服务:
sudo systemctl start nfs sudo systemctl enable nfs
配置 node01
使用 autofs 挂载 NFS 目录
-
安装 autofs:
sudo yum install autofs -y
-
配置 autofs:
编辑/etc/auto.master
文件,添加以下行:/- /etc/auto.nfs
创建
/etc/auto.nfs
文件,添加以下行:/nfs/rhce -rw,node02:/nfs/rhce
-
启动并启用 autofs 服务:
sudo systemctl start autofs sudo systemctl enable autofs
配置 node01
提供 DNS 服务
-
安装 DNS 服务:
sudo yum install bind bind-utils -y
-
配置 DNS:
编辑/etc/named.conf
文件,确保listen-on
和allow-query
设置为您的网络。添加正向区域和反向区域配置:zone "rhce.com" IN { type master; file "/var/named/rhce.com.zone"; allow-update { none; }; }; zone "0.168.192.in-addr.arpa" IN { type master; file "/var/named/192.168.0.zone"; allow-update { none; }; };
-
创建区域文件:
创建/var/named/rhce.com.zone
文件,内容如下:$TTL 86400 @ IN SOA ns1.rhce.com. root.rhce.com. ( 2020071001 ; Serial 3600 ; Refresh 1800 ; Retry 604800 ; Expire 86400 ; Minimum TTL ) @ IN NS ns1.rhce.com. ns1 IN A 192.168.0.1 node01 IN A 192.168.0.1 node02 IN A 192.168.0.2
创建
/var/named/192.168.0.zone
文件,内容如下:$TTL 86400 @ IN SOA ns1.rhce.com. root.rhce.com. ( 2020071001 ; Serial 3600 ; Refresh 1800 ; Retry 604800 ; Expire 86400 ; Minimum TTL ) @ IN NS ns1.rhce.com. 1 IN PTR node01.rhce.com. 2 IN PTR node02.rhce.com.
-
启动并启用 DNS 服务:
sudo systemctl start named sudo systemctl enable named
配置 node01
提供 WEB 服务
-
安装 Apache 服务:
sudo yum install httpd -y
-
配置虚拟主机:
创建/etc/httpd/conf.d/rhce.conf
文件,内容如下:<VirtualHost *:80> ServerName www.rhce.com DocumentRoot /nfs/rhce <Directory /nfs/rhce> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> </VirtualHost>
-
启动并启用 Apache 服务:
sudo systemctl start httpd sudo systemctl enable httpd
确保服务在重启后依然正常运行
-
验证 autofs 挂载:
ls /nfs/rhce
-
验证 DNS 配置:
nslookup node01.rhce.com nslookup node02.rhce.com