Project requirements:
Two clients, one server
Two clients to install Apache, server installation needs to install rpcbind and nfs software packages
Project process
Install apache server on two clients install nfs
[root@kh1 ~]# yum -y install httpd
Install nfs-utils on client 1
client 2
server
[root@fw1 ~]# yum -y install nfs-utils
Create a shared directory
[root@fw1 ~]# mkdir /opt/web1 创建目录
[root@fw1 ~]# mkdir /opt/web2
[root@fw1 ~]# cd /opt/web1
[root@fw1 web1]# vi index.html 网页编辑
<html><title>web1</title><body><h1>this is web1!!</h1></body></html>
[root@fw1 web1]# cp index.html /opt/web2
[root@fw1 web1]# cd /opt/web2
[root@fw1 web2]# vi index.html
<html><title>web2</title><body><h1>this is web2!!</h1></body></html>
[root@fw1 web2]# cd
Start service
[root@fw1 ~]# vi /etc/exports
/opt/web1 20.0.0.10(ro)
/opt/web2 20.0.0.11(ro)
[root@fw1 ~]# systemctl start nfs 服务开启
[root@fw1 ~]# systemctl start rpcbind 服务开启
View the NFS shared directory published by the machine
[root@fw1 ~]# showmount -e
/opt/web2 20.0.0.11
/opt/web1 20.0.0.10
View the shared content of the NFS server on each
client Client 1
[root@kh1 ~]# showmount -e 20.0.0.12
/opt/web2 20.0.0.11
/opt/web1 20.0.0.10
进行挂载
[root@kh1 ~]# mount 20.0.0.12:/opt/web1 /var/www/html/
[root@kh1 ~]# df -Th
[root@kh1 ~]# cd /var/www/html/
[root@kh1 html]# ls -lh
[root@kh1 html]# vi index.html
Client 2
[root@kh2 ~]# showmount -e 20.0.0.12
/opt/web2 20.0.0.11
/opt/web1 20.0.0.10
[root@kh2 ~]# mount 20.0.0.12:/opt/web2 /var/www/html/
[root@kh2 ~]# df -Th
[root@kh2 ~]# cd /var/www/html/
[root@kh2 html]# ls -lh
[root@kh2 html]# vi index.html
Client can access HTML page by opening web service
[root@kh1 ~]# systemctl start httpd
Client web page for testing
http://localhost