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

相关推荐
hu1j1 天前
[HTB] 靶机学习(十二)Eureka
学习·安全·web安全·网络安全·云原生·eureka
jzhwolp1 天前
nginx epoll 里黑科技位运算+指针复用
linux·nginx·架构
NON-JUDGMENTAL1 天前
在 Ubuntu 上安装 Ollama 并通过 Open WebUI 运行本地大语言模型
linux·ubuntu·语言模型
ZzzZZzzzZZZzzzz…1 天前
RHCSA---权限管理
linux·运维·权限管理·特殊权限·rhcsa·acl权限·权限掩码原理
TinyPiXOS开发者联盟1 天前
轻量级嵌入式系统的 Lottie 动画实现
linux·c++·动画·嵌入式开发·lottie·tinypixos·tpgui
海蓝可知天湛1 天前
Ubuntu24.10禁用该源...+vmware无法复制黏贴“天坑闭环”——从 DNS 诡异解析到 Ubuntu EOL 引发的 apt 404排除折
linux·ubuntu
SoulKuyan1 天前
android su执行命令
linux·运维·服务器
Zhao_yani1 天前
Centos 7安装Apache Drill
linux·centos·drill
一叶飘零_sweeeet1 天前
Linux 安装 Elasticsearch:避坑指南 + 性能调优实战
linux·运维·elasticsearch
梁正雄1 天前
linux-shell-基础与变量和运算符-1
linux·运维