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上的一致
总结:NFC服务需要借助RPC协议实现通信。
NFS服务端安装配置
实验需要2台机器,一台作为服务端,一台作为客户端。
服务端,安装2个包nfs-utils和rpcbind
[root@zyshanlinux-001 ~]# yum install -y nfs-utils rpcbind
Installed:
nfs-utils.x86_64 1:1.3.0-0.54.el7 rpcbind.x86_64 0:0.2.0-44.el7
客户端,安装包nfs-utils
[root@zyshanlinux-02 ~]# yum install -y nfs-utils
Installed:
nfs-utils.x86_64 1:1.3.0-0.54.el7
配置文件,允许共享主机IP
[root@zyshanlinux-001 ~]# vim /etc/exports
配置内容,就一行
/home/nfstestdir 192.168.106.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000)
保存配置文件后,执行如下准备操作
首先要创建分享的目录,给创建的目录赋予777的权限。
[root@zyshanlinux-001 ~]# mkdir /home/nfstestdir
[root@zyshanlinux-001 ~]# chmod 777 /home/nfstestdir
服务端启动rpcbind前后监听端口情况
[root@zyshanlinux-001 ~]# netstat -lnpt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1254/nginx: master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1086/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1325/master
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 1254/nginx: master
tcp6 0 0 :::22 :::* LISTEN 1086/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1325/master
tcp6 0 0 :::3306 :::* LISTEN 1447/mysqld
[root@zyshanlinux-001 ~]# systemctl start rpcbind
[root@zyshanlinux-001 ~]# netstat -lnpt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 46926/rpcbind
tcp 0 0 0.0.0.0:80 0.0.0.0:* L