How to Set Up Real-Time Data Sync with Sersync and Rsync on CentOS
This guide walks through configuring two CentOS 7.7 hosts for real-time data synchronization using Sersync and Rsync, covering environment preparation, service deployment, configuration file editing, manual testing, daemon startup, and automatic startup via rc.local.
1. Network Introduction
Two hosts are used for the experiment: qll251 as the Rsync server and Sersync server, and qll252 as the Rsync client. Both run CentOS 7.7, with the firewall disabled and SELinux set to disabled.
# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
# systemctl stop firewalld && systemctl disable firewalld
# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
# reboot
# getenforce
Disabled2. Deployment
On the source host (qll251) deploy Sersync and Rsync services
Download the Sersync binary package:
# wget https://sersync.googlecode.com/files/sersync2.5.4_64bit_binary_stable_final.tar.gzExtract the package and rename the directory:
# tar -zxvf sersync2.5.4_64bit_binary_stable_final.tar.gz
# mv GNU-Linux-x86/ sersync2.5.4Edit /root/sersync2.5.4/confxml.xml to set the local backup path, remote IP (192.168.1.252), and authentication parameters:
<sersync>
<localpath watch="/data">
<remote ip="192.168.1.252" name="web"/>
</localpath>
<rsync>
<commonParams params="-artuz"/>
<auth start="true" users="rsync_user" passwordfile="/etc/rsync.mypass"/>
</rsync>
</sersync>Create the local backup directory and the Rsync password file:
# mkdir /data
# echo 123123 > /etc/rsync.mypass
# chmod 600 /etc/rsync.mypassInstall and start Rsync and Xinetd services:
# yum -y install rsync xinetd
# systemctl start rsyncd && systemctl enable rsyncd
# systemctl start xinetd && systemctl enable xinetdOn the client host (qll252) deploy the Rsync client
# yum -y install rsyncEdit /etc/rsyncd.conf with the following key settings:
uid = root
gid = root
address = 192.168.1.252
port = 873
hosts allow = 192.168.1.0/24
use chroot = yes
max connections = 5
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
motd file = /etc/rsyncd.motd
[web]
path = /mybak
comment = used for mysql-data
read only = false
list = yes
auth users = rsync_user
secrets file = /etc/rsync.passwdCreate the destination directory and the password file for the client:
# mkdir /mybak
# echo "rsync_user:123123" > /etc/rsync.passwd
# chmod 600 /etc/rsync.passwdStart the Rsync daemon with the custom configuration:
# rsync --daemon --config=/etc/rsyncd.conf
# echo "rsync --daemon --config=/etc/rsyncd.conf" >> /etc/rc.local3. Start Sersync Daemon for Data Sync
Perform a manual sync to verify the environment:
# rsync -avz /data [email protected]::web --password-file=/etc/rsync.mypassAfter confirming success, launch the Sersync daemon:
# /root/sersync2.5.4/sersync2 -d -r -o /root/sersync2.5.4/confxml.xmlReal‑time synchronization can be observed on both machines.
To enable automatic start after reboot, add the daemon command to /etc/rc.local and ensure both /etc/rc.local and /etc/rc.d/rc.local are executable:
# chmod +x /etc/rc.d/rc.local
# rebootWith these steps, the two hosts achieve continuous, real‑time data synchronization using Sersync and Rsync.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
