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

相关推荐
轩Scott12 分钟前
Ubuntu开机卡Logo?NVIDIA驱动修复全攻略
linux·ubuntu
佳杰云星23 分钟前
如何给大模型集群选“大脑”?智算调度与管理平台 10 维选型指南(附选型评分表)
人工智能·kubernetes·大模型·云计算·gpu·算力调度·智算中心
西柚小萌新26 分钟前
【计算机常识】--Ngrok在Linux上内网穿透详细教程
linux·运维·服务器
Irissgwe27 分钟前
一、网络基础概念
linux·网络·websocket·网络协议·socket·linux网络编程
红茶要加冰1 小时前
linux的例行性工作——计划任务
linux·运维·服务器
漠效1 小时前
阿里云上的ICP备案和公安联网备案
阿里云·云计算
byxdaz1 小时前
Linux中查看硬件信息
linux·运维
darkdragonking2 小时前
由一次构建 OpenEuler 22.03 dnf源所了解到的
linux·运维·服务器
米高梅狮子2 小时前
Ceph 分布式存储 部署
linux·运维·数据库·分布式·ceph·docker·华为云
easy_coder2 小时前
面向诊断场景的云产品知识库设计方案
人工智能·云计算