nfs服务器的搭建和挂载使用

实验环境:centos7.3
服务器: JAMF 172.16.22.247
客户端: zabbix 172.16.22.233
安装包:
服务器: yum -y install rpcbind.x86_64 nfs-utils.x86_64
客户端: yum -y install nfs-utils

服务器:

vim /etc/exports

/home/nfsdir 172.16.22.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000)

NFS配置选项

  1. rw 读写
  2. ro 只读
  3. sync 同步模式,内存数据实时写入磁盘
  4. async 非同步模式
  5. no_root_squash 客户端挂载NFS共享目录后,root用户不受约束,权限很大
  6. root_squash 与上面选项相对,客户端上的root用户收到约束,被限定成某个普通用户
  7. all_squash 客户端上所有用户在使用NFS共享目录时都被限定为一个普通用户
  8. anonuid/anongid 和上面几个选项搭配使用,定义被限定用户的uid和gid
[root@JAMF ~]# systemctl start rpcbind
[root@JAMF ~]# systemctl start nfs
[root@JAMF ~]# systemctl enable rpcbind
[root@JAMF ~]# systemctl enable nfs

服务器关闭selinux,防火墙信任客户端源IP

getenforce 
Disabled
[root@JAMF ~]# firewall-cmd --permanent --zone=trusted --add-source=172.16.22.233
success
[root@JAMF ~]# firewall-cmd --reload                                      
success

客户端挂载:

[root@zabbix ~]# showmount -e 172.16.22.247
Export list for 172.16.22.247:
/home/nfsdir 172.16.22.0/24
[root@zabbix ~]# mount | grep nfs
nfsd on /proc/fs/nfsd type nfsd (rw,relatime)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
172.16.22.247:/home/nfsdir on /mnt type nfs4 (rw,relatime,vers=4.1,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=172.16.22.233,local_lock=none,addr=172.16.22.247)
[root@zabbix ~]# df -h | grep nfs
172.16.22.247:/home/nfsdir   76G   24G   53G  31% /mnt

客户端:

[root@JAMF nfsdir]# ll

[root@zabbix ~]# echo -e "testnfs\nmysql\n" > /mnt/testnf.txt
-rw-r--r-- 1 www  www  15 Mar 16 01:28 testnf.txt

[root@zabbix ~]# ll /mnt/
total 8
-rw-r--r-- 1 www  www  15 Mar 16  2018 testnf.txt
[root@zabbix ~]# id www
uid=1000(www) gid=1000(www) groups=1000(www)  //虽然在客户端使用的是root账号创建的文件,但实际上是
[root@zabbix ~]# 
服务器:
[root@JAMF mnt]# cd /home/nfsdir/
[root@JAMF nfsdir]# ll
total 4
-rw-r--r-- 1 www www 15 Mar 16 18:00 testnfs.txt
drwxr-xr-x 2 www www  6 Mar 16 01:40 tmp
[root@JAMF nfsdir]# id www
uid=1000(www) gid=1000(www) groups=1000(www)

转载于:https://blog.51cto.com/m51cto/2087736

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值