nfs(network file system -網路檔案系統)

來源:互聯網
上載者:User

標籤:nfs

一種使用於分散式檔案系統的協定。功能是通過網路讓不同的機器、不同的作業系統能夠彼此分享個別的資料,讓應用程式在用戶端通過網路訪問位於伺服器磁碟中的資料,是在類unix系統間實現磁碟檔案分享權限設定的一種方法。

NFS的基本原則:允許不同的用戶端及服務端通過一組RPC分享相同的檔案系統。它是獨立於作業系統,容許不同硬體及作業系統的西通過共同進行檔案的分享。

RPC(remote procedure call-遠端程序呼叫)是能使用戶端執行其他系統中程式的一種機制。

關閉防火牆和selinux,使用server1與server2虛擬機器,server1共用檔案。

1). 安裝nfs軟體

yum install nfs-utils -y

systemctl start nfs-server

systemctl enable nfs-server

2). 設定共用內容

mkdir /nfshare/nfs{1..5} -p

3). 修改配置

vim /etc/exports

@@

/nfshare 172.25.254.1/24(ro)

@@

##第一列/nfshare表示需要共用的目錄

##IP 表示允許哪個用戶端訪問

##IP 後括弧裡的設定表示對該共用檔案的許可權

ro ##唯讀訪問

rw ##讀寫訪問

sync ##所有資料在請求時寫入共用

Hide ##在 NFS 共用目錄中不共用其子目錄

no_hide ##共用 NFS 目錄的子目錄

all_squash 共##享檔案的 UID 和 GID 映射匿名使用者anonymous,適合公用目錄。

no_all_squash##保留共用檔案的 UID 和 GID(預設)

root_squash##root使用者的所有請求映射成如anonymous 使用者一樣的許可權(預設)

no_root_squas##root 使用者具有根目錄的完全管理訪問

許可權

exportfs -rv##重新整理配置,使配置生效

[[email protected] ~]# vim /etc/exports

@/nfshare        172.25.254.1/24(rw)@

[[email protected] ~]#  exportfs -rv

exporting 172.25.254.1/24:/nfshare

[[email protected] ~]#  showmount -e 172.25.254.1

Export list for 172.25.254.1:

/nfshare 172.25.254.1/24

**手動掛載

yum install nfs-utils -y

mkdir /mnt/nfsmount//建立用戶端掛載目錄

showmount -e 172.25.254.1//顯示某ip共用的目錄

mount 172.25.254.1:/nfshare /mnt/nfsmount//掛在共用目錄到本地

vim /etc/fatab//永久掛載

```

//在檔案後添加下面一行內容

172.25.254.1:/nfshare /mnt/nfsmount nfs4 defaults 0 0

```

注意:nfs,cifs也屬於檔案系統格式,是網路檔案系統格式。

**自動掛載到預設目錄

yum install autofs -y

systemctl start autofs

systemctl enable autofs

cd /net/172.25.254.1//訪問服務端共用的目錄

vim /etc/sysconfig/autofs//修改釋放掛載資源的時間

```

13 TIMEOUT=5

```

[[email protected] ~]# systemctl start autofs

[[email protected] ~]# systemctl enable autofs

[[email protected] ~]# cd /net/172.25.254.1

[[email protected] 172.25.254.1]# vim /etc/sysconfig/autofs

**自動掛載到自訂目錄

vim /etc/auto.master

/westos/etc/auto.westos

vim /etc/auto.westos

*172.25.254.126:/nfshare/&

redhat 172.25.254.126:/nfshare

systemctl restart autofs

cd /westos

如果有報錯根據錯誤資訊排查。常見問題有 rpc 服務沒有啟動、防火牆沒關閉、selinux 未關閉等問題。


本文出自 “元小光” 部落格,請務必保留此出處http://yuanxiaoguang.blog.51cto.com/11338250/1898237

nfs(network file system -網路檔案系統)

聯繫我們

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