nfs下的exportfs命令和nfs客戶端重新掛載


工作中,如果使用了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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM