nfs的一個報錯:mount.nfs: Input/output error

來源:互聯網
上載者:User
mount.nfs: Input/output error

解決:在用戶端也需啟動portmap

順便貼一篇文章:
原貼:http://linux.chinaunix.net/bbs/archiver/?tid-905711.html2007-8-8 14:40 wzknet手把手教你Linux系統下快速設定NFS

[color=Blue]一、NFS服務端設定(NFS服務端IP:10.10.10.10/25)
作業系統版本:
[root@localhost /]# cat /etc/redhat-release
Red Hat Enterprise Linux AS release 4 (Nahant Update 4)

1、檢查portmap服務運行狀態(因為NFS及其輔助程式都是基於RPC的,所以我們要確保系統中首先運行portmap服務)
[root@localhost /]# id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) context=root:system_r:unconfined_t
[root@localhost /]# service portmap status
portmap is stopped
結果顯示portmap服務是停止的,可以通過以下命令啟動該服務:
[root@localhost /]# service portmap start
Starting portmap: [  OK  ]
[root@localhost /]# service portmap status
portmap (pid 11085) is running...
結果顯示portmap服務已處於“running”狀態。

2、檢查nfs服務運行狀態
[root@localhost /]# service nfs status
Shutting down NFS mountd: rpc.mountd is stopped
nfsd is stopped
rpc.rquotad is stopped
結果顯示nfs服務是停止的,可以通過以下命令啟動該服務:
[root@localhost /]# service nfs start
Starting NFS services:  [  OK  ]
Starting NFS quotas: [  OK  ]
Starting NFS daemon: [  OK  ]
Starting NFS mountd: [  OK  ]
此時來檢查一下nfs服務運行狀態,由下可知,nfs服務已啟用。
[root@localhost /]# service nfs status
Shutting down NFS mountd: rpc.mountd (pid 11155) is running...
nfsd (pid 11151 11148 11147 11146 11145 11144 11143 11142) is running...
rpc.rquotad (pid 11138) is running...

3、設定nfs服務在系統重啟後自動運行
[root@localhost /]# chkconfig --list nfs
nfs             0:off   1:off   2:off   3:off   4:off   5:off   6:off
[root@localhost /]# chkconfig nfs on
[root@localhost /]# chkconfig --list nfs
nfs             0:off   1:off   2:on    3:on    4:on    5:on    6:off

4、/etc/exports檔案設定
/etc/exports檔案格式:
共用的目錄 主機名稱1或IP1(參數1,參數2) 主機名稱2或IP2(參數3,參數4)
如果使用主機名稱,則必須預先在/etc/hosts檔案中定義。
exports主要參數:
rw:可讀寫權限
ro:唯讀許可權
no_root_squash:對於登陸NFS主機的共用目錄使用者如果是root的話則對該目錄具有root許可權。這樣做極
不安全,建議不用為好!
root_squash:對於登陸NFS主機的共用目錄使用者使用者如果是root則它的許可權將被壓縮成匿名使用者,同
時它的UID和GID都會變成nobody那個系統帳號的身份。
all_squash:不管登陸NFS主機使用者身份如何,它的身份都會被壓縮成匿名使用者,通常就是nobody
anonuid:anonuid=xxx,制定NFS伺服器/etc/passwd中匿名使用者的UID
anongid:anonuid=xxx,制定NFS伺服器/etc/passwd中匿名使用者的GID
sync:資料在請求時寫入共用
async:NFS在寫入資料前可響應請求
secure:NFS通過1024以下的安全連接埠發送
insecure:NFS通過1024以上連接埠發送
hide:不共用NFS目錄的子目錄
no_hide:共用NFS目錄的子目錄
例如在/etc/exports檔案中添加以下內容(紅色部分):
[root@localhost /]# cat /etc/exports
/study 10.10.10.12(rw,sync,no_root_squash)

5、輸出共用目錄
[root@localhost /]#  exportfs -a
查看是否成功輸出共用目錄:
[root@localhost /]# cat /etc/exports
/study 10.10.10.12(rw,sync,no_root_squash)

二、NFS用戶端設定(NFS用戶端IP:10.10.10.12/25)
[root@REDHATAS5 /]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5 (Tikanga)

1、檢查portmap運行狀態(因為NFS及其輔助程式都是基於RPC的,所以我們要確保系統中首先運行portmap服務)
[root@REDHATAS5 /]# service portmap status
portmap (pid 22742) is running...
如果portmap服務未啟,則在mount時會報錯:
[root@REDHATAS5 /]# mount -t nfs 10.10.10.10:/study /nfstest
mount.nfs: Input/output error

2、查看NFS服務端共用目錄
[root@REDHATAS5 /]# showmount -e 10.10.10.10
Export list for 10.10.10.10:
/study 10.10.10.12

3、掛載共用目錄
[root@REDHATAS5 /]# mount -t nfs 10.10.10.10:/study /nfstest

4、查看成功掛載的nfs目錄
[root@REDHATAS5 /]# df -h | grep /nfstest
10.10.10.10:/study  7.8G  6.8G  695M  91% /nfstest

5、測試共用目錄是否可讀寫
[root@REDHATAS5 nfstest]# ls -l
total 8
-rw-r--r-- 1 root root 21 Jun 24 13:13 nfs-server.txt
[root@REDHATAS5 nfstest]# touch nfs-client.txt
[root@REDHATAS5 nfstest]# ls -l
total 12
-rw-r--r-- 1 root root  0 Jun 24 13:13 nfs-client.txt
-rw-r--r-- 1 root root 21 Jun 24 13:13 nfs-server.txt
由上可知,表明可讀寫。[/color]

[[i] 本帖最後由 wzknet 於 2007-8-8 14:42 編輯 [/i]]

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.