NFS缺点NFS是一种基于TCP/IP传输的网络文件系统协议;
通过使用NFS协议,客户机可以像访问本地目录一样访问远程服务器中的共享资源;
对于大多数负载均衡群集来说,使用NFS协议来共享数据存储是比较常见的方法,NFS也是NAS存储设备必然支持的一种协议;
开始搭建==》 服务端配置NFS没有用户认证机制,而且数据在网络上明文传输,所以安全性很差,一般只在局域网中使用
- rpc与nfs的安装
#检查是否安装--安装了会输入版本信息,空白则是未安装 rpm -qa nfs-utils rpcbind
安装了输入如下:
- 安装命令
yum -y install rpcbind nfs-utils
- 查看运行状态
systemctl status rpcbind systemctl status nfs
- 启动rpc服务并设置开机自动启动
systemctl start rpcbind systemctl enable rpcbind
- 启动nfs服务并设置开机自动启动
systemctl start nfs systemctl enable nfs
- 创建共享目录并授权
cd /usr/local mkdir file chmod 777 /usr/local/file
- 修改/etc/exports,配置共享信息,注:(172.30.130.11 为服务端IP)
vi /etc/exports /usr/local/file 172.30.130.11/24(rw,sync,no_root_squash)
补充:
ro:代表只读,rw:代表读写;
sync:代表同步的将数据写入到内存与硬盘中;
async:代表异步的先将数据保存到内存,然后再写入硬盘;
no_root_squash:表示当客户机以root身份访问时赋予本地root权限(默认是root_squash;
root_squash:表示客户机用root用户访问更改共享目录时,将root用户映射成匿名用户;
- 重新加载NFS服务,使配置文件生效
systemctl reload nfs exportfs -r
- 检验服务端是否配置成功
showmount -e客户端配置
- rpc与nfs的安装
yum -y install rpcbind nfs-utils
- 检查是都否看到服务端的挂载信息,注:(172.30.130.11 为服务端IP)
showmount -e 172.30.130.11
- 创建目录
同服务端一样,在相同位置创建好目录 cd /usr/local mkdir file chmod 777 /usr/local/file
- 挂载,注:(172.30.130.11 为服务端IP)
mount -t nfs 172.30.130.11:/usr/local/file /usr/local/file
- 查看挂载信息,检验是否挂载成功
df -h常见问题:
如果客户端挂载不上,可能是防火墙的原因;
rpcbind服务默认使用111端口,请开启端口或关闭防火墙;



