两台 linux 服务器之间实现挂载共享
示例环境:
1, Linux 版本:
rhel-server-6.8-x86_64
2, 软件版本:
- nfs4-acl-tools-0.3.3-8.el6.x86_64
- nfs-utils-lib-1.1.5-11.el6.x86_64
- nfs-utlis-1.2.3-70.el6.x86_64
一, 服务端(192.168.122.3)(被共享, 源)
设置允许挂载的目录
修改 /etc/exports , 增加共享目录(共享目录需要自定义创建):
vi /etc/exports
将下述信息复制, 并保存.
/home/share 192.168.122.(rw,sync,no_root_squash)
如下图:
image
其中:
/home/share ?? 是指要共享的目录; 示例中共享的目录是 / home/share
192.168.122.?? 客户端的 ip(允许访问的 ip, 可以直接表示不限制 ip)
(rw)????? 读写权限
重启 nfs 服务: 执行
service nfs restart
二, 客户端(192.168.122.2):
重启 nfs 服务: 执行 service nfs restart
挂载 执行
mount 192.168.122.3:/home/share /home/share
其中 192.168.122.3 是服务端的 IP
192.168.122.3:/home/share ?? 服务端共享的目录
/home/share ?? 客户端本地的目录(该目录可以自定义创建)
取消挂载:
umount /home/share 客户端目录
查看挂载
mount
image
三, 验证
1, 在客户端 (示例: 192.168.122.2) 的 / home/share 路径下创建测试文件, 在服务器端 (示例: 192.168.122.3) 查看是否自动同步;
2, 在服务器端 (示例: 192.168.122.3) 的 / home/share 路径下创建测试文件, 在客户端 (示例: 192.168.122.2) 的 / home/share 查看是否自动同步
来源: http://www.bubuko.com/infodetail-2719457.html