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命令!

1、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
2、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服务都行;

转载于:https://my.oschina.net/u/3651233/blog/1523333

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值