实验环境
cat /etc/redhat-release && uname -a
CentOS Linux release 7.8.2003 (Core)
Linux centos7 3.10.0-1127.el7.x86_64
192.168.10.18 rsync1 rsync+sersync
192.168.10.15 rsync2 rsync
实验软件
sersync2.5.4_64bit_binary_stable_final.tar.gz
软件安装
yum install -y rsync xinetd rsync1/rsync2操作
systemctl daemon-reload
systemctl start xinetd && systemctl enable xinetd rsync1/rsync2操作
mkdir -pv /data/back && touch /data/back/{aa.txt,bb.txt}
touch /etc/rsync.passwd && echo 123 > /etc/rsync.passwd
chmod 600 /etc/rsync.passwd rsync1操作
mkdir -pv /data/db_back && touch /var/log/rsyncd.log
touch /etc/rsync.passwd && echo back:123 > /etc/rsync.passwd
chmod 600 /etc/rsync.passwd rsync2
cp -pv /etc/rsyncd.conf /etc/rsyncd.conf.bak && echo > /etc/rsyncd.conf
cat /etc/rsyncd.conf
uid = root
gid = root
address =192.168.10.15
port =873
hosts allow =192.168.10.0/24
use chroot = yes
max connections = 40
pid file =/var/run/rsyncd.pid
lock file =/var/run/rsync.lock
log file =/var/log/rsyncd.log
[db]
path = /data/db_back/
read only = no
auth users = back
secrets file =/etc/rsync.passwd
rsync --daemon --config=/etc/rsyncd.conf 启动服务rsync2操作
测试rsync同步
rsync -avz /data/back/ back@192.168.10.15::db --password-file=/etc/rsync.passwd
sending incremental file list
./
aa.txt
bb.txt rsync1操作 测试同步数据
ll /data/db_back/*.txt
/data/db_back/aa.txt
/data/db_back/bb.txt 同步数据测试成功 rsync2操作
tar zxvf sersync2.5.4_64bit_binary_stable_final.tar.gz
mv GNU-Linux-x86 /usr/local/sersync
ln -s /usr/local/sersync/sersync2 /usr/bin/
cp -pv /usr/local/sersync/confxml.xml /usr/local/sersync/confxml.xml.bak
cat /usr/local/sersync/confxml.xml
<sersync>
<localpath watch="/data/back/">
<remote ip="192.168.10.15" name="web"/>
<auth start="true" users="back" passwordfile="/etc/rsync.passwd"/>
sersync2 -d -r -o /usr/local/sersync/confxml.xml
set the system param
execute:echo 50000000 > /proc/sys/fs/inotify/max_user_watches
execute:echo 327679 > /proc/sys/fs/inotify/max_queued_events
parse the command param
option: -d run as a daemon
option: -r rsync all the local files to the remote servers before the sersync work
option: -o config xml name: /usr/local/sersync/confxml.xml
daemon thread num: 10
parse xml config file
host ip : localhost host port: 8008
daemon start,sersync run behind the console
use rsync password-file :
user is back
passwordfile is /etc/rsync.passwd
config xml parse success
please set /etc/rsyncd.conf max connections=0 Manually
sersync working thread 12 = 1(primary thread) + 1(fail retry thread) + 10(daemon sub threads)
Max threads numbers is: 22 = 12(Thread pool nums) + 10(Sub threads)
please according your cpu ,use -n param to adjust the cpu rate
------------------------------------------
rsync the directory recursivly to the remote servers once
working please wait...
execute command: cd /data/back && rsync -artuz -R --delete ./ back@192.168.10.15::db --password-file=/etc/rsync.passwd>/dev/null 2>&1
run the sersync:
watch path is: /data/back 启动sersync数据监听 rsync1操作
测试sersync同步数据
touch /data/back/test11.txt && ll /data/back/*.txt | wc -l
3 建立测试数据 rsync1操作
ll /data/db_back/*.txt | wc -l
3 同步数据rsync2操作
rm -rf /data/back/test11.txt && ll /data/back/*.txt | wc -l
2 删除测试数据 rsync1操作
ll /data/db_back/*.txt | wc -l
2 删除数据同步测试 rsync2操作
cp -pv /etc/rc.local /etc/rc.d/rc.local.bak
echo sersync2 -d -r -o /usr/local/sersync/confxml.xml >> /etc/rc.d/rc.local rsync1操作 设置开机启动
cp -pv /etc/rc.d/rc.local /etc/rc.d/rc.local.bak
echo rsync --daemon --config=/etc/rsyncd.conf >> /etc/rc.d/rc.local rsync2操作 设置开机启动
配置多个confxml.xml文件 www bbs blog
sersync2 -d -o /usr/local/sersync/blog_confxml.xml
sersync2 -d -o /usr/local/sersync/bbs_confxml.xml
netstat -tuplna | grep rsync
tcp 0 0 192.168.10.15:873 0.0.0.0:* LISTEN 1260/rsync
















