NFS project configuration

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
Insert picture description here
client 2
Insert picture description here
server

[root@fw1 ~]# yum -y install nfs-utils

Insert picture description here

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

Insert picture description here
Insert picture description here
Insert picture description here

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     服务开启

Insert picture description here

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

Insert picture description here
Insert picture description here

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

Insert picture description here
Insert picture description here

Client can access HTML page by opening web service

[root@kh1 ~]# systemctl start httpd

Client web page for testing

http://localhost

Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_49343462/article/details/109516317