码迷,mamicode.com
首页 > Web开发 > 详细

nfs下的exportfs命令和nfs客户端重新挂载

时间:2019-06-18 12:40:36      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:卸载   重启   mkdir   rbo   centos7   star   system   list   script   

工作中,如果使用了nfs服务器,会遇到修改nfs服务器配置的情况,如果想重新让客户端加载上修改后的配置,
但是又不能重启rpcbind服务,我们需要使用export命令了

exportfs命令
常用选项
-a 全部挂载或者全部卸载
-r 重新挂载
-u 卸载某一个目录
-v 显示共享目录
以下操作在服务端上

实验:两台centos7

vim /etc/exports 
//增加
/tmp/ 192.168.133.0/24(rw,sync,no_root_squash)
exportfs -arv //不用重启nfs服务,配置文件就会生效
nfs服务不能随便重启,重启服务会对挂载了nfs的客户端有影响,
exportfs来自nfs-utils包
作用是修了配置后重载,不用重启服务。
服务器:

[root@JAMF nfsdir]# vim /etc/exports     
/home/nfsdir 172.16.22.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000)
/tmp 172.16.22.0/24(rw,sync,no_root_squash)
[root@JAMF nfsdir]# exportfs -arv
exporting 172.16.22.0/24:/tmp
exporting 172.16.22.0/24:/home/nfsdir

客户端:

[root@zabbix ~]# showmount -e 172.16.22.247                           
Export list for 172.16.22.247:
/tmp         172.16.22.0/24
/home/nfsdir 172.16.22.0/24
[root@zabbix ~]# mkdir /mnt/tmp
[root@zabbix ~]# mount -t nfs -onolock 172.16.22.247:/tmp /mnt/tmp 
-o nolock 了,即在挂载nfs服务时,不加锁。 在客户端上执行:
[root@zabbix ~]# touch /mnt/tmp/new.txt
[root@zabbix tmp]# ll /mnt/tmp/new.txt   
-rw-r--r-- 1 root root 0 Mar 16 01:41 /mnt/tmp/new.txt

服务器:

[root@JAMF nfsdir]# ll /tmp/new.txt 
-rw-r--r-- 1 root root 0 Mar 16 01:41 /tmp/new.txt

[root@zabbix mnt]# mount -t nfs -Oremount,nfsvers=3 172.16.22.247:/tmp /mnt/tmp
mount.nfs: /mnt/tmp is busy or already mounted
[root@zabbix mnt]# umount /mnt/tmp/                                            
[root@zabbix mnt]# mount -t nfs -Oremount,nfsvers=3 172.16.22.247:/tmp /mnt/tmp

#NFS客户端问题:NFS 4版本会有该问题

客户端文件属主属组nobody

客户端挂载共享目录后,不管是root用户还是普通用户,创建新文件时属主、属组为nobody
客户端挂载时加上 -O nfsvers=3

[root@zabbix mnt]# mount -t nfs -Oremount,nfsvers=3 172.16.22.247:/tmp /mnt/tmp
mount.nfs: /mnt/tmp is busy or already mounted
[root@zabbix mnt]# umount /mnt/tmp/                                            
[root@zabbix mnt]# mount -t nfs -Oremount,nfsvers=3 172.16.22.247:/tmp /mnt/tmp

客户端和服务端都需要
vim /etc/idmapd.conf //
把“#Domain = local.domain.edu” 改为 “Domain = xxx.com” (这里的xxx.com,随意定义吧),然后再重启rpcidmapd服务
服务器:

[root@JAMF nfsdir]# vim /etc/idmapd.conf 
[General]
#Verbosity = 0
# The following should be set to the local NFSv4 domain name
# The default is the host‘s DNS domain name.
Domain = jamf.oceanwing.com
[root@JAMF nfsdir]# systemctl restart rpcidmapd
客户端:

[root@zabbix mnt]# vim /etc/idmapd.conf 
[General]
#Verbosity = 0
# The following should be set to the local NFSv4 domain name
# The default is the host‘s DNS domain name.
Domain = zabbix.oceanwing.com
[root@zabbix mnt]# systemctl restart rpcidmapd

原文链接:https://blog.51cto.com/m51cto/2087738

nfs下的exportfs命令和nfs客户端重新挂载

标签:卸载   重启   mkdir   rbo   centos7   star   system   list   script   

原文地址:https://www.cnblogs.com/soymilk2019/p/11044346.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!