### Server 設定 1. nfs server 服務正常 -> 這個考試的時候會幫你準備好 1. mkdir /rusers 2. yum install rpcbind nfs-utils 3. systemctl enable nfs-server 4. systemctl start nfs-server 5. /etc/exports ``` /rusers *(rw,sync,insecure) # 上面這段意思是-> /rusers 分享出去成為網路磁碟 # 參數請參考鳥哥 ``` 6. firewalld ``` firewall-cmd --add-service=rpc-bind firewall-cmd --add-service=rpc-bind --per firewall-cmd --add-service=rpc-bind firewall-cmd --add-service=rpc-bind --per ``` ### Client 設定 需要知道的 1. /etc/auto.master -> autofs掛載“子目錄”設定檔的宣告位置 參考client /etc/auto.master 第13行 ``` /rusers /etc/auto.nfs # 這段設定是掛載autofs至我本機/rusers,設定檔案在/etc/auto.nfs ``` 2. 編輯上述設定的路徑/etc/auto.nfs 這段要做的事情參考[鳥哥 建立資料對應檔內 (/etc/auto.nfs) 的掛載資訊與伺服器對應資源](https://linux.vbird.org/linux_server/centos6/0330nfs.php#nfsclient_autofs) vim /etc/auto.nfs ``` [本地端次目錄] [-掛載參數] [伺服器所提供的目錄] remoteuser1 -rw,bg,soft,rsize=32768,wsize=32768 192.168.68.211:/rusers # 參數可以不用看這麼多,考試時有-rw就可以了,主要看題目出什麼 # 這段設定是寫說,請幫我掛載子目錄remoteuser1,但要參考/etc/auto.master裡面寫的掛載路徑 子目錄是掛載在這之下 # 考試的時候要依照題意 ``` 3. systemctl restart autofs 4. 驗證 df /rusers 觀察filesystem ``` [root@localhost rusers]# df /rusers Filesystem 1K-blocks Used Available Use% Mounted on /etc/auto.nfs 0 0 0 - /rusers # 要是個nfs資料夾 可以對照 / 會發現mount type filesystem不一樣,代表成功 [root@localhost rusers]# df / Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/sysvg-lv_root 12572672 1606476 10966196 13% / ``` 5. 驗證寫入 ``` cd /rusers/remoteuser1 touch 123 ``` server上的 /rusers 也要有一樣的檔案 (考試時非必要) # 額外問題 1. nfs server /etc/exports 我多開了 no_root_squash 如果拿掉這個參數,重啟nfs server rw 會失效為什麼 2. nfs server /etc/exports sync 參數是什麼 https://www.cnblogs.com/sevck/p/5733713.html <https://serverfault.com/questions/611007/unable-to-write-to-mount-point-nfs-server-getting-permission-denied>