-
centos7.6下搭建NFS共享并挂载到windows客户端-网络错误53解决方法
2020-02-20 19:43:111、安装nfs软件 yum install -y nfs-utils rpcbind 2、编辑配置文加件添配置需要共享的目录 vim /etc/exports /data/mysqlDIR *(rw,no_root_squash,no_all_squash,sync) 3、创建要共享的目录 mkdir /data/...一、NFS概述
二、NFS服务的搭建步骤
1、NFS概述
NFS 是Network File System的缩写,即网络文件系统。一种使用于分散式文件系统的协定,由Sun公司开发,于1984年向外公布。功能是通过网络让不同的机器、不同的操作系统能够彼此分享个别的数据,让应用程序在客户端通过网络访问位于服务器磁盘中的数据,是在类Unix系统间实现磁盘文件共享的一种方法。
NFS在文件传送或信息传送过程中依赖于RPC协议,RPC远程过程调用 (Remote Procedure Call) 是能使客户端执行其他系统中程序的一种机制,NFS本身是没有提供信息传输的协议和功能的。
NFS应用场景
常用于高可用文件共享,多台服务器共享同样的数据,可扩展性比较差,本身高可用方案不完善,取而代之的数据量比较大的可以采用MFS、TFS、HDFS、GFS等等分布式文件系统。
NFS(网络文件系统):让网络上的不同linux/unix系统机器实现文件共享
nfs本身只是一种文件系统,没有提供文件传递的功能,但却能让我们进行文件的共享,原因在于 NFS 使用RPC服务,用到NFS的地方都需要启动RPC服务,无论是NFS客户端还是服务端
nfs和rpc的关系:nfs是一个文件系统,负责管理分享的目录;rpc负责文件的传递
nfs启动时至少有rpc.nfsd和rpc.mountd2个daemon
rpc.nfsd主要是管理客户机登陆nfs服务器时,判断该客户机是否能登陆,和客户机ID信息。
Rpc.mountd主要是管理nfs的文件系统。当客户机顺利登录nfs服务器时,会去读/etc/exports文件中的配置,然后去对比客户机的权限。
协议端口:
RPC:111 tcp/udp
nfsd: 2049 tcp/udp
mountd:RPC服务在 nfs服务启动时默认会为 mountd动态选取一个随机端口(32768–65535)来进行通讯 ,可以在/etc/nfsmount.conf文件中指定mountd的端口二、NFS服务端搭建步骤
1、安装nfs软件
yum install -y nfs-utils rpcbind
2、编辑配置文加件添配置需要共享的目录
vim /etc/exports /data/mysqlDIR *(rw,no_root_squash,no_all_squash,sync)
3、创建要共享的目录
mkdir /data/mysqlDIR
4、使配置文件生效,如果目录不存在就会报错,创建目录后再执行一下就好
[root@images1-linux ~]# exportfs -r exportfs: Failed to stat /data/mysqlDIR: No such file or directory
5、启动nfs和rpcbind服务并查看端口情况
systemctl start nfs && systemctl start rpcbind ss -ntl
NFS server启动时会随机启动多个端口并向RPC注册,这样如果使用iptables对NFS sever 端口进行限制就会有点麻烦,可以更改配置文件固定NFS服务相关端口
先看一下目前所使用的的端口情况rpcinfo -p localhost
6、把这些端口修改成指定的端口,编辑配置文件:# 在配置文件中添加以下5行内容,其他的保持不动 # vim /etc/sysconfig/nfs RQUOTAD_PORT=30001 LOCKD_TCPPORT=30002 LOCKD_UDPPORT=30002 MOUNTD_PORT=30003 STATD_PORT=30004
7、重启nfs和rpcbind服务
systemctl restart nfs && systemctl restart rpcbind
再次查看端口情况就会发现有的随机端口已经变成我们指定的端口了
查看共享目录信息[root@NFS-Server ~]# exportfs -rv exporting *:/data/mysqlDIR [root@NFS-Server ~]# exportfs -v /data/mysqlDIR <world>(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)
8、如果是云主机或开了防火墙等,需要开启指定端口,111,2049,…等,我这里是把防火墙禁用了
9、linux客户端查看共享目录信息并挂载到本地
# 客户端也要安装nfs工具: yum install -y nfs-utils # 查看服务端共享的文件目录等 showmount -e + nfs服务端IP # 挂载方法:mount -t 指定协议 IP:/共享目录位置 + 挂载点 mount -t nfs X.X.X.X:/data/mysqlDIR /mnt # 卸载共享目录 umount + 挂载点
10、在windows客户端挂载
① 打开-控制面板-程序-打开或关闭windows功能-勾选NFS客户端
② 打开dos命令行进行挂载挂载方法: mount IP:/共享目录位置 + 挂载点 卸载方法: umount + 挂载点
卸载挂载点
出错故障排除思路:
① 检查共享目录的配置文件,权限、目录等
② 是否开启了防火墙,如开启了请添加规则放行相应的端口号
③ 如果是云主机,要检查安全组里的规则是否放行端口等
④ 尽量在配置文件中定义使用固定的端口号,便于添加规则
⑤ 错误如下图(原因是windows端经常会使用大的端口号导致的)错误截图:
linux客户端端和windows客户端挂载目录时可能遇到的错误:
① linux客户端挂载不上,提示访问拒绝错误
② windows端常出现的问题:提示网络错误-53
网络错误-53的解决方法:
NFS服务器有一个”在非安全模式工作(允许更高的端口号)“的选项。Windows NFS客户端经常使用的是大的端口号。你可以在你的共享项设置中添加insecure选项
例如:/data/xxx *(insecure,rw)
重启服务再次挂载就可以了 -
Windows通过nfs挂载Linux目录并创建oracle逻辑目录(网络错误 - 122、- 53、 - 5等问题的解决)
2020-12-02 11:01:36NFS配置以及管理 NFS服务所需软件及主要配置文件: 安装NFS服务,需要安装两个软件,分别是: • RPC主程序:rpcbind NFS 其实可以被视为一个 RPC 服务,因为启动任何一个 RPC 服务之前,我们都需要做好 port 的对应...NFS配置以及管理
NFS服务所需软件及主要配置文件:
安装NFS服务,需要安装两个软件,分别是:
• RPC主程序:rpcbind
NFS 其实可以被视为一个 RPC 服务,因为启动任何一个 RPC 服务之前,我们都需要做好 port 的对应 (mapping) 的工作才行,这个工作其实就是『 rpcbind 』这个服务所负责的!也就是说, 在启动任何一个 RPC 服务之前,我们都需要启动 rpcbind 才行! (在 CentOS 5.x 以前这个软件称为 portmap,在 CentOS 6.x 之后才称为 rpcbind 的!)。
• NFS主程序:nfs-utils
就是提供 rpc.nfsd 及 rpc.mountd 这两个 NFS daemons 与其他相关 documents 与说明文件、执行文件等的软件!这个就是 NFS 服务所需要的主要软件。文章目录
NFS服务配置(windows->linux)
检查服务程序是否存在:
[root@localhost /]# rpm -q nfs-utils rpcbind nfs-utils-1.3.0-0.el7.x86_64 rpcbind-0.2.0-23.el7.x86_64 [root@localhost /]# ^C
正确启动顺序应该是先启动rpcbind,再启动NFS:
[root@localhost /]# service rpcbind start Redirecting to /bin/systemctl start rpcbind.service [root@localhost /]# service nfs start Redirecting to /bin/systemctl start nfs.service [root@localhost /]#
查看nfs运行状态:
[root@localhost /]# service nfs status Redirecting to /bin/systemctl status nfs.service nfs-server.service - NFS Server Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled) Active: active (exited) since 五 2020-09-18 09:49:36 CST; 45s ago Process: 10692 ExecStopPost=/usr/sbin/exportfs -f (code=exited, status=0/SUCCESS) Process: 10691 ExecStop=/usr/sbin/rpc.nfsd 0 (code=exited, status=0/SUCCESS) Process: 10704 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS $RPCNFSDCOUNT (code=exited, status=0/SUCCESS) Process: 10700 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS) Process: 10697 ExecStartPre=/usr/libexec/nfs-utils/scripts/nfs-server.preconfig (code=exited, status=0/SUCCESS) Main PID: 10704 (code=exited, status=0/SUCCESS) CGroup: /system.slice/nfs-server.service 9月 18 09:49:36 localhost.localdomain systemd[1]: Starting NFS Server... 9月 18 09:49:36 localhost.localdomain systemd[1]: Started NFS Server.
设置开机自启以及防火墙放行:
[root@localhost init.d]# systemctl enable rpcbind [root@localhost init.d]# systemctl start nfs-server nfs-secure-server Job for nfs-secure-server.service failed. See 'systemctl status nfs-secure-server.service' and 'journalctl -xn' for details. [root@localhost init.d]# systemctl enable nfs-server nfs-secure-server ln -s '/usr/lib/systemd/system/nfs-server.service' '/etc/systemd/system/nfs.target.wants/nfs-server.service' ln -s '/usr/lib/systemd/system/nfs-secure-server.service' '/etc/systemd/system/nfs.target.wants/nfs-secure-server.service' [root@localhost init.d]# firewall-cmd --permanent --add-service=nfs success [root@localhost init.d]# firewall-cmd --reload success [root@localhost init.d]#
配置共享文件目录,编辑配置文件:
[root@localhost /]# mkdir /public [root@localhost etc]# vi /etc/exports /public 192.168.221.0/24(rw) [root@localhost etc]# systemctl reload nfs
windows的NFS客户端配置:
windows2008x64上操作:【添加角色:文件服务器,勾选网络文件系统服务】才有mount命令!
(以上网络错误 – 53 为防火墙问题)挂载命令:month \192.168.221.138\public x:
取消挂载命令:umount x:关闭防火墙命令:systemctl stop firewalld
NFS目录赋权:chmod -R 777 /publicoracle创建nfs共享的逻辑目录:
SQL> create or replace directory dmp as '\\10.62.232.246\oradata\dmp'; 目录已创建。 SQL> grant read,write on directory dmp to SYSTEM;
附:网络错误 - 122、- 5:
需要注意hosts.allow、hosts.deny文件限制情况:
1、为 /etc/hosts.allow文件添加"ALL: ALL"
2、为 /etc/hosts.deny文件注释行:“ALL:ALL” -
阿里云服务器映射到本地磁盘
2016-04-02 23:37:44先给我的阿里云主机(ubuntu 12.04 LTS) 装上nfs ...windows执行挂载: C:\Users\hexing.hexing-PC>mount \\120.24.210.XXX\tmp Y: -o nolock 网络错误 - 53 有关详细信息,请键入“N先给我的阿里云主机(ubuntu 12.04 LTS) 装上nfs
添加新行 /etc/export :
/opt/test *(rw,sync)
windows执行挂载:
C:\Users\hexing.hexing-PC>mount \\120.24.210.XXX\tmp Y: -o nolock
网络错误 - 53
有关详细信息,请键入“NET HELPMSG 53”。查看主机日志 cat /var/log/syslog:
Apr 2 23:23:34 iZ94tzmkw47Z rpc.mountd[508]: refused mount request from 223.73.34.152 for /tmp (/tmp): illegal port 41733
Apr 2 23:23:53 iZ94tzmkw47Z rpc.mountd[508]: refused mount request from 223.73.34.152 for /tmp (/tmp): illegal port 41294
Apr 2 23:24:09 iZ94tzmkw47Z rpc.mountd[508]: can't get hostname of 223.73.34.152
Apr 2 23:24:09 iZ94tzmkw47Z rpc.mountd[508]: can't get hostname of 223.73.34.152放狗一搜,把 /etc/exports 变更为这样:
/home/packman/ *(ro,no_subtree_check,insecure,sync)
然后成功了:
C:\Users\hexing.hexing-PC>mount \\120.24.210.173\tmp Y: -o nolock
Y: 现已成功连接到 \\120.24.210.173\tmp
命令已成功完成。参考: http://www.cnblogs.com/xmnn1990/p/4760091.html
linux嵌入式开发新方法:阿里云+arm开发板
-
这一点貌似在 Linux 和 Mac OS X 下不用操心,在 Windows 下有可能遇到需要安装驱动的情况,确认这一点可以右键「计算机」-「属性」,到「设备管理器」里查看相关设备上是否有黄色感叹号或问号,如果没有就说明驱动...