CentOS7系统之间设置共享文件夹

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_27063119/article/details/77507097

CentOS7系统之间设置共享文件夹


说明:有两台服务器,ip地址分别为:192.168.1.135和192.168.1.137

现将135服务器的文件夹/usr/server/tomcatFile/webapps/bidFile/共享给137服务器

(1)安装NFS

CentOS是自带NFS,所以无需安装,若要安装执行命令:

yum -y installnfs-utils rpcbind

(2)启用NFS

CentOS默认已启动,如果没有启动,需要执行命令:

service rpcbindstart、service nfs start

(3)配置两台服务器的防火墙,执行命令:

firewall-cmd--permanent --add-service=nfs

firewall-cmd--permanent --add-service=mountd

firewall-cmd--permanent --add-service=rpc-bind

firewall-cmd–reload

(4)设置共享目录

在192.168.1.135服务器上设置共享目录,编辑/etc/exports,追加以下内容

/usr/server/tomcatFile/webapps/bidFile/ 192.168.1.137(rw,no_root_squash,no_all_squash,sync)

         为了使配置生效,执行命令:

exportfs –r

 

附:查看已共享的目录命令:

本机:showmount -e

其他:showmount -e IP

(5)挂载共享文件夹

在192.168.1.137服务器上挂载共享文件夹,输入命令:

mount -t nfs 192.168.1.135:/usr/server/tomcatFile/webapps/bidFile/ /usr/server/tomcatFile/webapps/bidFile/

 

(6)测试共享文件夹是否可用

在192.168.1.135服务器的/usr/server/tomcatFile/webapps/bidFile/目录下新建文件1.txt并填写一些内容,

打开192.168.1.137服务器的/usr/server/tomcatFile/webapps/bidFile/目录,若有相同的文件,并且文件中内容一致则表明共享文件夹可用


猜你喜欢

转载自blog.csdn.net/qq_27063119/article/details/77507097
今日推荐