Linux Centos7 远程挂载网络磁盘/共享目录-NFS共享文件夹操作

服务端操作

【1】安装NFS程序

yum -y install nfs

rpcbind,在centos6以前自带的yum源中为portmap。

使用yum安装nfs时会下载依赖,因此只要下载nfs即可,无需再下载rpcbind.


【2】查看是否安装了nfs与rpcbind

rpm -qa |grep nfs

rpm -qa |grep rpcbind


【3】创建共享的目录并共享

如要共享的目录已存在请跳过创建(也可以进行手动创建)

mkdir  /mnt/NFS/resource


然后编辑下面的文件:

vim /etc/exports

-- 把下面的加入到文件/etc/exports中

/mnt/NFS/resource  10.8.200.202/24(rw,no_root_squash,sync,no_wdelay)

/mnt/NFS/resource  10.8.200.205/24(rw,no_root_squash,sync,no_wdelay)

【4】启动nfs,rpcbind,并设为开机自启

(centos7)

systemctl start nfs

systemctl start rpcbind

systemctl enable nfs

systemctl enable rpcbind

(centos6)

service nfs start

service rpcbind start


【5】查看是否共享成功

showmount -e localhost

可看到共享的目录及客户端,即为成功

如果报下面错误,则需要把防火墙关闭

 ==========================================================================================

客户端操作

 

【1】安装NFS程序

yum -y install nfs


【2】启动nfs

(centos7)

systemctl start nfs

systemctl start rpcbind

systemctl enable nfs

systemctl enable rpcbind

(centos6)

service nfs start

service rpcbind start

chkconfig nfs on

chkconfig rpcbind on


【3】创建挂载目录

mkdir /res_base/prd/


【4】查看是否共享成功

showmount -e nfs服务端IP(10.8.200.204 是NFS的服务器)

showmount -e 10.8.200.204    

10.8.200.202,10.8.200.205是远程访问共享服务器的客户端IP


【5】网络挂载

mount -t nfs -o nolock 服务端IP:共享目录绝对路径 本地挂载目录

mount -t nfs -o nolock 10.8.200.204:/mnt/NFS/resource/  /res_base/prd

开机自动挂载

vi /etc/fstab

# 新增一行

10.8.200.132:/mnt/NFS/resource/ /res_base/prd                    nfs4    defaults        0 0

centos7的nfs默认使用的是nfs4,所以mount -t 无需指定nfs4也可以


【6】查看是否成功

df -Th 

【7】卸载网络磁盘

与卸载本地挂载相同

umount /res_base/prd

umount 10.8.200.132:/mnt/NFS/resource   

Window 10挂载NFS操作

 

 

 

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值