NFS项目配置

项目需求:
两台客户机,一台服务器
两台客户机安装Apache,服务器安装需要安装rpcbind和nfs软件包

项目流程
两台客户机上安装apache 服务器安装nfs

[root@kh1 ~]# yum -y install httpd

客户机1
在这里插入图片描述
客户机2
在这里插入图片描述
服务器上安装nfs-utils

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

在这里插入图片描述

创建共享目录

[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

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

启动服务

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

在这里插入图片描述

查看本机发布的NFS共享目录

[root@fw1 ~]# showmount -e
/opt/web2 20.0.0.11
/opt/web1 20.0.0.10

客户机上分别进行查看NFS服务器共享内容
客户机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

在这里插入图片描述
在这里插入图片描述

客户机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

在这里插入图片描述
在这里插入图片描述

客户机开启网页服务即可访问HTML页面

[root@kh1 ~]# systemctl start httpd

客户机网页进行测试

http://localhost

在这里插入图片描述
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_49343462/article/details/109516317