NFS本地安装与远程挂载

参考文章: 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

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值