14.4

14.4 exportfs命令

經常使用選項
-a 所有掛載或者所有卸載 

-r 從新掛載  

-u 卸載某一個目錄  

-v 顯示共享目錄
如下操做在服務端上
vim /etc/exports //增長
/tmp/ 192.168.133.0/24(rw,sync,no_root_squash)
exportfs -arv //不用重啓nfs服務,配置文件就會生效
如下操做在客戶端
 mkdir /aminglinux
 mount -t nfs -o nolock 192.168.133.130:/tmp /aminglinux    //-o nolock是不加鎖,nfs經常使用;
 touch /aminglinux/test.txt
 ls -l !$
 -oremount,nfsvers=3

若是直接重啓NFS服務端的話,無論理客戶端的掛載狀況,那麼客戶端頗有可能產生d進程,沒法殺死處理的進程;這裏咱們就藉助exportfs命令!linux

一、NFS服務端配置:

[root@DasonCheng ~]# echo '/tmp/ 192.168.60.12(rw,sync,no_root_squash)' >> /etc/exports
[root@DasonCheng ~]# cat /etc/exports
/home/nfstestdir 192.168.60.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000)
/tmp/ 192.168.60.12(rw,sync,no_root_squash)
[root@DasonCheng ~]# exportfs -arv    //從新掛載,並顯示共享目錄;這樣就不用重啓nfs服務;
exporting 192.168.60.12:/tmp
exporting 192.168.60.0/24:/home/nfstestdir

二、NFS客戶端配置:

[root@aming2 ~]# showmount -e 192.168.60.11  //exportfs以後,就有了/tmp
Export list for 192.168.60.11:
/home/nfstestdir 192.168.60.0/24
/tmp             192.168.60.12
[root@aming2 ~]# mkdir /aming
[root@aming2 ~]# mount -t nfs -o nolock 192.168.60.11:/tmp/ /aming
[root@aming2 ~]# df -h
文件系統                        容量  已用  可用 已用% 掛載點
192.168.60.11:/home/nfstestdir   19G  7.0G   12G   38% /mnt
192.168.60.11:/tmp               19G  7.0G   12G   38% /aming
[root@aming2 ~]# echo 'testtestfile' >/aming/test.txt
[root@aming2 ~]# ll /aming/
-rw-r--r--. 1 root   root     13 8月  24 23:30 test.txt    
//新建立的文件是root,這就是no_root_squash的做用,至關於root最高權限在本地文件

14.5 NFS客戶端問題

客戶端文件屬主屬組nobody
NFS 4版本會有該問題
客戶端掛載共享目錄後,無論是root用戶仍是普通用戶,建立新文件時屬主、屬組爲nobody
客戶端掛載時加上 -o nfsvers=3
客戶端和服務端都須要
vim /etc/idmapd.conf //
把「#Domain = local.domain.edu」 改成 「Domain = xxx.com」 (這裏的xxx.com,隨意定義吧),而後再重啓rpcidmapd服務
  • 法1:
[root@aming2 ~]# mount -t nfs -o nolock -o nfsvers=3 192.168.60.11:/tmp /aming
//這樣掛載;-o nfsvers=3
[root@aming2 ~]# mount -t nfs -oremount,nfsvers=3 192.168.60.11:/tmp /aming
//或者remount從新掛載也行;
  • 法2:
客戶端和服務端都須要
vim /etc/idmapd.conf 
//把「#Domain = local.domain.edu」 改成 「Domain = xxx.com」 (這裏的xxx.com,隨意定義吧)
[root@DasonCheng ~]# 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 = aaa.com    //自定義一個域名,隨機;
[root@DasonCheng ~]# systemctl restart rpcidmapd  //重啓rpcidmapd或者rpcbind服務都行;
相關文章
相關標籤/搜索