Linux

mount.nfs:在 Ubuntu 機器上掛載時伺服器拒絕訪問?

  • December 18, 2013

我有三台機器 -

machineA    10.108.24.132
machineB    10.108.24.133
machineC    10.108.24.134

所有這些機器都安裝了 Ubuntu 12.04,我對這三台機器都有 root 訪問權限。

現在我應該在上面的機器上做下面的事情 -

Create mount point /opt/exhibitor/conf
Mount the directory in all servers.
sudo mount <NFS-SERVER>:/opt/exhibitor/conf /opt/exhibitor/conf/

/opt/exhibitor/conf如上所述,我已經在所有這三台機器中創建了目錄。

現在我正在嘗試在所有這三台機器上創建一個掛載點。所以我遵循了以下過程 -

安裝 NFS 支持文件和 NFS 核心伺服器

$ sudo apt-get install nfs-common nfs-kernel-server

創建共享目錄

$ mkdir /opt/exhibitor/conf/

編輯 /etc/exports 並添加如下條目:

# /etc/exports: the access control list for filesystems which may be exported
#               to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
#
/opt/exhibitor/conf/     10.108.24.*(rw)

執行 exportfs

root@machineA:/# exportfs -rv
exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "10.108.24.*:/opt/exhibitor/conf/".
 Assuming default behaviour ('no_subtree_check').
 NOTE: this default has changed since nfs-utils version 1.0.x

exporting 10.108.24.*:/opt/exhibitor/conf

現在我做showmountmachineA

root@machineA:/# showmount -e 10.108.24.132
Export list for 10.108.24.132:
/opt/exhibitor/conf 10.108.24.*

現在當我這樣做時,我收到一個錯誤 -

root@machineA:/# sudo mount -t nfs 10.108.24.132:/opt/exhibitor/conf /opt/exhibitor/conf/
mount.nfs: access denied by server while mounting 10.108.24.132:/opt/exhibitor/conf

知道我在這裡做錯了什麼嗎?

改變你的 /etc/exports 從

/opt/exhibitor/conf/     10.108.24.*(rw)

/opt/exhibitor/conf/     10.108.24.0/24(rw)

好像您正在嘗試在同一台伺服器上進行 NFS 掛載

root@machineA:/# sudo mount -t nfs 10.108.24.132:/opt/exhibitor/conf /opt/exhibitor/conf/

機器A是10.108.24.132

你試過了嗎?

root@machineB:/# mkdir -p /opt/exhibitor/conf
root@machineB:/# sudo mount -t nfs 10.108.24.132:/opt/exhibitor/conf /opt/exhibitor/conf/

在機器C上

root@machineC:/# mkdir -p /opt/exhibitor/conf
root@machineC:/# sudo mount -t nfs 10.108.24.132:/opt/exhibitor/conf /opt/exhibitor/conf/

如果從 machineA 但使用不同的目錄作為掛載點,您應該能夠做到:

root@machineA:/# mkdir -p /opt/exhibitor/conf2
root@machineA:/# sudo mount -t nfs 10.108.24.132:/opt/exhibitor/conf /opt/exhibitor/conf2/

引用自:https://serverfault.com/questions/562051