[Linux] - centos使用mount + nfs 远程共享存储

服务端安装nfs

1、使用yum安装nfs

yum install nfs-utils nfs-utils-lib -y

如果安装过程出现这样的错误:

得先安装lvm2

yum install -y lvm2

 

2、编辑文件exports

vim /etc/exports

加入代码,如:

/home 192.168.1.100(rw,sync,no_root_squash,no_subtree_check)

#参数详解
ro #只读共享
rw #读写共享
sync #同步写操作
async #异步写操作
wdelay #延迟写操作
root_squash #屏蔽远程root权限
no_root_squash #不屏蔽远程root权限
all_squash #屏蔽所有远程用户的权限
no_subtree_check #此选项可防止子树检查

 

3、运行导出

exportfs -a

 可以使用-r刷新

exportfs -r

 

4、开启端口

/sbin/iptables -I INPUT -p tcp -s 192.168.1.100 --dport 111 -j ACCEPT
/sbin/iptables -I INPUT -p tcp -s 192.168.1.100 --dport 2049 -j ACCEPT
/sbin/iptables -I INPUT -p tcp -s 192.168.1.100 --dport 30001 -j ACCEPT
/sbin/iptables -I INPUT -p tcp -s 192.168.1.100 --dport 30002 -j ACCEPT
/sbin/iptables -I INPUT -p tcp -s 192.168.1.100 --dport 30003 -j ACCEPT
/sbin/iptables -I INPUT -p tcp -s 192.168.1.100 --dport 30004 -j ACCEPT

 

5、启动nfs和rpc服务

service nfs-server start
service rpcbind start

 

客户端安装nfs

1、安装nfs

yum install nfs-utils -y

 

2、使用mount远程共享

mount -t nfs 192.168.1.100:/home /home

 

到此完成。


 

 

如果要把home链接到别的目录,可以使用例如如下命令:

ln -s /home /root/home

 

取消挂载可以使用命令:

umount -t nfs 192.168.1.100:/home

 

挂载开机启动可以使用如下方式

1、编辑

vim /etc/fstab

 

2、加入代码

192.168.1.100:/home /home nfs defaults 0 0

 

查看NFS共享,可以使用命令:

showmount -e 192.168.1.100

 

转载于:https://www.cnblogs.com/HD/p/5977163.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值