NFS 是Network File System的缩写,即网络文件系统。一种使用于分散式文件系统的协定,
NFS 的基本原则是“容许不同的客户端及服务端通过一组RPC分享相同的文件系统”,它是独立于操作系统,容许不同硬件及操作系统的系统共同进行文件的分享。
NFS服务器搭建(192.168.16.128)
1,若防火墙未关闭,使用如下命令进行关闭
systemctl stop firewalld`
systemctl disable firewalld
2. 检查SELinux
[root@node2 ~]# cat /etc/selinux/config
SELINUX=disabled
3.安装nfs包
检查是否安装
rpm -qa | grep nfs
rpm -qa | grep rpcbind
# 安装nfs相关服务软件包
yum install nfs-utils
yum install rpcbind
4.配置nfs
vim /etc/exports
/nfs 192.168.16.*(rw,async,no_root_squash)
5.启动,自启服务,先rpbind再nfs
[root@mail ~]# systemctl enable rpcbind && systemctl start rpcbind
[root@mail ~]# systemctl enable nfs && systemctl restart nfs
6.使nfs配置生效
exportfs -r
# 查看服务状态
systemctl status rpcbind
systemctl status nfs
查看服务状态
systemctl status rpcbind
systemctl status nfs
rpcinfo -p ,如果显示rpc 服务器注册的端口列表(端口:111),则启动成功。
查看是否成功和可用的nfs地址:
# 查看可用的nfs地址
[root@node2 ~]# showmount -e localhost
NFS客户端配置(792.168.16.129)
#创建挂载的文件夹
mkdir -p /nfs/data
# showmount -e $(nfs服务器的IP)
showmount -e 192.168.16.128
挂载nfs
mount -t nfs 192.168.16.128:/nfs /nfs/data