首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> Java 程式設計 >> Java 相關知識

Solaris 系統 NFS 服務架設與管理實戰手冊

     編輯:Java 相關知識

NFS 核心概念與角色

NFS (Network File System) 為 Sun 公司基於 TCP/IP、RPC (Remote Procedure Call)、XDR (External Data Representation) 開發,支援異構作業系統間檔案共享。
NFS 伺服器:共享本地資源(執行 mountd、nfsd 守護程序)
NFS 客戶端:存取共享資源(執行 statd、lockd 守護程序)
實務中單一主機常同時扮演雙重角色,互相共享存取。

關鍵檔案與指令對照表

角色守護程序關鍵檔案管理指令
伺服器mountd, nfsd/etc/dfs/dfstab, /etc/dfs/sharetab, /etc/rmtab, /etc/rc3.d/S15nfs.servershare, unshare, shareall, unshareall
客戶端statd, lockd/etc/vfstab, /etc/mnttabmount, umount, mountall, umountall

伺服器端詳細操作流程

掛載請求處理機制

  1. 客戶端 mount 請求 → 伺服器 mountd
  2. mountd 驗證後回傳資源資訊(磁碟裝置號、inode 號等唯一編碼)
  3. 客戶端寫入本地 /etc/mnttab
  4. mountd 在 /etc/rmtab 記錄:remote hostname: local filename
  5. mountd 重啟或收到卸載請求時更新 /etc/rmtab

共享資源指令詳解

share -F nfs -o rw=client1:client2,ro=@192.168.1.0/24:host3,root=host4 -d "描述" /path/to/resource
  • rw:讀寫(預設)
  • rw=client1:client2:指定主機讀寫
  • ro:唯讀
  • ro=@network/host:指定網段/主機唯讀
  • root=host:授予指定主機 root 權限(優先級低於伺服器本地權限)

取消共享:unshare /path/to/resource

開機自動共享

  1. 編輯 /etc/dfs/dfstab,每行一條 share 指令
  2. 執行 /etc/init.d/nfs.server start 或進入 run level 3 自動生效
  3. 手動快速指令:shareall(共享所有 dfstab 資源)、unshareall

資源查看指令

  • dfshares:顯示可掛載資源(資源、伺服器、權限、傳輸埠)
  • dfmounts:顯示資源被利用狀況(資源、目錄、客戶端)
  • nfsstat:完整 NFS 狀態統計

客戶端詳細操作流程

偵測伺服器共享

showmount -e server_host  # 查看可掛載資源
showmount -a              # 顯示已使用資源與來源
showmount -d              # 顯示已遠端掛載資源

手動掛載/卸載

mkdir /local/mount/point
mount server:/remote/path /local/mount/point   # 預設 rw
mount -o ro server:/remote/path /local/mount/point  # 唯讀

umount server:/remote/path /local/mount/point

開機自動掛載

編輯 /etc/vfstab:

server:/remote/path - /local/mount/point nfs - yes soft,bg
  • soft:掛載失敗報錯不掛起
  • bg:背景掛載,不阻塞開機流程

批量管理指令

  • mountall:掛載所有 vfstab 中 mount at boot=yes 資源
  • mountall -r:僅影響遠端檔案
  • mountall -l:僅影響本地檔案
  • umountall:卸載所有已掛載資源(排除 /、/proc 等關鍵檔案系統)

實務關鍵提醒

  • 伺服器本地檔案權限優先於 share 設定(本地唯讀則 root 選項也無法寫入)
  • /etc/rmtab 記錄非權威,僅供參考追蹤
  • 生產環境建議搭配 automount (autofs) 實現按需掛載
  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved