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

相关推荐
longerxin202017 小时前
在 Linux 上使用 SCP 将文件传输到 Windows(已开启 SSH)
linux·运维·ssh
王正南20 小时前
kali-linux 虚拟机连接安卓模拟器
android·linux·运维·虚拟机连接模拟器·安卓模拟器,linux虚拟机
吳所畏惧21 小时前
Linux环境/麒麟V10SP3下离线安装Redis、修改默认密码并设置Redis开机自启动
linux·运维·服务器·redis·中间件·架构·ssh
yueguangni21 小时前
sysstat 版本 10.1.5 是 CentOS 7 的默认版本,默认情况下确实不显示 %wait 字段。需要升级到新版sysstat
linux·运维·centos
萧曵 丶1 天前
Linux 业务场景常用命令详解
linux·运维·服务器
AKAMAI1 天前
分布式边缘推理正在改变一切
人工智能·分布式·云计算
豆是浪个1 天前
Linux(Centos 7.6)命令详解:ps
linux·windows·centos
Run_Teenage1 天前
Linux:深刻理解缓冲区
linux
youxiao_901 天前
kubernetes 概念与安装(一)
linux·运维·服务器
凡梦千华1 天前
logrotate日志切割
linux·运维·服务器