linux开启 Sersync 守护进程进行数据同步

a、配置 Sersync 环境变量

[root@SERSYNC sersync]# echo 'export PATH=$PATH:/usr/local/sersync/bin'>>/etc/profile

[root@SERSYNC sersync]# tail -1 /etc/profile export PATH=$PATH:/usr/local/sersync/bin [root@SERSYNC sersync]# . /etc/profile [root@SERSYNC sersync]# which sersync

启动的过程及结果:

注意:我们这里要启动的是多实例,即 confxml.xml 和 download_confxml.xml

[root@SERSYNC ~]# ls /usr/local/sersync/conf/*

/usr/local/sersync/conf/confxml.xml

/usr/local/sersync/conf/confxml.xml.bak.2014-06-04

/usr/local/sersync/conf/download_confxml.xml

[root@SERSYNC ~]# sersync -r -d -o /usr/local/sersync/conf/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: -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 : localhosthost port: 8008

daemon start,sersync run behind the  console

use rsync password-file :

user isrsync_bak

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 thr eads)

Max threads numbers is: 32 = 12(Thread pool nums) + 20(Sub threads)

chmod: cannot access `/usr/local/logs/rsync_fail_log.sh': No such file or directory

------------------------------------------

rsync the directory recursivly to the remote servers once working please wait...

execute command: cd /data/web && rsync -aruz -R --delete ./ --timeout=100 rsync_bak

@172.16.100.1::web --password-file=/etc/rsync.password >/dev/null 2>&1

run the sersync:

watch path is: /data/web

[root@SERSYNC ~]# sersync -r -d -o /usr/local/sersync/conf/download_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: -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/download_confxml.xml

daemon thread num: 10

parse xml config file

host ip : localhosthost port: 8008

daemon start,sersync run behind the console

use rsync password-file :

user isrsync_bak

passwordfile is /etc/rsync.password config xml parse success

please set /etc/rsyncd.conf max connections=0 Manually

eads)

Max threads numbers is: 32 = 12(Thread pool nums) + 20(Sub threads)

please according your cpu ,use -n param to adjust the cpu rate

chmod: cannot access `/usr/local/logs/rsync_fail_log.sh': No such file or directory

------------------------------------------

rsync the directory recursivly to the remote servers once

working please wait...

execute command: cd /data/download && rsync -aruz -R --delete ./ --timeout=100 rsync

_bak@172.16.100.1::download --password-file=/etc/rsync.password >/dev/null 2>&1

run the sersync:

watch path is: /data/download

b、开启后查看进程

[root@SERSYNC ~]# ps -ef |grep sersync

root      2114     1 0 01:56 ?        00:00:00 sersync -r -d -o /usr/local/sersync/conf/confxml.

xml

root      2223     1 0 02:03 ?        00:00:00 sersync -r -d -o /usr/local/sersync/conf/downloa

d_confxml.xml

root      2295 2244 0 02:08 pts/2    00:00:00 grep sersync

C、配置开机自启动

[root@SERSYNC ~]# cp /etc/rc.local /etc/rc.local.bak._$(date +%F)

[root@SERSYNC ~]# cat >>/etc/rc.local<< 'EOF'

> # sync data to 172.16.100.1,172.16.100.2

> sersync -d -o /usr/local/sersync/conf/confxml.xml

> sersync -d -o /usr/local/sersync/conf/download_confxml.xml

> EOF

原文地址:https://www.cnblogs.com/fanweisheng/p/11327464.html