NFS介绍、NFS服务端安装配置、NFS配置选项

NFS服务搭建与配置

NFS介绍

NFS是Network File System的缩写

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

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

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

NFS是Network File System的缩写

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

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

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

NFS服务端安装配置

yum install -y nfs-utils rpcbind
vim /etc/exports //加入如下内容
/home/nfstestdir 192.168.133.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000)
保存配置文件后,执行如下准备操作
mkdir /home/nfstestdir
chmod 777 /home/nfstestdir
systemctl start rpcbind 
systemctl start nfs
systemctl enable rpcbind 
systemctl enable nfs
//安装nfs服务端
[root@24centos7-14 /]# yum install -y nfs-utils rpcbind
[root@24centos7-14 /]# vim /etc/exports
添加以下代码
/home/nfstestdir 10.0.0.*(rw,sync,all_squash,anonuid=1000,anongid=1000)


[root@24centos7-14 /]# mkdir /home/nfstestdir
[root@24centos7-14 /]# chmod 777 /home/nfstestdir
[root@24centos7-14 /]# systemctl start rpcbind
[root@24centos7-14 /]# ps aux | grep rpcbind
rpc       2423  0.0  0.0  64964  1044 ?        Ss   21:33   0:00 /sbin/rpcbind -w
root      2569  0.0  0.0 112680   984 pts/0    S+   21:54   0:00 grep --color=auto rpcbind
[root@24centos7-14 /]# systemctl start nfs
[root@24centos7-14 /]# ps aux | grep nfs
root      2618  0.0  0.0      0     0 ?        S<   21:54   0:00 [nfsd4_callbacks]
root      2624  0.0  0.0      0     0 ?        S    21:54   0:00 [nfsd]
root      2625  0.0  0.0      0     0 ?        S    21:54   0:00 [nfsd]
root      2626  0.0  0.0      0     0 ?        S    21:54   0:00 [nfsd]
root      2627  0.0  0.0      0     0 ?        S    21:54   0:00 [nfsd]
root      2628  0.0  0.0      0     0 ?        S    21:54   0:00 [nfsd]
root      2629  0.0  0.0      0     0 ?        S    21:54   0:00 [nfsd]
root      2630  0.0  0.0      0     0 ?        S    21:54   0:00 [nfsd]
root      2631  0.0  0.0      0     0 ?        S    21:54   0:00 [nfsd]
root      2635  0.0  0.0 112680   980 pts/0    R+   21:54   0:00 grep --color=auto nfs
[root@24centos7-14 /]# systemctl enable rpcbind
[root@24centos7-14 /]# systemctl enable nfs
Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.

NFS配置选项

rw 读写
ro 只读
sync 同步模式,内存数据实时写入磁盘
async 非同步模式
no_root_squash 客户端挂载NFS共享目录后,root用户不受约束,权限很大
root_squash 与上面选项相对,客户端上的root用户收到约束,被限定成某个普通用户
all_squash 客户端上所有用户在使用NFS共享目录时都被限定为一个普通用户
anonuid/anongid 和上面几个选项搭配使用,定义被限定用户的uid和gid
标签:NFS 发布于:2019-10-25 13:17:22