我有三台机器 -
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
现在我做showmount
了machineA
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
知道我在这里做错了什么吗?
答案1
更改你的 /etc/exports
/opt/exhibitor/conf/ 10.108.24.*(rw)
到
/opt/exhibitor/conf/ 10.108.24.0/24(rw)
答案2
似乎您正在尝试在同一台服务器上执行 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/
答案3
在此之前,我很抱歉我的英语很糟糕。但我会尽力写得更好。
我认为您需要在安装时设置用户名和密码。
mount -t nfs 10.108.24.132:/opt/exhibitor/conf /opt/exhibitor/conf/ -o username=USERNAME,password=PASSWORD
我从未尝试过 nfs,我的机器上使用 samba。在 samba 中,我们需要将 linux 用户添加到 samba 用户。
smbpasswd -a username
也许在 nfs 中也是同样的情况。