sersync
- sersync是基于inotify开发的,类似于inotify-tools的工具
- sersync可以记录下被监听目录中发生变化的(包括增加、删除、修改)具体某一个文件或者某一个目录的名字,然后使用rsync同步的时候,只同步发生变化的文件或者目录
静态数据的同步
##rsync.conf config start
uid = root
gid = root
use chroot = no
max connetctions = 200
timeout = 100
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
ignore errors
read only = false
list = false
hosts allow = 192.168.30.128
auth users = rsync_backup
secrets file = /etc/rsync.password
[backup]
comment = backup
path = /tmp/sync_data
##rsync config end
配置密码文件。
echo "rsync_backup:rsync.conf">/etc/rsync.password
chmod 600 /etc/rsync.password
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
rsync 2367 root 3u IPv4 23180 0t0 TCP *:rsync (LISTEN)
rsync 2367 root 5u IPv6 23181 0t0 TCP *:rsync (LISTEN)
[root@sources ~]# chmod 600 /etc/rsync.password
[root@sources ~]# rsync -avzP /etc/hosts rsync_backup@192.168.30.129::backup --password-file=/etc/rsync.password
sending incremental file list
hosts
278 100% 0.00kB/s 0:00:00 (xfer#1, to-check=0/1)
sent 173 bytes received 27 bytes 400.00 bytes/sec
total size is 278 speedup is 1.39
GNU-Linux-x86/
GNU-Linux-x86/sersync2
GNU-Linux-x86/confxml.xml
[root@sources sersync]# cd /usr/local/sersync
[root@sources sersync]# mkdir -p conf bin logs
[root@sources sersync]# mv confxml.xml conf
[root@sources sersync]# mv sersync2 bin/sersync
[root@sources sersync]# echo 'export PATH=$PATH:/usr/local/sersync/bin'>>/etc/profile
[root@sources sersync]# source /etc/profile
[root@sources sersync]# which sersync
/usr/local/sersync/bin/sersync
<localpath watch="/tmp/sync_data"> # 定义本地要同步的目录
<remote ip="192.168.30.129" name="backup"/> # 同步到哪台机器上 backup模块rsync端模块名字
</localpath>
<commonParams params="-artuz"/>
<auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/>
<userDefinedPort start="false" port="874"/><!-- port=874 -->
<timeout start="true" time="100"/><!-- timeout=100 -->
<ssh start="false"/>
</rsync>
<failLog path="/usr/local/sersync/logs/rsync_fail_log.sh" timeToExecute="60"/>
1.第一,由于使用的centos7.而centos7默认采用的是xfs文件系统。虽然xfs好像同步也正常的,但是在confxml.xml其实是用启用xfs文件系统的。。默认是false。
<fileSystem xfs="false"/>
2.第二,遇见了同步失败。直接贴错误吧。(该错误在/usr/local/sersync/logs/rsync_fail_log.sh)
[root@sources sync_data]# rsync -artuz -R --timeout=100 ./www root@192.168.30.129::backup --password-file=/etc/rsync.password
@ERROR: auth failed on module backup
rsync error: error starting client-server protocol (code 5) at main.c(1516) [sender=3.0.9]
错误代码1516行。但是死活最后发现,是root@。。。 这就错了,需要改上面说的用户认证那里。
<auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/>