Linux中如何掌握NFS的使用方法

來源:互聯網
上載者:User

NFS是我們經常要用到的服務,用於linux系統之間文檔目錄的共用。其實nfs是配置是很簡單的,同樣我也用簡單的方字來記錄說明一下NFS的配置要點。

1)服務端設定檔: /etc/exports

檔案格式: Directory hostname (options)

Directory 為要共用的目錄;

hostname 客戶機的網域名稱/IP地址/IP位址區段;也可以為空白,空則代表任意主機;

options 可選,如不指定,則採用預設選項。如ro,rw,sync,async等;

如:

 
  1. /home 192.168.1.* (rw,async,no_root_squash) 

Rw;可讀可寫

Async;同步,服務端只有接受到用戶端的回應,才進行下一步,以確保串連更可靠

No_root_squash;不壓縮root使用者的許可權,如要更安全請用roo_squash

在服務端可以用exportfs命令來輸出exports對外共用的目錄;

2)確保啟動portmap和NFS

 
  1. # /etc/rc.d/init.d/portmap start (or: # /service portmap start )  
  2.  
  3. # /etc/rc.d/init.d/nfs start (or: # /serverice nfs start) 

註:可用netstat –untlp,來查看portmap和nfs服務是否啟動,2049連接埠就是NFS伺服器,111連接埠對應的就是portmap服務,可以發現在TCP和UDP上都有對應的連接埠;

3) NFS用戶端配置(mount或fstab檔案)

 
  1. # mount –t nfs hostname(orIP):/directory /mountpoint 

-t nfs可以省略;

/directory為絕對路徑;

或是在/etc/fstab檔案中增加NFS檔案系統的掛載記錄

 
  1. NFSserverIP:/directory /mountpoint nfs defaults 0 0  

可以用mount查一下掛載點的情況。

聯繫我們

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