Rsync + Sersync 实时数据同步方案

方案架构

  • 源服务器:部署 Sersync(监控文件变化) + Rsync(推送数据)
  • 目标服务器:部署 Rsync Daemon(接收数据)
  • 同步逻辑:源服务器文件变动 → Sersync 实时触发 → Rsync 增量同步至目标服务器

详细实施步骤

一、目标服务器配置(数据接收端)

  1. 安装 Rsync

bash

yum install rsync -y # CentOS

apt install rsync -y # Ubuntu

  1. 创建 Rsync 配置文件

bash

vim /etc/rsyncd.conf

ini

uid = root

gid = root

use chroot = no

max connections = 2000

pid file = /var/run/rsyncd.pid

lock file = /var/run/rsync.lock

log file = /var/log/rsyncd.log

data_backup\] # 模块名称(客户端同步时指定) path = /data/backup # 同步目录 comment = Backup Directory read only = no # 允许写入 auth users = rsync_user # 认证用户 secrets file = /etc/rsync.password # 密码文件 3. **创建认证文件** bash echo "rsync_user:your_password" \> /etc/rsync.password chmod 600 /etc/rsync.password 4. **创建同步目录** bash mkdir -p /data/backup chown -R rsync_user:rsync_user /data/backup 5. **启动 Rsync 守护进程** bash systemctl start rsyncd systemctl enable rsyncd 6. **开放防火墙端口** bash firewall-cmd --add-port=873/tcp --permanent firewall-cmd --reload *** ** * ** *** **二、源服务器配置(数据发送端)** 1. **安装 Rsync** bash yum install rsync -y *# CentOS* apt install rsync -y *# Ubuntu* 2. **创建 Rsync 密码文件** bash echo "your_password" \> /etc/rsync.password chmod 600 /etc/rsync.password 3. **测试手动同步** bash rsync -avz /source/data/ rsync_user@目标服务器IP::data_backup --password-file=/etc/rsync.password * **作用**:验证配置正确性,确保网络和权限正常。 3. **安装 Sersync** bash wget https://github.com/wsgzao/sersync/raw/master/sersync2.5.4_64bit_binary_stable_final.tar.gz tar -zxvf sersync2.5.4_64bit_binary_stable_final.tar.gz -C /opt/ mv /opt/GNU-Linux-x86/ /opt/sersync 5. **修改 Sersync 配置文件** bash vim /opt/sersync/confxml.xml xml *\

相关推荐
有谁看见我的剑了?8 小时前
linux 添加硬盘后系统识别不到硬盘处理
linux·运维·服务器
yc_12249 小时前
用 Visual Studio 远程调试 Linux:从零到流畅的完整指南
linux·ide·visual studio
瞎某某Blinder10 小时前
DFT学习记录[6]基于 HES06的能带计算+有效质量计算
python·学习·程序人生·数据挖掘·云计算·学习方法
计算机安禾10 小时前
【Linux从入门到精通】第31篇:防火墙漫谈——iptables与firewalld防护指南
linux·运维·php
下一页盛夏花开10 小时前
ubuntu 20中安装QT以后出现红色空心断点
linux·运维·ubuntu
sanshanjianke11 小时前
Thunderobot 911ME 笔记本 Linux 风扇控制研究
linux
fengyehongWorld14 小时前
TeraTerm ttl脚本登录wsl
linux·teraterm
2401_8734794014 小时前
企业安全团队如何配合公安协查?IP查询在电子取证中的技术实践
tcp/ip·安全·网络安全·php
乌托邦的逃亡者14 小时前
Linux中如何检测IP冲突
linux·运维·tcp/ip
一曦的后花园14 小时前
linux搭建promethes并对接node-exporter指标
linux·运维·服务器