参考文章: https://blog.csdn.net/m0_53533877/article/details/130124761
一、nfs 安装、挂载与查看
1.1 本机安装、权限、查看
nfs 安装与操作
[root@localhost /]# yum -y install rpcbind nfs-utils
创建共享目录并且设置相应的权限
#mkdir /data/share/
#chmod 755 -R /data/share/
nfs目录与权限
[root@localhost nfsdata]# vi /etc/exports
/nfsdata *(rw,sync,no_root_squash)
/nfsdata/zookeeper-0 *(rw,sync,no_root_squash)
/nfsdata/zookeeper-1 *(rw,sync,no_root_squash)
/nfsdata/zookeeper-2 *(rw,sync,no_root_squash)
更新配置
exportfs -r
启动服务
按照顺序启动
#systemctl start rpcbind
#systemctl start nfs
加入开机启动项
#systemctl enable rpcbind
#systemctl enable nfs
启动后查看NF服务是否正常
1)查看端口配置是否生效
[root@localhost /]# rpcinfo -p
program vers proto port service
100000 4 tcp 111 portmapper
100000 3 tcp 111 portmapper
100000 2 tcp 111 portmapper
100000 4 udp 111 portmapper
100000 3 udp 111 portmapper
100000 2 udp 111 portmapper
100024 1 udp 58711 status
100024 1 tcp 42688 status
100005 1 udp 20048 mountd
100005 1 tcp 20048 mountd
100005 2 udp 20048 mountd
100005 2 tcp 20048 mountd
100005 3 udp 20048 mountd
100005 3 tcp 20048 mountd
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
100227 3 tcp 2049 nfs_acl
100003 3 udp 2049 nfs
100003 4 udp 2049 nfs
100227 3 udp 2049 nfs_acl
100021 1 udp 38291 nlockmgr
100021 3 udp 38291 nlockmgr
100021 4 udp 38291 nlockmgr
100021 1 tcp 40844 nlockmgr
100021 3 tcp 40844 nlockmgr
100021 4 tcp 40844 nlockmgr
[root@localhost /]#
查看是否可以连接
[root@localhost /]# showmount -e 127.0.0.1
Export list for 127.0.0.1:
/nfsdata/zookeeper-2 *
/nfsdata/zookeeper-1 *
/nfsdata/zookeeper-0 *
/nfsdata *
[root@localhost /]#
2.1 远端查看与挂载
客户端安装
[root@localhost /]# yum -y install rpcbind
[root@localhost /]# yum -y install showmount
查看远端nfs可用的挂在目录与权限
[root@k8s-master zookeeper]# showmount -e 192.168.125.21
Export list for 192.168.125.21:
/nfsdata/zookeeper-2 *
/nfsdata/zookeeper-1 *
/nfsdata/zookeeper-0 *
/nfsdata *
[root@k8s-master zookeeper]#
nfs远端挂在与卸载
确认/mnt/share目录已创建
[root@k8s-master zookeeper]# mount -t nfs 192.168.125.21:/nfsdata /mnt/share/
[root@k8s-master zookeeper]#
[root@k8s-master zookeeper]#
[root@k8s-master zookeeper]# umount /mnt/share/
[root@k8s-master zookeeper]#
设置开机自动挂载
确认/mnt/share目录已创建
[root@k8s-master zookeeper]# vim /etc/rc.d/rc.local
mount -t nfs 192.168.0.111:/nfsdata/zookeeper-0 /mnt/share/ -o nolock,nfsvers=3,vers=3
测试
[root@k8s-master zookeeper]# df -h
[root@k8s-master zookeeper]# df -h
文件系统 容量 已用 可用 已用% 挂载点
192.168.125.21:/nfsdata 50G 4.3G 46G 9% /mnt/share/
[root@k8s-master zookeeper]#
引用文章: https://blog.csdn.net/m0_53533877/article/details/130124761