要求
一、在主机上提供web,dns服务
服务端
IP:172.25.250.131/24
dns:172.25.250.131
[root@localhost ~]# cd /etc/httpd/conf.d[root@localhost conf.d]# vim vhost.conf
[root@localhost conf.d]# mkdir /nfs/rhce -p[root@localhost conf.d]# echo welcome to www.rhce.com > /nfs/rhce/index.html[root@localhost conf.d]# vim /etc/named.conf
[root@localhost conf.d]# vim /var/named/named.rhce
[root@localhost conf.d]# vim /etc/hosts
[root@localhost conf.d]# firewall-cmd --permanent --add-service=httpsuccess[root@localhost conf.d]# firewall-cmd --permanent --add-service=dnssuccess[root@localhost conf.d]# firewall-cmd --reloadsuccess[root@localhost conf.d]# systemctl restart httpd[root@localhost conf.d]# systemctl restart named
1.2主机域名解析
[root@localhost conf.d]# dig -t A www.rhce.com
1.3查看
[root@localhost conf.d]# curl www.rhce.com
welcome to www.rhce.com
2.nfs共享以及autofs自动挂载
2.1编辑nfs配置文件,新建共享目录,并设置权限
服务端(172.25.250.131/24)
[root@localhost ~]# mkdir /nfs/rhce -p[root@localhost ~]# chmod -Rf 777 /nfs/rhce[root@localhost ~]# vim /etc/exports[root@localhost ~]# cat /etc/exports
/nfs/rhce 172.25.250.132(rw,sync,all_squash)[root@localhost ~]# systemctl restart rpcbind
[root@localhost ~]# systemctl restart nfs-server.service [root@localhost ~]# systemctl enable rpcbind
[root@localhost ~]# systemctl enable nfs-server.service
2.2配置放行防火墙规则
firewall-cmd --permanent --add-service=nfsfirewall-cmd --permanent --add-service=mountdfirewall-cmd --permanent --add-service=rpc-bindfirewall-cmd --reload
[root@localhost ~]# vim /etc/exports
客户端(172.25.250.132/24)
[root@localhost nfs2]# vim /etc/auto.nfs //书写本地挂载目录的子目录及远程共享目录
[root@localhost nfs2]# vim /etc/auto.master
[root@localhost nfs2]# showmount -e 172.25.250.131
[root@localhost nfs2]# systemctl restart autofs
[root@localhost nfs2]# systemctl enable autofs
2.3测试
[root@localhost ~]# df -h //查看挂载信息,这里看还没有挂载
[root@localhost ~]# cd /nfs1 //进入本地挂载目录,会自动新建
[root@localhost ~]# cd /nfs2 //进入本地挂载的下级目录,会触发自动挂载
[root@localhost ~]# df -h //现在查看挂载信息,可以看到已经挂载上了