linuxnfsrpcbindportmap基本配置及错误处理方法

更新时间:2023-06-23 09:08:40 阅读: 评论:0

linuxnfsrpcbindportmap基本配置及错误处理⽅法
CentOS Linux安装NFS服务器
NFS是Network File System,基于RPC(Remote Procedure Call Protocol远程过程调⽤协议)实现。NFS是TCP/IP协议集所提供的⼀种⼦协议,该协议可以实现LINUX/UNIX主机之间的⽂件共享,磁盘空间共享。它只⽤于Linux和Unix内核的操作系统进⾏共享。使⽤NFS ⽹络⽂件系统,可以将服务器的硬盘挂载到本地,就像操作本地计算机的硬盘⼀样。
这⾥⽤的系统是CentOS6.4,假设NFS Server IP为192.168.1.2,NFS Clinet IP为192.168.0.100。
1.服务端安装NFS:
yum install nfs-utils protmap
nfs-utils包提供了NFS服务器程序和相应的管理⼯具。
freeze是什么意思
protmap是⼀个管理RPC连接的程序,portmap服务对NFS是必须的,因为它是NFS的动态端⼝分配守护进程,如果portmap不启
动,NFS就是启动不了的。
2.配置NFS服务端,编辑/etc/exports⽂件:
vim /etc/exports
cnn是什么意思设置共享⽂件⽬录,如加⼊:
/home/nfsdir *(rw)
汉译英在线/home/share 192.168.0.100(rw,no_root_squash) *(ro)
/home/nfsdir *(rw)
表⽰共享/home/nfsdir⽬录,所有⽤户都有读写权限。
/home/share 192.168.0.100(rw,no_root_squash) *(ro)
表⽰共享/home/share⽬录,192.168.0.100有读写权限并且root⽤户有完全管理访问权限,其他机器仅有只读权限。
配置⽂件的格式为:
[共享的⽬录] [主机名或IP(参数,参数)]
其中参数是可选的,当不指定参数时,nfs将使⽤默认选项。默认的共享选项是sync,ro,root_squash,no_delay。
当主机名或IP地址为空时,则代表共享给任意客户机提供服务。
gotta get that当将同⼀⽬录共享给多个客户机,但对每个客户机提供的权限不同时,可以这样:
[共享的⽬录] [主机名1或IP1(参数1,参数2)] [主机名2或IP2(参数3,参数4)]
下⾯是⼀些NFS共享的常⽤参数:
ro  只读访问
rw  读写访问
sync  同步写⼊资料到内存与硬盘中
async  资料会先暂存于内存中,⽽⾮直接写⼊硬盘
cure  NFS通过1024以下的安全TCP/IP端⼝发送
oleincure  NFS通过1024以上的端⼝发送
wdelay  如果多个⽤户要写⼊NFS⽬录,则归组写⼊(默认)
no_wdelay  如果多个⽤户要写⼊NFS⽬录,则⽴即写⼊,当使⽤async时,⽆需此设置。
hide  在NFS共享⽬录中不共享其⼦⽬录
no_hide  共享NFS⽬录的⼦⽬录
subtree_check  如果共享/usr/bin之类的⼦⽬录时,强制NFS检查⽗⽬录的权限(默认)
no_subtree_check  和上⾯相对,不检查⽗⽬录权限
all_squash  共享⽂件的UID和GID映射匿名⽤户anonymous,适合公⽤⽬录。
no_all_squash  保留共享⽂件的UID和GID(默认)
root_squash  root⽤户的所有请求映射成如anonymous⽤户⼀样的权限(默认)
no_root_squash  root⽤户具有根⽬录的完全管理访问权限
anonuid=xxx  指定NFS服务器/etc/passwd⽂件中匿名⽤户的UID
anongid=xxx  指定NFS服务器/etc/passwd⽂件中匿名⽤户的GID
当exports⽂件修改后,使⽤以下命令,不需要重启NFS服务,就可以重新挂载/etc/exports⾥⾯的设定: exportfs -arv
3.先启动portmap服务:
rvice portmap restart
4.再启动NFS服务:
rvice nfs restart
如果之前没有先启动portmap服务,那么当启动NFS服务时会停在
Starting NFS daemon:
很长时间。
5.设置nfs、portmap开机⾃启动:
chkconfig --level 345 nfs on
chkconfig --level 345 portmap on
6.客户端也需要安装nfs-utils、portmap软件包,并启动portmap服务:
yum install nfs-utils portmap
rvice portmap restart
chkconfig --level 345 on
7.NFS服务端启动成功后,客户端可以利⽤showmount命令测试是否能连上服务端:
命令格式:showmount -e [hostname|IP],showmount命令需要安装了nfs-utils软件包才有。 showmount -e 192.168.1.2
显⽰如下:
/home/nfsdir *
/home/share (everyone)
8.客户端建⽴挂载的⽂件夹:
cd /mnt
mkdir nfs1
mkdir nfs2
9.客户端使⽤mount命令挂载NFS共享⽂件:
mount -t nfs 192.168.1.2:/home/nfsdir /mnt/nfs1
mount -t nfs 192.168.1.2:/home/share /mnt/nfs2
命令格式:mount - t nfs nfs服务器地址:⽬录共享 本地挂载⽬录点
10.客户端可使⽤df命令,mount命令查看挂载情况:
mount
192.168.1.2:/home/share on /mnt/nfs2 type nfs (rw,addr=192.168.1.2)
192.168.1.2:/home/nfsdir on /mnt/nfs1 type nfs (rw,addr=192.168.1.2)
11.客户端卸载NFS⽂件命令:
umount /mnt/nfs1
umount /mnt/nfs2
12.客户端可以设置系统启动时⾃动挂载NFS⽂件:
需要将NFS的共享⽬录挂载信息写⼊/etc/fstab/⽂件,以实现对NFS共享⽬录的⾃动挂载。
编辑/etc/fstab⽂件:
vim /etc/fstab
在最后加⼊如
192.168.1.2:/home/nfsdir /mnt/nfsdir nfs defaults 0 0出国留学流程
13.查看当前主机RPC状态:
rpcinfo -p localhost
⼀个很纠结的错误
使⽤ mount -t nfs 127.0.0.1:/home/lzgonline/rootfs /mnt 和 mount -t nfs 192.168.1.9:/home/lzgonline/rootfs /mnt 本机挂载nfs则没有问题,然⽽使⽤ mount -t nfs 192.168.3.12:/home/lzgonline/rootfs /mnt 时却出现了问题,导致开发板⽆法通过nfs挂载启动,其中192.128.3.12 和 192.128.1.9(即nfs服务器)之间建⽴了映射(DMZ)关系。
mount.nfs: access denied by rver while mounting 192.168.3.12:/home/lzgonline/rootfs
百度、⾕歌了很久,⼤部分都说是权限设置有问题,其实⽂件夹权限都设为777了,权限上都没问题,hosts.deny和hosts.allow都保留默认设置,防⽕墙也关了,该设置的都设置了,但还是被拒绝,很是郁闷,就在⼀筹莫展的时候,通过查看⼀些linux技术论坛后逐渐找到了问题所在。
⾸先使⽤命令查看出错⽇志⽂件
[root@lzgonline init.d]# cat /var/log/messages | grep mount
Jun 29 00:49:04 lzgonline mountd[1644]: refud mount request from 192.168.3.12 for /home/lzgonline/rootfs
(/home/lzgonline/rootfs): illegal port 1689
Jun 29 00:51:02 lzgonline mountd[1644]: refud mount request from 192.168.3.12 for /home/lzgonline/rootfs
(/home/lzgonline/rootfs): illegal port 1710
Jun 29 01:02:17 lzgonline mountd[1644]: refud mount request from 192.168.3.12 for /home/lzgonline/rootfs
(/home/lzgonline/rootfs): illegal port 1916
Jun 29 01:09:51 lzgonline mountd[1644]: refud mount request from 192.168.3.12 for /home/lzgonline/rootfs
linux开发培训(/home/lzgonline/rootfs): illegal port 2157
red rainJun 29 01:17:02 lzgonline mountd[1644]: refud mount request from 192.168.3.12 for /home/lzgonline/rootfs
(/home/lzgonline/rootfs): illegal port 2318
从出错⽇志可以看出,mount.nfs: access denied by rver while mounting 192.168.3.12:/home/lzgonline/rootfs 被拒绝的原因是因为使⽤了⾮法端⼝,功夫总没⽩费,终于在⼀个linux技术论坛上找到了答案:
I googled and found that since the port is over 1024 I needed to add the "incure" option to the relevant line in
/etc/exports on the rver. Once I did that (and ran exportfs -r), the mount -a on the client worked.
waybill//如果端⼝号⼤于1024,则需要将 incure 选项加⼊到配置⽂件(/etc/exports)相关选项中mount客户端才能正常⼯作:
查看 exports ⼿册中关于 cure 选项说明也发现确实如此
[root@lzgonline init.d]# man exports
cure,This  option requires that requests originate on an Internet port less than IPPORT_RESERVED (1024). This option is on by default. To turn it off, specify incure.
//cure 选项要求mount客户端请求源端⼝⼩于1024(然⽽在使⽤ NAT ⽹络地址转换时端⼝⼀般总是⼤于1024的),默认情况下是开启这个选项的,如果要禁⽌这个选项,则使⽤ incure 标识
修改配置⽂件/etc/exports,加⼊ incure 选项
/home/lzgonline/rootfs  *(incure,rw,async,no_root_squash)西域男孩最好听的歌
保存退出
然后重启nfs服务:rvice nfs restart
然后问题就解决了
笔者⽤的Linuxf发⾏版本为Centos6.4,以下⽅法理论上讲对于Fedora, Red Hat均有效:
搭建好NFS服务后,如果⽤以下的命令进⾏挂载:
# mount -t nfs 172.16.12.140:/home/liangwode/test  /mnt
出现如下错误提⽰:
mount.nfs: access denied by rver while mounting 172.16.12.140:/home/liangwode/test
那我们可以⽤以下的⽅法进⾏解决:
修改/etc/sysconfig/nfs⽂件,将
# Turn off v2 and v3 protocol support
#  RPCNFSDARGS="-N 2 -N 3"
# Turn off v4 protocol support
#RPCNFSDARGS="-N 4"    /*把这句话的#号去掉*/
NFS分为三个版本,即NFS-2 NFS-3 NFS-4,该配置⽂件默认关闭了这三个的NFS版本,我们只需要打开NFS-4即可。
在⼀些系统中,NFS服务是关闭状态的,为了启动这项功能,我们需要⼿动进⾏设置。那么对于NFS Server和NFS Client的设置我们在⽂章中来为⼤家详细介绍⼀下。希望能够让⼤家掌握这部分知识。
服务端(Solaris 9):
⼀.NFS Server设置:

本文发布于:2023-06-23 09:08:40,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/90/154684.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:共享   权限   命令   服务   选项
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图