nfs套娃
起因:因nfs服务器磁盘快爆满了,业务还需拓展,考虑到其他服务器磁盘资源充足,应开发需求,套娃之路从此开始
hostname | ip | server |
---|---|---|
data | 192.168.1.2 | nfs-server |
image | 192.168.1.3 | nfs-server |
原结构
套娃后结构
第一层套娃
[root@data ~]# yum install -y nfs-utils rpcbind
[root@data ~]# systemctl start rpcbind && systemctl enable rpcbind
[root@data ~]# mkdir /data
[root@data ~]# vim /etc/exports
/data 192.168.1.0/24(rw,no_root_squash,no_all_squash,sync)
[root@data ~]# systemctl start nfs-server && systemctl enable nfs-server
[root@image ~]# yum install -y nfs-utils rpcbind
[root@image ~]# systemctl start rpcbind && systemctl enable rpcbind
[root@image ~]# showmount -e 192.168.1.2
Export list for 192.168.1.2:
/data 192.168.1.0/24
[root@image ~]# mkdir /data
# 挂载第一个nfs
[root@image ~]# mount 192.168.1.2:/data /data
[root@image ~]# vim /etc/fstab
# 配置开机挂载
192.168.1.2:/data /data nfs defaults 0 0
# 测试第一个nfs
[root@data ~]# touch /data/test1
[root@image ~]# ls /data
test1
[root@image ~]# touch /data/test2
[root@data ~]# ls /data
test1 test2
第二层套娃
[root@image ~]# mkdir /image
[root@image ~]# vim /etc/exports
/image 192.168.1.0/24(rw,no_root_squash,no_all_squash,sync)
[root@image ~]# systemctl start nfs-server && systemctl enable nfs-server
[root@data ~]# showmount -e 192.168.1.3
Export list for 192.168.1.3:
/image 192.168.1.0/24
[root@data ~]# mkdir /data/image
[root@data ~]# mount 192.168.1.3:/image /data/image
[root@data ~]# vim /etc/fstab
192.168.1.3:/image /data/image nfs defaults 0 0
# 这里192.168.1.3也需要挂载,否则192.168.1.3无法获取到192.168.1.2:/data/image的信息,只有在192.168.1.3:/image才有记录,192.168.1.3:/data/image不会有记录
# 以下为只在192.168.1.2挂载的测试记录
[root@data ~]# touch /data/image/test3
[root@data ~]# ls /data/image
test3
[root@image ~]# ls /data/image
# 此时返回为空
[root@image ~]# ls /image
test3
[root@image ~]# mount 192.168.1.3:/image /data/image
[root@image ~]# vim /etc/fstab
192.168.1.3:/image /data/image nfs defaults 0 0
[root@image ~]# ls /data/image
test3
[root@image ~]# touch /data/image/test4
[root@image ~]# ls /data/image
test3 test4
[root@image ~]# ls /image
test3 test4
[root@data ~]# ls /data/image
test3 test4
[root@data ~]# touch /data/image/test5
[root@data ~]# ls /data/image
test3 test4 test5
[root@image ~]# ls /data/image
test3 test4 test5
[root@image ~]# ls /image
test3 test4 test5
# 至此套娃结束