标签:system denied exports 执行 ide tree 地址 master 文件的
服务器端:(192.168.10.10)"/etc/fstab" 14L, 697C written
? 1
? 2
? 3
? 4
执行mount -a命令 没有报错,说明挂载成功,df -h命令查看
[root@client ~]# mount -a
[root@client ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 15G 2.9G 12G 20% /
devtmpfs 906M 0 906M 0% /dev
tmpfs 914M 80K 914M 1% /dev/shm
tmpfs 914M 9.0M 905M 1% /run
tmpfs 914M 0 914M 0% /sys/fs/cgroup
/dev/sr0 3.5G 3.5G 0 100% /yum
/dev/sda3 15G 125M 15G 1% /var
/dev/sda1 297M 91M 207M 31% /boot
192.168.10.10:/nfs_share 15G 2.9G 12G 20% /nfs
? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 11
? 12
问题1:在挂载的目录里创建一个文件,发现创建失败,这是因为默认的权限选项是root_squash,禁止远端用户具有root权限
[root@client ~]# touch /nfs/myhost
touch: cannot touch ‘/nfs/myhost’: Permission denied
? 1
? 2
在服务器端查看cat /var/lib/nfs/etab 文件,发现有很多选项
[root@server ~]# cat /var/lib/nfs/etab
/nfs_share (rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,no_all_squash,no_subtree_check,secure_locks,acl,anonuid=65534,anongid=65534,sec=sys,rw,secure,root_squash,no_all_squash)
? 1
? 2
解决方案1:
在服务器端的/etc/exports添加以下配置
[root@server ~]# vim /etc/exports
/nfs_share (rw,no_root_squash)
[root@server ~]# exportfs -a #不要轻易重启nfs服务,否则客户机端会出现卡顿的现象,尽量使用exportfs命令
? 1
? 2
? 3
解决方案2:服务器端恢复之前的配置
[root@server ~]# vim /etc/exports
/nfs_share (rw)
#在服务器端把共享的目录other的权限添加写入的权限
[root@server ~]# chmod o+w /nfs_share -R
[root@server ~]# ll -d /nfs
drwxrwxrwx. 2 root root 33 Jul 19 10:37 /nfs_share
? 1
? 2
? 3
? 4
? 5
? 6
在客户机端测试
[root@client ~]# touch /nfs/myhost1
[root@client ~]# ll /nfs/
total 0
-rw-rw-rw-. 1 root root 0 Jul 19 10:29 myhost
-rw-r--r--. 1 nfsnobody nfsnobody 0 Jul 19 10:37 myhost1
? 1
? 2
? 3
? 4
? 5
完美解决!!!!
另外,客户机端还有一种方式可以用来自动挂载nfs服务的,那就是autofs服务
挂载方式二:在客户机端(192.168.10.10)
? autofs服务的间接映射
首先在服务器创建/nfs_share1目录,并且这个目录共享出去
mkdir /nfs_share1
echo -e“/nfs_share1\t*(rw)”>>/etc/exports
然后在客户机安装autofs服务
yum -y install autofs
重启autofs服务并且加入自启动项中
[root@client ~]# systemctl enable autofs
ln -s ‘/usr/lib/systemd/system/autofs.service‘ ‘/etc/systemd/system/multi-user.target.wants/autofs.service‘
[root@client ~]# systemctl restart autofs
? 1
? 2
? 3
编辑autofs的主映射文件
#这里的主映射文件的后缀名一定要以autofs结尾,其中/auto为基础目录,就是挂载点的上级目录,/etc/nice.auto为二级映射文件,文件名字可以随便
[root@client ~]# vim /etc/auto.master.d/nice.autofs
/auto /etc/nice.auto
? 1
? 2
? 3
编辑autofs的二级映射文件
#nice为挂载点,挂载的路径相当于/auto/nice 中间为挂载的权限,必须以-开头,最后192.168.1.11:/nfs_share1表示服务器的地址以及共享目录,中间以":"隔开.
[root@client ~]# vim /etc/nice.auto
nice -rw 192.168.10.10:/nfs_share1
标签:system denied exports 执行 ide tree 地址 master 文件的
原文地址:http://blog.51cto.com/13956389/2174430