第一个节点:
[root@ip-10-164-175-246 ~]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.0 (Maipo) [root@ip-10-164-175-246 ~]# rpm -q nfs-utils nfs-utils-1.3.0-0.el7.x86_64 [root@ip-10-164-175-246 ~]# cat /etc/exports /var/www/html/ ip-10-184-161-46.ec2.internal(rw) [root@ip-10-164-175-246 ~]#
第二个节点:
[root@ip-10-184-161-46 ~]# mount ip-10-164-175-246.ec2.internal:/var/www/html/ /mnt/ [root@ip-10-184-161-46 ~]# touch /mnt/$$ touch: cannot touch ‘/mnt/3326’: Permission denied [root@ip-10-184-161-46 ~]#
为什么我不能通过NFS向/ mnt /写入任何内容?
解决方法
root_squash — Prevents root users connected remotely from having root
privileges and assigns them the user ID for the user nfsnobody. This
effectively “squashes” the power of the remote root user to the lowest
local user,preventing unauthorized alteration of files on the remote
server. Alternatively,the no_root_squash option turns off root
squashing. To squash every remote user,including root,use the
all_squash option. To specify the user and group IDs to use with
remote users from a particular host,use the anonuid and anongid
options,respectively. In this case,a special user account can be
created for remote NFS users to share and specify
(anonuid=,anongid=),where is the
user ID number and is the group ID number.
你需要添加标志no_root_squash来禁用它,因为它默认是打开的.