码迷,mamicode.com
首页 > 其他好文 > 详细

14.1 NFS介绍 14.2 NFS服务端安装配置 14.3 NFS配置选项

时间:2018-06-21 23:42:44      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:文件   监听端口   服务   实时   blank   port   abi   同步   磁盘   

14.1 NFS介绍

1. NFS是Network File System的缩写

2. NFS最早由Sun公司开发,分2,3,4三个版本,2和3由Sun起草开发,4.0开始Netapp公司参与并主导开发,最新为4.1版本

3. NFS数据传输基于RPC协议,RPC为Remote Procedure Call的简写。

4. NFS应用场景是:A,B,C三台机器上需要保证被访问到的文件是一样的,A共享数据出来,B和C分别去挂载A共享的数据目录,从而B和C访问到的数据和A上的一致

技术分享图片

NFS原理图:

技术分享图片技术分享图片14.2 NFS服务端安装配置

准备两个centos 7版本服务器:hao1服务端 hao2客户端

1. hao1服务端上安装:

[root@hao-01 ~]# yum install -y nfs-utils rpcbind

2. 编辑并添加内容:

[root@hao-01 ~]# vim /etc/exports

添加内容:

[ 共享目录 ip段.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000) ]

/home/nfstestdir 192.168.211.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000)

3. 创建共享目录:

[root@hao-01 ~]# mkdir /home/nfstestdir

4. 共享目录设置777权限:

[root@hao-01 ~]# chmod 777 /home/nfstestdir

5. 启动rpcbind服务:

[root@hao-01 ~]# systemctl start rpcbind

6. 搜索rpcbind是否启动?

[root@hao-01 ~]# ps aux |grep rpcbind

技术分享图片7. 查看rpcbind监听端口(显示systemd也是正常的):

[root@hao-01 ~]# netstat -lnpt

技术分享图片8. 启动nfs:

[root@hao-01 ~]# systemctl start nfs

9. 搜索nfs是否启动?

[root@hao-01 ~]# ps aux |grep nfs

技术分享图片10. 设置nfs开机启动:

[root@hao-01 ~]# systemctl enable nfs

技术分享图片14.3 NFS配置选项

NFS配置选项:

rw 读写

ro 只读

sync 同步模式,内存数据实时写入磁盘

async 非同步模式

no_root_squash 客户端挂载NFS共享目录后,root用户不受约束,权限很大

root_squash 与上面选项相对,客户端上的root用户收到约束,被限定成某个普通用户

all_squash 客户端上所有用户在使用NFS共享目录时都被限定为一个普通用户

anonuid/anongid 和上面几个选项搭配使用,定义被限定用户的uid和gid

 

1. hao2客户端上安装:

[root@hao-02 ~]# yum install -y nfs-utils rpcbind

2. 关闭hao1服务端防火墙:

[root@hao-01 ~]# systemctl stop firewalld

[root@hao-01 ~]# getenforce

[root@hao-01 ~]# setenforce 0

3. 关闭hao2客户端防火墙:

[root@hao-02 ~]# systemctl stop firewalld

[root@hao-02 ~]# getenforce

[root@hao-02 ~]# setenforce 0

4. 访问hao1服务端的ip,查看服务端共享目录和ip段:

[root@hao-02 ~]# showmount -e 192.168.211.128

技术分享图片

5. hao2客户端 nfs挂载:

mount -t nfs 服务端ip:共享目录 挂载点

mount -t nfs 192.168.211.128:/home/nfstestdir /mnt

6. 查看挂载:

[root@hao-02 ~]# df -h

技术分享图片

技术分享图片7. 挂载点mnt下,创建一个文件:

[root@hao-02 ~]# touch /mnt/hao.txt

8. hao2客户端查看挂载点下hao.txt文件 属主 属组:

[root@hao-02 ~]# ls -l /mnt/hao.txt

技术分享图片

技术分享图片9. hao2客户端查看mysql的id:

[root@hao-02 ~]# id mysql

技术分享图片

技术分享图片10. hao1服务端查看共享目录下的hao.txt文件 属主 属组:

[root@hao-01 ~]# ls -l /home/nfstestdir/hao.txt

技术分享图片

技术分享图片11. hao1服务端查看mysql的id:

[root@hao-01 ~]# id mysql

技术分享图片

12. 因为/etc/exports里设置了anonuid=1000,anongid=1000

所以属主属组就显示的机器对应的1000id的用户。

 

14.1 NFS介绍 14.2 NFS服务端安装配置 14.3 NFS配置选项

标签:文件   监听端口   服务   实时   blank   port   abi   同步   磁盘   

原文地址:https://www.cnblogs.com/pta188/p/9211237.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!