linux中centos下nfs伺服器的配置方法

來源:互聯網
上載者:User


NFS伺服端

portmap 111;NFS 2049
 
伺服端安裝

yum -y install nfs-kernel-server

啟用

service nfs-kernel-server restart設定檔


vi /etc/exports

<export/share point> <client list>
/usr    node*(rw,sync,no_root_squash)  /home   node*(rw,sync,no_root_squash)

常用的 NFS 選項:

•ro, rw:指定此分享可否寫 入。``ro`` 表示唯讀,用戶端不能寫入;rw 表示用戶端可以寫入。

•sync, async:同步 (sync) 與非同步 (async) 模式,擇一使用。在同步模式,存取 NFS 的程式須等到實際讀寫動作完成後才返回執行;非同步模式則沒有這個要求,程式送出存取要求之後就可以繼續執行,加快系統運作的效率。基本上非同步模式雖然 效率高,但會增加系統不穩定的因素,當系統當機 (無論是伺服或用戶端) 的時候,很容易造成磁碟上的資料錯誤111cn.Net,所以 Debian 預設是同步模式。

除非特別有需要,否則不建議使用非同步模式。如果沒有指定 sync 或 async,NFS 伺服器在啟動的時候會印出警告訊息,所以我們應該在所有的 export point 上指定 sync 選項。

•root_squash, no_root_squash:NFS 在預設的狀況下會把超級使用者帳號 root 的 UID/GID (0/0) 對應到 nobody 去,這就是 root_squash。我們可以用 no_root_squash 關掉這個功能。

檢視任何一台主機的 NFS

showmount -e hostname

掛載 NFS

mount -t nfs hostname:/export/path /mount/point
 
Client端
1.NFS伺服器端先設定,新增要連結的主機名稱

vi /etc/exports

/home newserver.domain.kh.edu.tw (rw,sync,no_wdelay,nohide,no_root_squash)

確認有無開通讀取許可權www.111cn.net

vi /etc/hosts.allow

ALL: 163.32.X.X

設定完成後,重新掛載

exportfs -arv

2.Client端設定,更改原主機內home名稱(home2),並建立新的home,以便連結NFS伺服器的home

umout home

mv home home2

mkdir home

3.啟動portmap 服務

service portmap start

service nfslock start

4.掃瞄 NFS 伺服器分享的目錄,是否與使用者端連結

showmount -e NFS 163.32.X.X

或者

mount -t nfs file.domain.kh.edu.tw:/home /home

5.遠端主機直接掛載到相關目錄,每次開機就會自動掛載

vi /etc/fstab

file.domain.kh.edu.tw:/home /home nfs rw,soft,intr 0 0

6.重新啟動,再用帳號登入測試看看吧!
 
Client端2
基本安裝

yum -y install nfs-utils

vi /etc/idmapd.conf # line 5: uncomment and change to your domain name

Domain = localhost.domain.kh.edu.tw

/etc/rc.d/init.d/rpcbind start

/etc/rc.d/init.d/rpcidmapd start

/etc/rc.d/init.d/nfslock start

/etc/rc.d/init.d/netfs start

預設開機使用

chkconfig rpcbind on

chkconfig rpcidmapd on

chkconfig nfslock on

chkconfig netfs on

mount -t nfs file.domain.kh.edu.tw:/home /home

相關文章

聯繫我們

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