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 *\

相关推荐
0xDevNull2 天前
Linux切换JDK版本详细教程
linux
进击的丸子2 天前
虹软人脸服务器版SDK(Linux/ARM Pro)多线程调用及性能优化
linux·数据库·后端
Johny_Zhao3 天前
OpenClaw安装部署教程
linux·人工智能·ai·云计算·系统运维·openclaw
NineData3 天前
数据库迁移总踩坑?用 NineData 迁移评估,提前识别所有兼容性风险
数据库·程序员·云计算
chlk1235 天前
Linux文件权限完全图解:读懂 ls -l 和 chmod 755 背后的秘密
linux·操作系统
舒一笑5 天前
Ubuntu系统安装CodeX出现问题
linux·后端
改一下配置文件5 天前
Ubuntu24.04安装NVIDIA驱动完整指南(含Secure Boot解决方案)
linux
深紫色的三北六号5 天前
Linux 服务器磁盘扩容与目录迁移:rsync + bind mount 实现服务无感迁移(无需修改配置)
linux·扩容·服务迁移
SudosuBash5 天前
[CS:APP 3e] 关于对 第 12 章 读/写者的一点思考和题解 (作业 12.19,12.20,12.21)
linux·并发·操作系统(os)
哈基咪怎么可能是AI6 天前
为什么我就想要「线性历史 + Signed Commits」GitHub 却把我当猴耍 🤬🎙️
linux·github