背景说明
在做系统集群部署时,涉及到两个或多个服务器之间文件同步.在软件层面linux服务环境找到以下两种同步方式
- 利用linux NFS功能将网络共享文件挂载成本地目录
- 采用文件监听,实时推送
服务器资源如下
- 服务器1 10.2.4.51 ,作为主服务器
- 服务器2 10.2.4.52 ,作为从服务器
2 NFS网络共享配置
2.1 主服务器
2.1.1 安装应用包
yum install -y nfs-utils rpcbind #nfs安装命令
systemctl enable nfs #将nfs设置开机启动
systemctl enable rpcbind #将rpcbind设置开机启动
2.1.2 共享配置
主服务建立需要共享的文件夹
mkdir /home/nfs_data # 主服务需要共享的目录
配置从服务可以访问主服务器
vi /etc/exports #author: herbert qq:1234
设置内容为
/home/nfs_data/ 10.2.4.52(rw,sync,no_root_squash)
重启服务,注意一定要先启动 rpcbind
systemctl stop nfs
systemctl stop rpcbind
systemctl start rpcbind
systemctl start nfs
showmount -e # 可以检查NFS配置是否生效
# 配置正确后,会有一下提示信息
Export list for hk51:
/home/nfs