nfs 是Network File System 網路檔案系統

來源:互聯網
上載者:User

標籤:bin   style   for   使用者   service   狀態   export   bsp   exports   

 

NFS的基本原剛是容許不同的用戶端及服務通過一組PRC分享相同的檔案系統,它是獨立於作業系統,容許不同硬體及作業系統的系統共同進行檔案的分享。NFS在檔案傳送過程中依賴於RPC協議。遠端程序呼叫Remote Procedure Call是能使用戶端執行其他系統中程式的一種機制。NFS本身是沒有提供資訊傳輸的協議和功能的,但NFS卻能讓我們通過網路時行資料分享,這是因為NFS使用了一些其它的傳輸協議。而這些傳輸協議用到這個RPC功能。可以說NFS本身就是便用RPC的一個程式。或者說NFS也是一個RPC SERVER。所以只要用到NFS的地方都要啟動RPC服務,不論是NFS SERVER或者NFS CLIENT。這樣SERVER和CLIENT才能通過RPC來實現 PROGRAM PORT的對應。可以這麼理解RPC和NFS的關係:NFS是一個檔案系統,而RPC是負責資訊的傳輸。

服務端:

yum install -y rpcbind nfs-utils
# /etc/init.d/nfs startStarting NFS services:                                     [  OK  ]Starting NFS quotas:                                       [  OK  ]Starting NFS mountd:                                       [  OK  ]Starting NFS daemon:                                       [  OK  ]Starting RPC idmapd:                                       [  OK  ]
# cat /etc/exports /data *(rw)

上面框內容是要分享的目錄

查看NFS服務狀態:

# /etc/init.d/nfs statusrpc.svcgssd is stoppedrpc.mountd (pid 29497) is running...nfsd (pid 29513 29512 29511 29510 29509 29508 29507 29506) is running...rpc.rquotad (pid 29492) is running...
[[email protected] Downloads]# /etc/init.d/rpcbind statusrpcbind (pid  2608) is running...

設定NFS服務在系統運行層級2和5自動啟動

[[email protected] Downloads]# chkconfig --level 35 nfs on[[email protected] Downloads]# chkconfig|grep nfsnfs                0:off    1:off    2:off    3:on    4:off    5:on    6:offnfs-rdma           0:off    1:off    2:off    3:off    4:off    5:off    6:offnfslock            0:off    1:off    2:off    3:on    4:on    5:on    6:off

如果改變/etc/exports一定要重啟nfs服務

伺服器端使用showmount命令查詢nfs的共用狀態

[[email protected] Downloads]# showmount -eclnt_create: RPC: Unknown host[[email protected] Downloads]# showmount -e localhostExport list for localhost:/data *

預設查看自己共用的服務,前提是要DNS能解自己,不然會報錯!!!如上面的內容

[[email protected] ~]# mount -t nfs 192.168.1.3:/data /data_nfs/[[email protected] ~]# df -hFilesystem            Size  Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root                       38G  2.2G   34G   6% /tmpfs                 939M     0  939M   0% /dev/shm/dev/vda1             477M   38M  414M   9% /boot192.168.1.3:/data     459G  127G  310G  29% /data_nfs

用戶端使用showmount 命令查詢NFS的共用狀態:

[[email protected] ~]# showmount -e 192.168.1.3Export list for 192.168.1.3:/data *

許可權問題,用戶端發生下面情況:

[[email protected] data_nfs]# touch ktouch: cannot touch `k‘: Permission denied

無許可權!!!!

是因為NFS 伺服器端共用的目錄本身的寫入權限沒有開放給其他使用者,在伺服器端開啟該許可權。

開放許可權

[[email protected] /]# chmod -R 777 data/# 還不行
[[email protected] /]# chmod -R 755 /data/[[email protected] /]# cat /etc/exports /data *(rw,sync,all_squash,no_subtree_check)[[email protected] /]# exportfs -rvexporting *:/data

問題解決!!!

 

nfs 是Network File System 網路檔案系統

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.