挂载共享文件夹时出现拒绝访问错误?

挂载共享文件夹时出现拒绝访问错误?

我是一名 Linux 新手,我有一个非常基本的问题。我有三台机器 -

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.*

而且我已经在上述三台机器上启动了 NFS 服务器 -

sudo /etc/init.d/nfs-kernel-server start    

现在当我这样做时,我收到了一个错误 -

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

我也尝试过在 machineB 和 machineC 上做同样的事情,但仍然得到同样的错误-

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

我的/etc/exports文件看起来不错吗?因为我在这三台机器上都有相同的内容。还有,有没有与 NFS 相关的日志,我可以查看以找到任何线索?

知道我在这里做错了什么吗?

更新:-

所以我的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.132(rw)
/opt/exhibitor/conf/     10.108.24.133(rw)
/opt/exhibitor/conf/     10.108.24.134(rw)

快速检查一下 - 如上所述,我为每台机器获取的 IP 地址如下 -

root@machineB:/# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:50:56:ad:5b:a7
          inet addr:10.108.24.133  Bcast:10.108.27.255  Mask:255.255.252.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5696812 errors:0 dropped:12462 overruns:0 frame:0
          TX packets:5083427 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:7904369145 (7.9 GB)  TX bytes:601844910 (601.8 MB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:187144 errors:0 dropped:0 overruns:0 frame:0
          TX packets:187144 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:24012302 (24.0 MB)  TX bytes:24012302 (24.0 MB)

这里我为机器B获取的IP地址是10.108.24.133

答案1

您需要确定 (rw) 的其他选项,例如 (rw、sync、fsid=0、crossmnt、no_subtree_check) 等,因为它们有自己的含义(在我的文章中解释过)并允许 /etc/hosts.allow 中的主机

我建议你快速浏览一下本教程如何在 Ubuntu 中设置 NFS 服务器如果您有任何问题或疑虑,请告诉我。

答案2

刚刚快速浏览了一下导出手册页。我认为通配符“*”仅适用于基于主机名的导出。如果您希望导出到 MachineB 和 MachineC,我会首先尝试导出如下:

10.108.24.0/24(rw)

..看看结果如何。这将导出到 10.108.24.1-254(可用)。如果这绝对不是您想要的,请尝试分别指定每个 IP 地址:

10.108.24.133(rw) 10.108.24.134(rw)

干杯

sc.

答案3

如果你有 nfs 文件系统

1.安装 nfs-common sudo apt-get install nfs-common

2.sudo nano /etc/fstab输入以下内容

server.me.lab:/path/to/folder /home/foo nfs rsize=8192,wsize=8192,timeo=14,intr,noatime

3.创建挂载点

mkdir /home/foo

4.sudo mount -a

相关内容