使用nfs經驗談

jichengjie發表於2013-12-16

一、場景:

在Linux上操作命令:

host3:/opt/oracle # id
uid=0(root) gid=0(root) groups=0(root),64(pkcs11)
host3:/opt/oracle # mount -t nfs 192.168.1.73:/opt/oracle/backup    /opt/oracle/backup
mount server reported tcp not available, falling back to udp
mount: RPC:程式未註冊
host3:/opt/oracle #


二、分析步驟:

第1步:檢查對方伺服器是否做了連線限制

         登入到對方伺服器 , 檢視/etc/hosts.allow 和 /etc/hosts.deny 檔案.其中hosts.deny 是拒絕了其中對應IP的主機的連線,hosts.allow 是允許其中對應IP主機的連線。

[root@hua73 ~]# tail /etc/hosts.allow
#
# hosts.allow   This file describes the names of the hosts which are
#               allowed to use the local INET services, as decided
#               by the '/usr/sbin/tcpd' server.
#


[root@hua73 ~]# tail /etc/hosts.deny
#
# hosts.deny    This file describes the names of the hosts which are
#               *not* allowed to use the local INET services, as decided
#               by the '/usr/sbin/tcpd' server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow.  In particular
# you should know that NFS uses portmap!

從裡面內容可知,對方服務並未對他方主機的連線做任何限制。

第2步:是否是由相關服務未啟動導致:


檢查portmap服務、nfs服務。其中portmap服務是用來支援RPC連線,RPC被用於NFS以及NIS 等服務。

1、檢查portmap服務的狀態:
[root@hua73 ~]# service portmap status
portmap (pid 3285) is running...

     說明portmap服務正常啟動執行。

2、檢查nfs服務的狀態:

[root@hua73 ~]# service nfs status
rpc.mountd is stopped
nfsd is stopped
rpc.rquotad is stopped

      ——nfs服務未啟動。


三、解決方法:

1、啟動nfs服務:

[root@hua73 ~]# service nfs start
Starting NFS services:  [  OK  ]
Starting NFS quotas: [  OK  ]
Starting NFS daemon: [  OK  ]
Starting NFS mountd: [  OK  ]


2、重啟portmap服務:

[root@hua73 ~]#
[root@hua73 ~]# service portmap reload
Stopping portmap: [  OK  ]
Starting portmap: [  OK  ]
[root@hua73 ~]#

但執行命令還是不行:
host3:/opt/oracle # mount -t nfs 192.168.1.73:/opt/oracle/backup    /opt/oracle/backup
mount: 192.168.1.73:/opt/oracle/backup failed, reason given by server: Permission denied

最後在exports中增加一行才解決問題
[root@hua73 etc]# vi exports

/opt/oracle/backup  192.168.1.53(rw,root_squash,sync)
~
~
~
~
~
~
~
"exports" 1L, 53C written
[root@hua73 etc]# service iptables status
Firewall is stopped.
[root@hua73 etc]#
[root@hua73 etc]#
[root@hua73 etc]#
[root@hua73 etc]#
[root@hua73 etc]#
[root@hua73 etc]#
[root@hua73 etc]# servicd nfs  restart
-bash: servicd: command not found
[root@hua73 etc]# service nfs restart
Shutting down NFS mountd: [  OK  ]
Shutting down NFS daemon: [  OK  ]
Shutting down NFS quotas: [  OK  ]
Shutting down NFS services:  [FAILED]
Starting NFS services:  [  OK  ]
Starting NFS quotas: [  OK  ]
Starting NFS daemon: [  OK  ]
Starting NFS mountd: [  OK  ]
[root@hua73 etc]# cat exports
/opt/oracle/backup  192.168.1.53(rw,root_squash,sync)
[root@hua73 etc]# ls -l exports
-rw-r--r-- 1 root root 53 Dec 12 10:44 exports
[root@hua73 etc]# date
Thu Dec 12 10:55:27 CST 2013
[root@hua73 etc]#


 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26870952/viewspace-1063358/,如需轉載,請註明出處,否則將追究法律責任。