【SuSe11.1 上架设NFS服务器】

2019-07-12 22:07发布

分类: 嵌入式Linux 1924人阅读 评论(0) 收藏 举报
SuSe11.1 上架设NFS服务器
Sailor_forever  sailing_9806@163.com 转载请注明
http://blog.csdn.net/sailor_8318/archive/2009/11/14/4809475.aspx  
1、检查是否安装NFS必备的portmap和nfs server及client
cnbjc0052:~ # rpm -qa | grep portmap
portmap-5beta-749.15
cnbjc0052:~ # rpm -qa | grep nfs
yast2-nfs-client-2.13.4-0.11
limal-nfs-server-1.1.72-0.3
yast2-nfs-server-2.13.10-0.3
limal-nfs-server-perl-1.1.72-0.3
nfsidmap-0.12-16.17
nfs-utils-1.0.7-36.29

2、设置共享目录
cnbjc0052:~ # vi /etc/exports
/home/sailing/eldk_tool/ppc_82xx *(rw,sync,no_root_squash)

3、重启相关服务
cnbjc0052:/home/sailing/eldk_tool/ppc_82xx # service portmap start
Starting RPC portmap daemon                                          done
cnbjc0052:/home/sailing/eldk_tool/ppc_82xx # service nfs start
Importing Net File System (NFS)                                      unused

cnbjc0052:/home/sailing/eldk_tool/ppc_82xx # exportfs -rv
exporting *:/home/sailing/eldk_tool/ppc_6xx

4、查看NFS共享是否成功
cnbjc0052:/home/sailing/eldk_tool/ppc_82xx # showmount -e
mount clntudp_create: RPC: Program not registered
貌似有问题

5、在主机上验证NFS server功能
cnbjc0052:~ # mkdir /mnt/nfs
cnbjc0052:~ # chmod -R 777 /mnt/nfs
cnbjc0052:~ # mount -t nfs 150.236.70.120:/home/sailing/eldk_tool/ppc_82xx /mnt/nfs
mount server reported tcp not available, falling back to udp
mount: RPC: Program not registered
失败,原因不明

6、关闭防火墙并查看个端口信息
cnbjc0052:~ # iptables -A INPUT -p TCP --dport 111 -j ACCEPT
cnbjc0052:~ # iptables -A INPUT -p UDP --dport 111 -j ACCEPT
cnbjc0052:~ # rpcinfo -p 127.0.0.1
   program vers proto   port
    100000    2   tcp    111  rpcbind
    100000    2   udp    111  rpcbind
    100007    2   udp    872  ypbind
    100007    1   udp    872  ypbind
    100007    2   tcp    873  ypbind
    100007    1   tcp    873  ypbind
    100004    2   udp    911  ypserv
    100004    2   tcp    912  ypserv
    100024    1   udp  33762  status
    100021    1   udp  33762  nlockmgr
    100021    3   udp  33762  nlockmgr
    100021    4   udp  33762  nlockmgr
    100024    1   tcp  46628  status
    100021    1   tcp  46628  nlockmgr
    100021    3   tcp  46628  nlockmgr
100021    4   tcp  46628  nlockmgr
Rpcinfo 没看到NFS相关的服务呢??估计是server架设有问题

7、经检查确认Suse 的NFS server的启动比较特别
cnbjc0052:~ # /etc/init.d/nfs start
Importing Net File System (NFS)                                      unused

cnbjc0052:~ # /etc/init.d/nfsserver start
Starting kernel based NFS server                                     done

etc/init.d/nfsserver start才是Suse上的NFS启动方式,和传统的Redhat或fedora不太相同

cnbjc0052:~ # rpcinfo   -p
   program vers proto   port
    100000    2   tcp    111  rpcbind
    100000    2   udp    111  rpcbind
    100007    2   udp    872  ypbind
    100007    1   udp    872  ypbind
    100007    2   tcp    873  ypbind
    100007    1   tcp    873  ypbind
    100004    2   udp    911  ypserv
    100004    2   tcp    912  ypserv
    100024    1   udp  33762  status
    100021    1   udp  33762  nlockmgr
    100021    3   udp  33762  nlockmgr
    100021    4   udp  33762  nlockmgr
    100024    1   tcp  46628  status
    100021    1   tcp  46628  nlockmgr
    100021    3   tcp  46628  nlockmgr
    100021    4   tcp  46628  nlockmgr
    100003    2   udp   2049  nfs
    100003    3   udp   2049  nfs
    100003    4   udp   2049  nfs
    100003    2   tcp   2049  nfs
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100005    1   udp    681  mountd
    100005    1   tcp    685  mountd
    100005    2   udp    681  mountd
    100005    2   tcp    685  mountd
    100005    3   udp    681  mountd
100005    3   tcp    685  mountd
由列表可知,NFS相关的服务已经成功启动

8、再次检查共享是否成功
cnbjc0052:~ # showmount -e
Export list for cnbjc0052:
/home/sailing/eldk_tool/ppc_6xx *
cnbjc0052:~ # showmount -a
All mount points on cnbjc0052:

cnbjc0052:~ # mount -t nfs 150.236.70.120:/home/sailing/eldk_tool/ppc_82xx /mnt/nfs
mount: 150.236.70.120:/home/sailing/eldk_tool/ppc_82xx failed, reason given by server: Permission denied
cnbjc0052:/home/sailing/eldk_tool # id
uid=0(root) gid=0(root) groups=0(root)
权限不符合,当前用户已经是root了啊,那可能是文件的权限不够

cnbjc0052:/home/sailing/eldk_tool # chmod -R 777 /home/sailing/eldk_tool/ppc_82xx
chmod: changing permissions of `/home/sailing/eldk_tool/ppc_82xx/usr/src/linux-2.6.24/drivers/char/hw_random/amd-rng.c': Operation not permitted
root不能更改普通用户的资源权限

cnbjc0052 sailing/eldk_tool> mount -t nfs 150.236.70.120:/home/sailing/eldk_tool/ppc_82xx /mnt/nfs
mount: only root can do that
普通用户无法mount

cnbjc0052 sailing/eldk_tool> chmod -R 777 ppc_82xx
将待共享的目录权限设置最大

cnbjc0052 sailing/eldk_tool> su
Password:
cnbjc0052:/home/sailing/eldk_tool # id
uid=0(root) gid=0(root) groups=0(root)
cnbjc0052:/home/sailing/eldk_tool #  mount -t nfs 150.236.70.120:/home/sailing/eldk_tool/ppc_82xx /mnt/nfs
mount: 150.236.70.120:/home/sailing/eldk_tool/ppc_82xx failed, reason given by server: Permission denied

为什么还是不行呢,莫非是root用户无法挂载普通用户目录下的资源??

建立新的公共目录,非普通用户home目录下,测试成功
cnbjc0052:/ # chmod -R 777 /opt/
cnbjc0052:/ # vi /etc/exports
cnbjc0052:/ # exportfs -rv
exporting *:/home/sailing/eldk_tool/ppc_6xx
exporting *:/opt
cnbjc0052:/ # service portmap start
Starting RPC portmap daemon                                          done
cnbjc0052:/ # /etc/init.d/nfsserver start
Starting kernel based NFS server                                                                     done
cnbjc0052:/ # vi /etc/exports
cnbjc0052:/ # showmount -e
Export list for cnbjc0052:
/opt                            *
/home/sailing/eldk_tool/ppc_6xx *
cnbjc0052:/ # mount -t nfs 150.236.70.120:/opt /mnt/nfs
cnbjc0052:/ # showmount -a
All mount points on cnbjc0052:
*:/home/sailing/eldk_tool/ppc_6xx
*:/opt
150.236.70.120:*

cnbjc0052:/ # showmount -a
All mount points on cnbjc0052:
*:/home/sailing/eldk_tool/ppc_6xx
*:/opt
150.236.236.173:*
150.236.70.120:*