[root@salt-client01 src]
[root@salt-client01 src]
[root@salt-client01 src]
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: -r rsync all the local files to the remote servers before the sersync work
option: -d run as a daemon
option: -o config xml name: /usr/local/sersync/conf/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 rsync_body
passwordfile is /etc/rsync.password
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 && rsync -artuz -r --delete ./ --timeout=100 rsync_body@192.168.91.166::data --password-file=/etc/rsync.password >/dev/null 2>&1
run the sersync:
watch path is: /data
[root@salt-client01 log]
/usr/local/sersync/log
[root@salt-client01 log]
[root@salt-client01 log]
[root@salt-client01 ~]
#!/bin/bash
sersync="/usr/local/sersync/bin/sersync2"
conf_file="/usr/local/sersync/conf/confxml.xml"
status=$(ps aux |grep 'sersync2'|grep -v 'grep'|wc -l)
if [ $status -eq 0 ];
then
$sersync -d -r -o $conf_file &
else
exit 0;
fi
脚本写好以后,添加到计划任务中去
*/1 * * * * /bin/bash /usr/local/sersync/log/rsync_fail_log.sh > /dev/null 2>&1
测试同步:
客户端新增文件
[root@salt-client01 data]
[root@salt-client01 data]
total 4
-rw-r--r-- 1 root root 1928 nov 10 18:15 192.168.91.156.passwd
-rw-r--r-- 1 root root 0 nov 10 17:27 3
服务端检测
[root@salt-master data]
[root@salt-master data]
total 8
-rw-r--r-- 1 root root 1928 nov 10 18:15 192.168.91.156.passwd
-rw-r--r-- 1 root root 0 nov 10 17:27 3
drwxr-xr-x 2 root root 4096 nov 10 17:27 data
客户端测试删除
[root@salt-client01 data]
rm: cannot remove `rf': no such file or directory
rm: remove regular file `192.168.91.156.passwd'? y
[root@salt-client01 data]
total 0
-rw-r--r-- 1 root root 0 nov 10 17:27 3
[root@salt-client01 data]
服务器端:
[root@salt-master data]
total 4
-rw-r--r-- 1 root root 0 nov 10 17:27 3
drwxr-xr-x 2 root root 4096 nov 10 17:27 data