sersync多站点主主同步部署
站点目录:
A端:/home/www/web1/,/home/www/web2/
B端:/home/www/web1/,/home/www/web2/
启动测试命令:rsync --daemon
A组测试命令:
rsync -avzp /home/www/web1/ [email protected]::web1/ --password-file=/etc/rsync.password
rsync -avzp /home/www/web2/ [email protected]::web2/ --password-file=/etc/rsync.password
A组执行命令:
/usr/local/sersync/bin/sersync -d -o /usr/local/sersync/conf/confxml_web1.xml
/usr/local/sersync/bin/sersync -d -o /usr/local/sersync/conf/confxml_web2.xml
B组测试命令:
rsync -avzp /home/backup/web1/ [email protected]::web1/ --password-file=/etc/rsync.pass
rsync -avzp /home/backup/web1/ [email protected]::web2/ --password-file=/etc/rsync.pass
B组执行命令
/usr/local/sersync/bin/sersync -d -o /usr/local/sersync/conf/confxml_web1.xml
/usr/local/sersync/bin/sersync -d -o /usr/local/sersync/conf/confxml_web2.xml
ps -ef |grep sersync 查看两个站点进程是否同步
创建密码文件:权限必须是600
A端创建:vim /etc/rsync.password jesse
A端创建:vim /etc/rsync.pass rsync_backup:jesse
B端创建:vim /etc/rsync.password jesse
B端创建:vim /etc/rsync.pass rsync_backup:jesse
A和B目录结构:
/usr/local/sersync
[root@izm5e5ynf23pd7w4j5ie7xz sersync]# tree
├── bin
│ └── sersync
├── conf
│ ├── confxml_web1.xml
│ └── confxml_web2.xml
└── logs
└── rsync_fail_log.sh
A端配置confxml_web1.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
2 <head version="2.5">
3 <host hostip="localhost" port="8008"></host>
4 <debug start="false"/>
5 <fileSystem xfs="false"/>
6 <filter start="false">
7 <exclude expression="(.*)\.svn"></exclude>
8 <exclude expression="(.*)\.gz"></exclude>
9 <exclude expression="^info/*"></exclude>
10 <exclude expression="^static/*"></exclude>
11 </filter>
12 <inotify>
13 <delete start="true"/>
14 <createFolder start="true"/>
15 <createFile start="true"/>
16 <closeWrite start="true"/>
17 <moveFrom start="true"/>
18 <moveTo start="true"/>
19 <attrib start="true"/>
20 <modify start="true"/>
21 </inotify>
22
23 <sersync>
24 <localpath watch="/home/backup/web1">
25 <remote ip="116.85.23.X" name="web1"></remote>
26 </localpath>
27 <rsync>
28 <commonParams params="-artuz"/>
29 <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/>
30 <userDefinedPort start="false" port="874"/><!-- port=874 -->
31 <timeout start="false" time="100"/><!-- timeout=100 -->
32 <ssh start="false"/>
33 </rsync>
34 <failLog path="/usr/local/sersync/logs/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once-->
35 <crontab start="false" schedule="600"><!--600mins-->
36 <crontabfilter start="false">
37 <exclude expression="*.php"></exclude>
38 <exclude expression="info/*"></exclude>
39 </crontabfilter>
40 </crontab>
41 <plugin start="false" name="command"/>
42 </sersync>
43
44 <plugin name="command">
45 <param prefix="/bin/sh" suffix="" ignoreError="true"/> <!--prefix /opt/tongbu/mmm.sh suffix-->
46 <filter start="false">
47 <include expression="(.*)\.php"/>
48 <include expression="(.*)\.sh"/>
49 </filter>
50 </plugin>
51
52 <plugin name="socket">
53 <localpath watch="/opt/tongbu">
54 <deshost ip="192.168.138.20" port="8009"/>
55 </localpath>
56 </plugin>
57 <plugin name="refreshCDN">
58 <localpath watch="/data0/htdocs/cms.xoyo.com/site/">
59 <cdninfo domainname="ccms.chinacache.com" port="80" username="xxxx" passwd="xxxx"/>
60 <sendurl base="http://pic.xoyo.com/cms"/>
61 <regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/>
62 </localpath>
63 </plugin>
64 </head>
B端配置confxml_web1.xml:
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <head version="2.5">
3 <host hostip="localhost" port="8008"></host>
4 <debug start="false"/>
5 <fileSystem xfs="false"/>
6 <filter start="false">
7 <exclude expression="(.*)\.svn"></exclude>
8 <exclude expression="(.*)\.gz"></exclude>
9 <exclude expression="^info/*"></exclude>
10 <exclude expression="^static/*"></exclude>
11 </filter>
12 <inotify>
13 <delete start="true"/>
14 <createFolder start="true"/>
15 <createFile start="true"/>
16 <closeWrite start="true"/>
17 <moveFrom start="true"/>
18 <moveTo start="true"/>
19 <attrib start="true"/>
20 <modify start="true"/>
21 </inotify>
22
23 <sersync>
24 <localpath watch="/home/backup/web1">
25 <remote ip="47.104.154.X" name="web1"/>
26 </localpath>
27 <rsync>
28 <commonParams params="-artuz"/>
29 <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.pass"/>
30 <userDefinedPort start="false" port="874"/><!-- port=874 -->
31 <timeout start="false" time="100"/><!-- timeout=100 -->
32 <ssh start="false"/>
33 </rsync>
34 <failLog path="/usr/local/sersync/logs/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once-->
35 <crontab start="false" schedule="600"><!--600mins-->
36 <crontabfilter start="false">
37 <exclude expression="*.php"></exclude>
38 <exclude expression="info/*"></exclude>
39 </crontabfilter>
40 </crontab>
41 <plugin start="false" name="command"/>
42 </sersync>
43
44 <plugin name="command">
45 <param prefix="/bin/sh" suffix="" ignoreError="true"/> <!--prefix /opt/tongbu/mmm.sh suffix-->
46 <filter start="false">
47 <include expression="(.*)\.php"/>
48 <include expression="(.*)\.sh"/>
49 </filter>
50 </plugin>
51
52 <plugin name="socket">
53 <localpath watch="/opt/tongbu">
54 <deshost ip="192.168.138.20" port="8009"/>
55 </localpath>
56 </plugin>
57 <plugin name="refreshCDN">
58 <localpath watch="/data0/htdocs/cms.xoyo.com/site/">
59 <cdninfo domainname="ccms.chinacache.com" port="80" username="xxxx" passwd="xxxx"/>
60 <sendurl base="http://pic.xoyo.com/cms"/>
61 <regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/>
62 </localpath>
63 </plugin>
64 </head>
sersync多站点主主同步部署
猜你喜欢
转载自blog.csdn.net/weixin_36171533/article/details/81100641
今日推荐
周排行