[root@localhost src]
[root@localhost src]
[root@localhost src]
[root@localhost sersync]
confxml.xml sersync2
[root@localhost sersync]
[root@localhost sersync]
<?xml version=
"1.0"
encoding=
"ISO-8859-1"
?>
<
head
version=
"2.5"
>
<host hostip=
"localhost"
port=
"8008"
><
/host
>
<debug start=
"true"
/>
<fileSystem xfs=
"false"
/>
<filter start=
"false"
>
<exclude expression=
"(.*)\.svn"
><
/exclude
>
<exclude expression=
"(.*)\.gz"
><
/exclude
>
<exclude expression=
"^info/*"
><
/exclude
>
<exclude expression=
"^static/*"
><
/exclude
>
<
/filter
>
<inotify>
<delete start=
"true"
/>
<createFolder start=
"true"
/>
<createFile start=
"false"
/>
<closeWrite start=
"true"
/>
<moveFrom start=
"true"
/>
<moveTo start=
"true"
/>
<attrib start=
"false"
/>
<modify start=
"false"
/>
<
/inotify
>
<sersync>
<localpath
watch
=
"/app/rsync_client"
>
<remote ip=
"10.15.43.100"
name=
"app_rsync_server"
/>
<!--<remote ip=
"192.168.8.39"
name=
"tongbu"
/>-->
<!--<remote ip=
"192.168.8.40"
name=
"tongbu"
/>-->
<
/localpath
>
<
rsync
>
<commonParams params=
"-artuz"
/>
<auth start=
"true"
users
=
"rsync"
passwordfile=
"/etc/rsyncd.secret"
/>
<userDefinedPort start=
"false"
port=
"874"
/><!-- port=874 -->
<timeout start=
"false"
time
=
"100"
/><!-- timeout=100 -->
<
ssh
start=
"false"
/>
<
/rsync
>
<failLog path=
"/tmp/rsync_fail_log.sh"
timeToExecute=
"60"
/><!--default every 60mins execute once-->
<
crontab
start=
"true"
schedule=
"600"
><!--600mins-->
<crontabfilter start=
"false"
> #如果开启了filter文件过滤功能,那么
crontab
整体同步也需要设置过滤,否则虽然实时同步的时候文件被过滤了,但
crontab
整体同步的时候 如果不单独设置crontabfilter,还会将需过滤的文件同步到远程,
<exclude expression=
"*.php"
><
/exclude
> #
crontab
的过滤正则与filter过滤的不同,果同时开启了filter与
crontab
,则要开启
crontab
的crontabfilter,并按示例设置使其与filter的过滤一一对应。
<exclude expression=
"info/*"
><
/exclude
>
<
/crontabfilter
>
<
/crontab
>
<plugin start=
"false"
name=
"command"
/> #当设置为
true
的时候,将文件同步到远程服务器后会调用name参数指定的插件。
<
/sersync
>
<plugin name=
"command"
>
<param prefix=
"/bin/sh"
suffix=
""
ignoreError=
"true"
/> <!--prefix
/opt/tongbu/mmm
.sh suffix-->
<filter start=
"false"
>
<include expression=
"(.*)\.php"
/>
<include expression=
"(.*)\.sh"
/>
<
/filter
>
<
/plugin
>
<plugin name=
"socket"
>
<localpath
watch
=
"/opt/tongbu"
>
<deshost ip=
"192.168.138.20"
port=
"8009"
/>
<
/localpath
>
<
/plugin
>
<plugin name=
"refreshCDN"
>
<localpath
watch
=
"/data0/htdocs/cms.xoyo.com/site/"
>
<cdninfo domainname=
"ccms.chinacache.com"
port=
"80"
username=
"xxxx"
passwd
=
"xxxx"
/>
<sendurl base="
<regexurl regex=
"false"
match=
"cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"
/>
<
/localpath
>
<
/plugin
>
<
/head
>
[root@localhost sersync]
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: -n thread num is: 8
option: -o config xml name:
/app/sersync/confxml
.xml
parse xml config
file
host ip : localhost host port: 8008
Open debug, you will see debug infomation
daemon start,sersync run behind the console
Start the
crontab
Every 600 minutes
rsync
all the files to the remote servers entirely
use
rsync
password-
file
:
user is
rsync
passwordfile is
/etc/rsyncd
.secret
config xml parse success
please
set
/etc/rsyncd
.conf max connections=0 Manually
sersync working thread 10 = 1(primary thread) + 1(fail retry thread) + 8(daemon sub threads)
Max threads numbers is: 18 = 10(Thread pool nums) + 8(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
/app/rsync_client
&&
rsync
-artuz -R --delete ./
rsync
@10.15.43.100::app_rsync_server --password-
file
=
/etc/rsyncd
.secret
crontab
command
:
cd
/app/rsync_client
&&
rsync
-artuz -R --delete ./
rsync
@10.15.43.100::app_rsync_server --password-
file
=
/etc/rsyncd
.secret
run the sersync:
watch
path is:
/app/rsync_client
add
watch
:
/app/rsync_client
return
wd is: 1
add
watch
:
/app/rsync_client/test
return
wd is: 2
[root@localhost sersync]