码迷,mamicode.com
首页 > 其他好文 > 详细

nfs

时间:2020-11-07 15:37:17      阅读:19      评论:0      收藏:0      [点我收藏+]

标签:端口号   ubuntu   当前目录   centos   app   解决办法   映射   some   data   

防火墙都是关闭的
服务端

[root@localhost ~]# yum -y install rpcbind nfs-utils

编辑/etc/exportsp配置文件配置共享目录(配置文件默认可能没有)
root@ubuntu:~# cat /etc/exports
#共享目录 允许访问的IP或网段(参数)
/nfs 192.168.6.0/24(rw,sync,no_root_squash

先启动rpcbind再启动nfs
[root@localhost ~]# systemctl start rpcbind 
[root@localhost ~]# systemctl start nfs-utils.service

用于配置NFS服务程序配置文件的参数:

参数1 作用 2
ro 只读
rw 读写
root_squash 当NFS客户端以root管理员访问时,映射为NFS服务器的匿名用户nfsnobody
no_root_squash 当NFS客户端以root管理员访问时,映射为NFS服务器的root管理员
all_squash 无论NFS客户端使用什么账户访问,均映射为NFS服务器的匿名用户nfsnobody
rsync 同时将数据写入到内存与硬盘中,保证不丢失数据
async 优先将数据保存到内存,然后再写入硬盘;这样效率更高,但可能会丢失数据

[root@NFS ~]# exportfs -r #重载配置文件
root@ubuntu:~# exportfs -rv
exportfs: /etc/exports [1]: Neither ‘subtree_check‘ or ‘no_subtree_check‘ specified for export "192.168.6.0/24:/nfs".
Assuming default behaviour (‘no_subtree_check‘).
NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [2]: Neither ‘subtree_check‘ or ‘no_subtree_check‘ specified for export "192.168.6.0/24:/nfs123".
Assuming default behaviour (‘no_subtree_check‘).
NOTE: this default has changed since nfs-utils version 1.0.x

exporting 192.168.6.0/24:/nfs123
exporting 192.168.6.0/24:/nfs

查看NFS服务是否向rpc注册端口信息,rpc端口号:111nfs主程序端口号:2049,客户端也可以执行此命令

root@ubuntu:~# rpcinfo -p 192.168.6.240
    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
    100005    1   udp  51536  mountd
    100005    1   tcp  38605  mountd
    100005    2   udp  36598  mountd
    100005    2   tcp  51885  mountd
    100005    3   udp  46768  mountd
    100005    3   tcp  43378  mountd
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100227    3   tcp   2049
    100003    3   udp   2049  nfs
    100003    4   udp   2049  nfs
    100227    3   udp   2049
    100021    1   udp  58186  nlockmgr
    100021    3   udp  58186  nlockmgr
    100021    4   udp  58186  nlockmgr
    100021    1   tcp  46484  nlockmgr
    100021    3   tcp  46484  nlockmgr
    100021    4   tcp  46484  nlockmgr

客户端
客户端也需要安装软件,但是不需要启动服务
[root@localhost ~]# yum -y install rpcbind nfs-utils
查看服务端共享的路径(服务端也可以执行此命令)
root@ubuntu:~# showmount -e 192.168.6.240
Export list for 192.168.6.240:
/nfs 192.168.6.0/24
挂载服务端目录到本地
root@ubuntu:~# mount 192.168.6.240:/nfs /root/shou
root@ubuntu:~# df -h |grep 192.168.6.240
192.168.6.240:/nfs 184G 5.4G 169G 4% /root/shou

排查错误:
示例1:卸载挂载设备时显示device is busy。
[root@nfs-client mnt]# umount /mnt
umount.nfs: /mnt: device is busy
umount.nfs: /mnt: device is busy
解答:有可能是当前目录就是挂载的NFS目录(/mnt),也有可能是NFS Server挂了。对于第一种情况,解决办法为退出挂载目录/mnt,再执行umount /mnt卸载。对于第二种情况,NFS Server挂了,NFS Client就会出现问题(df -h窗口会死掉),这时只能强制卸载,方法为:
umount -lf /mnt 其中的参数-f为强制卸载,参数-l为懒惰的卸载。

示例2:CentOS 6.6客户端NFS挂载时遇到问题。
[root@nfs-client ~]# mount -t nfs 172.16.1.9:/data /mnt
mount:wrong fs type,bad option,bad option,bad superblock on 10.0.0.7:/data,
missing codepage or helper program,or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount.<type> helper program )
In some cases useful info is found in syslog - try
meg | tail or so
排查思路:同样的机器,NFS服务器本地可以挂载,但是客户端挂载时wrong fs type,因此尝试所有客户端安装nfs-utils。CentOS6.5及以前的NFS没有遇到这个问题。
解决方法:执行yum install nfs-utils -y,客户端安装NFS软件,但不启动服务。

nfs

标签:端口号   ubuntu   当前目录   centos   app   解决办法   映射   some   data   

原文地址:https://blog.51cto.com/7469027/2547202

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!