sersync2 双向准实时同步配置

张映 发表于 2021-03-31

分类目录: 服务器相关

标签:,

利用heartbeat,mysql replication,rsync,sersync2实现邮件的高可用。本篇只说一下,sersync2实现邮件和附件的准实时同步。

1,下载安装sersync2

# wget -c https://github.com/wsgzao/sersync/blob/master/sersync2.5.4_64bit_binary_stable_final.tar.gz
# tar zxvf sersync2.5_64bit_binary_stable_final.tar.gz
# mv GNU-Linux-x86 /usr/local/sersync2

2,配置sersync2

<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5">
 <host hostip="localhost" port="8008"></host>
 <debug start="false"/>
 <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="true"/>
 <closeWrite start="true"/>
 <moveFrom start="true"/>
 <moveTo start="true"/>
 <attrib start="false"/>
 <modify start="false"/>
 </inotify>

 <sersync>
 <localpath watch="/mail/data">
 <remote ip="10.0.10.8" name="iredmail"/>
 </localpath>
 <rsync>
 <commonParams params="-artuz"/>
 <auth start="true" users="iredmail_attachment" passwordfile="/etc/rsyncd/passwd"/>
 <userDefinedPort start="false" port="874"/>
 <timeout start="false" time="100"/>
 <ssh start="false"/>
 </rsync>
 <failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/>
 <crontab start="false" schedule="600">
 <crontabfilter start="false">
 <exclude expression="*.php"></exclude>
 <exclude expression="info/*"></exclude>
 </crontabfilter>
 </crontab>
 <plugin start="false" name="command"/>
 </sersync>
</head>

在这里要注意:

/mail/data 是邮件路径
/tmp/rsync_fail_log.sh 这是个自动生成

3,创建自启动脚本

root@mail1:/usr/local/sersync2# cat start.sh
#!/bin/sh
/usr/local/sersync2/sersync2 -r -o /usr/local/sersync2/c.xml > /usr/local/sersync2/sersync2.log

root@mail1:/usr/local/sersync2# cat stop.sh
#!/bin/sh
ps aux |grep sersync2 | kill -9 `awk 'NR>1{print line}{line=$2}'`

root@mail1:/usr/local/sersync2# cat /usr/lib/systemd/system/sersync2.service
[Unit]
Description=sersync
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=simple
TimeoutSec=300
ExecStart=/usr/local/sersync2/start.sh
ExecStop=/usr/local/sersync2/stop.sh
Restart=on-failure
PrivateTmp=true

[Install]
WantedBy=multi-user.target

#systemctl start sersync2  //启动

4,测试,在/mail/data目录创建文件和目录,看会不会同步

 

 



转载请注明
作者:海底苍鹰
地址:http://blog.51yip.com/server/2510.html