工作中,如果使用了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包
作用是修了配置后重载,不用重启服务。
服务器:
[[email protected] 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)
[[email protected] nfsdir]# exportfs -arv
exporting 172.16.22.0/24:/tmp
exporting 172.16.22.0/24:/home/nfsdir
客户端:
[[email protected] ~]# 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
[[email protected] ~]# mkdir /mnt/tmp
[[email protected] ~]# mount -t nfs -onolock 172.16.22.247:/tmp /mnt/tmp
-o nolock 了,即在挂载nfs服务时,不加锁。 在客户端上执行:
[[email protected] ~]# touch /mnt/tmp/new.txt
[[email protected] tmp]# ll /mnt/tmp/new.txt
-rw-r--r-- 1 root root 0 Mar 16 01:41 /mnt/tmp/new.txt
服务器:
[[email protected] nfsdir]# ll /tmp/new.txt
-rw-r--r-- 1 root root 0 Mar 16 01:41 /tmp/new.txt
[[email protected] mnt]# mount -t nfs -Oremount,nfsvers=3 172.16.22.247:/tmp /mnt/tmp
mount.nfs: /mnt/tmp is busy or already mounted
[[email protected] mnt]# umount /mnt/tmp/
[[email protected] mnt]# mount -t nfs -Oremount,nfsvers=3 172.16.22.247:/tmp /mnt/tmp
#NFS客户端问题:NFS 4版本会有该问题
客户端文件属主属组nobody
客户端挂载共享目录后,不管是root用户还是普通用户,创建新文件时属主、属组为nobody
客户端挂载时加上 -O nfsvers=3
[[email protected] mnt]# mount -t nfs -Oremount,nfsvers=3 172.16.22.247:/tmp /mnt/tmp
mount.nfs: /mnt/tmp is busy or already mounted
[[email protected] mnt]# umount /mnt/tmp/
[[email protected] 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服务
服务器:
[[email protected] 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
[[email protected] nfsdir]# systemctl restart rpcidmapd
客户端:
[[email protected] 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
[[email protected] mnt]# systemctl restart rpcidmapd
原文地址:http://blog.51cto.com/m51cto/2087738
时间: 2024-11-08 21:49:30