ubuntu 使用NFS共享

2021-09-21 05:19:35 字數 1916 閱讀 5207

系統介紹:

root@master:~# cat /etc/issue

ubuntu 12.04.1 lts \n \l

root@master:~# uname  -a

linux master 3.2.0-29-generic #46-ubuntu smp fri jul 27 17:03:23 utc 2012 x86_64 x86_64 x86_64 gnu/linux

root@master:~# 

安裝步驟:

ps:一下操作只針對上述作業系統有效,且真實測試有效         

步驟一:

安裝nfs服務端

apt-get install nfs-kernel-server

配置共享目錄(關於引數後續介紹)

vim /etc/exports

/opt/html *(rw,sync,no_root_squash)

啟動nfs server

/etc/init.d/portmap restart

/etc/init.d/nfs-kernel-server restart

步驟二、

客戶端掛載nfs

mount -t nfs 192.168.1.185:/opt/html /var/www/html

檢視是否掛載成功

ubuntu nfs 常用的引數有: 

ro 唯讀訪問 

rw 讀寫訪問 

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

async nfs 在寫入資料前可以響應請求 

secure nfs 通過 1024 以下的安全 tcp/ip 埠傳送 

insecure nfs 通過 1024 以上的埠傳送 

wdelay 如果多個使用者要寫入 nfs 目錄,則歸組寫入(預設) 

no_wdelay 如果多個使用者要寫入 nfs 目錄,則立即寫入,當使用 async 時,

無需此設定。 

hide 在 nfs 共享目錄中不共享其子目錄 

no_hide 共享 nfs 目錄的子目錄 

subtree_check 如果共享/usr/bin 之類的子目錄時,強制 nfs 檢查父目錄

的許可權(預設) 

no_subtree_check 和上面相對,不檢查父目錄許可權 

all_squash 共享檔案的 uid 和 gid 對映匿名使用者 anonymous,適合公用目

錄。 no_all_squash 保留共享檔案的 uid 和 gid(預設) 

root_squash root 使用者的所有請求對映成如 anonymous 使用者一樣的許可權(默

認) no_root_squas root 使用者具有根目錄的完全管理訪問許可權 

anonuid=*** 指定 nfs 伺服器/etc/passwd 檔案中匿名使用者的 uid 

anongid=*** 指定 nfs 伺服器/etc/passwd 檔案中匿名使用者的 gid 

報錯:mount: wrong fs type, bad option, bad superblock on 192.168.1.195:/opt/html,

missing codepage or helper program, or other error

(for several filesystems (e.g. nfs, cifs) you might

need a /sbin/mount.helper program)

in some cases useful info is found in syslog - try

dmesg | tail  or so

解決辦法:

apt-get install nfs-common

ubuntu搭建nfs共享目錄

參考 在server端的設定如以下步驟 1.安裝nfs server軟體 sudo apt get install nfs kernel server2.建立共享目錄並將目錄的許可權改為777 mkdir p share chmod 777 share 如下圖 3.配製檔案vi etc export...

Docker Swarm集群 使用NFS共享儲存

系統環境為centos,一共有7臺機子組成了docker swarm集群,每台機子都要安裝nfs ipdocker角色 nfs角色 111.111.3.41 manager server 111.111.3.42 manager client 111.111.3.43 manager client ...

ubuntu16 04 NFS 檔案共享設定

1.1 伺服器端需要安裝 nfs kernel server 軟體包 sudo apt get update sudo apt get install nfs kernel server1.2 建立共享的檔案 也可以是已經存在的檔案 sudo mkdir p home gongxiang1.3.修改...