Recent unit live more, so very little update, at night the internet happened to see an introduction about Sersync, personal feeling more standard than rsync+inotify configuration, just recently preface, summed up under, share to everyone.
The current industry more reliable synchronization solutions are:
Rsync+inotify-tools,openduckbill+inotify-tools and Rsync+sersync
The first two are written based on scripting language, so the specification level, execution efficiency is slightly weaker than Rsync+sersync.
Sersync is written using C + +, based on boost1.43.0,inotify api,rsync command development, mainly for server synchronization, Web mirroring and other functions. It can filter the temporary files generated by Linux system file system and duplicate file operation, so it saves running time and network resources when it is synchronized with rsync. So faster and more suitable for online use.
This blog is to realize the real-time synchronization of the data under the Sersync push/data to the/data directory of Rsync receiver, and realize the mirror server of rsync server as Sersync
Note: When using Rsync+crontab to do timing synchronization, the main server to open the Rsync daemon, and the mirror server is running rsync client, usually use crontab timing to get the data on the rsync server.
But when using Rsync+sersync to do real-time synchronization, the server used to push the files runs the Sersync service, and the server that receives the files runs the rsync daemon, simply Sersync uses the rsync command to push the files to the rsync server. The actual use of the online will generally take the Sersync as the primary server, rsync as a mirror server, data synchronization backup, Web mirroring and other functions
Solution:
Operating system: centos6.3 x86
Rsync:centos Self-band Yum source
Sersync:sersync2.5_32bit
Sersync Push Delivery End 192.168.100.74
Rsync receiving End 192.168.100.29
Environment Construction: (receiving end, push end)
First, close SELinux and iptables
# Vi/etc/sysconfig/selinux
---------
Selinux=disabled
---------
# Setenforce 0
# Service Iptables Stop
Before using Sersync, we must install the rsync server.
Rsync (receiving end)
One. Install Rsync (centos6.3 installed by default)
# yum Install Rsync-y
# yum Install Xinetd-y
Two. Start Rsync dependency Service
#/etc/init.d/xinetd Start
# Chkconfig xinetd on
Three. Configuration:
# vi/etc/rsyncd.conf
--------------------
UID = root
GID = root
Use chroot = no
Max connections = 10
Strict modes = yes
Port = 873
Address = 192.168.100.29
[Data] # rsync module name, later configured Sersync will use
Path =/data # This synchronization directory is provided by the user with write permissions as specified by the UID
Comment = Mirror for test
Ignore errors
Read Only = no
List = no
Auth users = user
Secrets file =/etc/rsync.pas # password Authentication files, must be 600 permissions, otherwise rsync transmission will be an error
Hosts allow = *
# hosts Deny = 0.0.0.0/0
PID file =/var/run/rsyncd.pid
Lock file =/var/run/rsync.lock
Log file =/var/log/rsyncd.log
--------------------