sersync2 双向准实时同步配置

张映 发表于 2021-03-31

分类目录: 服务器相关

标签:,

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

1,下载安装sersync2

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

2,配置sersync2

  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="false"/>  
  20.  <modify start="false"/>  
  21.  </inotify>  
  22.   
  23.  <sersync>  
  24.  <localpath watch="/mail/data">  
  25.  <remote ip="10.0.10.8" name="iredmail"/>  
  26.  </localpath>  
  27.  <rsync>  
  28.  <commonParams params="-artuz"/>  
  29.  <auth start="true" users="iredmail_attachment" passwordfile="/etc/rsyncd/passwd"/>  
  30.  <userDefinedPort start="false" port="874"/>  
  31.  <timeout start="false" time="100"/>  
  32.  <ssh start="false"/>  
  33.  </rsync>  
  34.  <failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/>  
  35.  <crontab start="false" schedule="600">  
  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. </head>  

在这里要注意:

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

3,创建自启动脚本

  1. root@mail1:/usr/local/sersync2# cat start.sh  
  2. #!/bin/sh  
  3. /usr/local/sersync2/sersync2 -r -o /usr/local/sersync2/c.xml > /usr/local/sersync2/sersync2.log  
  4.   
  5. root@mail1:/usr/local/sersync2# cat stop.sh  
  6. #!/bin/sh  
  7. ps aux |grep sersync2 | kill -9 `awk 'NR>1{print line}{line=$2}'`  
  8.   
  9. root@mail1:/usr/local/sersync2# cat /usr/lib/systemd/system/sersync2.service  
  10. [Unit]  
  11. Description=sersync  
  12. After=syslog.target network.target remote-fs.target nss-lookup.target  
  13.   
  14. [Service]  
  15. Type=simple  
  16. TimeoutSec=300  
  17. ExecStart=/usr/local/sersync2/start.sh  
  18. ExecStop=/usr/local/sersync2/stop.sh  
  19. Restart=on-failure  
  20. PrivateTmp=true  
  21.   
  22. [Install]  
  23. WantedBy=multi-user.target  
  24.   
  25. #systemctl start sersync2  //启动  

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

 

 



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