顯示頁面舊版反向連結Fold/unfold all回到頁頂 本頁是唯讀的,您可以看到原始碼,但不能更動它。您如果覺得它不應被鎖上,請詢問管理員。 ====== Linux NFS 設定 ====== * NFS Server : 192.168.11.250 共用目錄為 /data * NFS Clien : 192.168.11.232(vm-web) ===== 安裝語法 ===== * CentOS<cli> yum install nfs-utils nfs-utils-lib </cli> * Ubuntu<cli> sudo apt install nfs-common nfs-kernel-server </cli> * Alpine<cli> sudo apk add nfs-utils </cli> ==== NFS Server 端 ==== <code> vi /etc/hosts </code> <file> : 192.168.11.232 vm-web.ichiayi.com vm-web </file> <code> chkconfig nfs on vi /etc/exports </code> <file> /data/ vm-web(rw,no_root_squash,no_all_squash,sync) </file> * CentOS <cli> systemctl start nfs </cli> * Ubuntu <cli> systemctl start nfs-server.service </cli> <note warning> * /etc/exports 內的設定的 nfs client 的 hostname 必須要正確, 否則當 clinet 要 mount 時會出現如下訊息: <code> mount: 192.168.11.250:/data failed, reason given by server: 拒絕不符權限的操作 </code> * 每次更動 /etc/exports 之後, 必須要重新啟動 nfs 服務 * CentOS <cli> systemctl start nfs </cli> * Ubuntu <cli> systemctl start nfs-server.service </cli> </note> <note important> * 如果想要簡單的設定權限, 讓所有連入 NFS 的使用者都是使用 root 權限可以在 export 的定義內加上 ,anonuid=0,anongid=0 \\ Exp. <file> : /STORAGE 10.0.5.10(rw,sync,no_subtree_check,all_squash,anonuid=0,anongid=0) </file> * OpenMediaVault 可以這樣設定 \\ {{:tech:2023-02-07_162019.png?600|}} </note> ===== NFS Client 端 ===== ===== 修正 hostname ===== <code> vi /etc/hosts </code> <file> 127.0.0.1 localhost.localdomain localhost vm-web 192.168.11.250 pd-920.ichiayi.com nfs-920 </file> <code> vi /etc/sysconfig/network </code> <file> NETWORKING=yes HOSTNAME=vm-web.ichiayi.com GATEWAY=192.168.11.250 </file> <code> hostname vm-web </code> 修正之後先登出,再登入一次就可以看到 hostname 已經變成 vm-web 如下所示: <code> [root@vm-web ~]# </code> ==== 測試驗證 ==== * 用 NFS Server IP 或 hostname 來顯示開放分享的目錄清單 <code> showmount -e 192.168.11.250 showmount -e nfs-920 </code> ++++顯示執行結果| <file> [root@vm-web ~]# showmount -e 192.168.11.250 Export list for 192.168.11.250: /data vm-web.ichiayi.com [root@web /]# showmount -e nfs-920 Export list for nfs-920: /data 192.168.1.232 [root@web /]# </file> ++++ * 建立與掛載共用目錄 <code> mkdir /data mount -t nfs 192.168.11.250:/data /data df -k </code> ++++顯示執行結果| <file> [root@vm-web ~]# mount -t nfs 192.168.11.250:/data /data [root@vm-web ~]# df -k Filesystem 1K-區段 已用 可用 已用% 掛載點 /dev/mapper/VolGroup00-LogVol00 7321528 1188696 5760916 18% / /dev/sda1 101086 27955 67912 30% /boot none 192384 0 192384 0% /dev/shm 192.168.11.250:/data 192292448 167842528 14681984 92% /data </file> ++++ <note warning> 如果不成功,就回去修正 NFS Server 端的 /etc/exports 內設定內容, 並重新啟動 nfs 服務. </note> ==== 設定開機自動掛載 ==== 當測試確認沒問題之後, 可以更改 /etc/fstab 來定義自動開機掛載 nfs 共用目錄 <code> vi /etc/fstab </code> <file> : 192.168.11.250:/data /data nfs rw 0 0 </file> **如果發覺效能太差, 可以改用 udp 的模式加快速度, 將 fstab 改成以下** <file> : 192.168.11.250:/data /data nfs rw,udp 0 0 </file> <note> * 當 mount 之後看到 nfs 的目錄 owner 都變成 nobody 時, 可能是 nfs client 端的 rpc.statd 沒有啟動, 可透過重新開機解決 </note> ===== 參考資料 ===== * http://www.howtoforge.com/setting-up-an-nfs-server-and-client-on-centos-6.3 * http://www.cyberciti.biz/faq/centos-fedora-rhel-nfs-v4-configuration/ * http://www.sofee.cn/blog/2006/09/29/46/ * http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-nfs-client-config-options.html * https://serverfault.com/questions/539267/nfs-share-with-root-for-anonuid-anongid {{tag>linux nfs 網路磁碟 儲存}} tech/nfs.txt 上一次變更: 2024/02/01 11:56由 jonathan