2018-04-13 web-jiqun►分布式集群 Sersync+Rsync互相实时同步 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311、关闭selinux2、防火墙(iptables、Firewalld)放行873端口(默认)3、安装Rsync服务yum install rsync -yuseradd -r -s /sbin/nologin rsync -Mcat > /etc/rsyncd.conf <<EOFuid = rsyncgid = rsyncuse chroot = noport = 873address = 192.168.230.10max connections = 2000timeout = 200log file = /var/run/rsyncd.logpid file = /var/run/rsyncd.pidlock file = /var/run/rsyncd.locklog format = %t %a %m %f %b[rsync]path = /home/wwwroot/test/commemt = rsynclist = yesread only = no#write only = noauth users = homeusersecrets file = /etc/rsyncd.secretignore errors = yeshosts allow = 192.168.250.101hosts deny =EOFread only 指定是否允许客户上传文件。若为 true 则不允许上传;若为 false 并且服务器目录也具有读写权限则允许上传。 truewrite only 指定是否允许客户下载文件。若为 true 则不允许下载;若为 false 并且服务器目录也具有读权限则允许下载。 falseread only 默认值true 不允许上传,只能读;false 可写(可上传),是否可读取决于write onlywrite only 默认值false 可读而且可下载;true 不允许下载,是否可写取决于read onlycat > /etc/rsyncd.secret <<EOFhomeuser:test123EOFchmod 600 /etc/rsyncd.secretcat > /etc/rsyncd.pass <<EOFtest123EOFchmod 600 /etc/rsyncd.passmkdir -p /home/wwwroot/testchown rsync.rsync -R /home/wwwroot/testsystemctl enable rsyncdsystemctl start rsyncd4、安装Sersync服务wget http://panel.ropon.top/rsync/sersync.zipunzip sersync.zip -C /usr/local/tar xf sersync.zip -C /usr/local/cat //usr/local/sersync/config.xml<?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="false"/><closeWrite start="true"/><moveFrom start="true"/><moveTo start="true"/><attrib start="false"/><modify start="false"/></inotify><sersync><localpath watch="/home/wwwroot/test"><remote ip="192.168.250.101" name="rsync"/><!--<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="homeuser" passwordfile="/etc/rsyncd.pass"/><userDefinedPort start="false" port="873"/><!-- 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="false" schedule="600"><!--600mins--><crontabfilter start="false"><exclude expression="*.php"></exclude><exclude expression="info/*"></exclude></crontabfilter></crontab><plugin start="false" name="command"/></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="/home/wwwroot/test/"><deshost ip="192.168.250.101" 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="http://pic.xoyo.com/cms"/><regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/></localpath></plugin></head>cat /etc/rc.local/usr/local/sersync/sersync2 -d -r -o /usr/local/sersync/confxml.xmlB服务器同理注意开机启动项cd /home/wwwroot/test && rsync -artuz -R --delete homeuser@192.168.230.10::rsync ./ --password-file=/etc/rsyncd.pass/usr/local/sersync/sersync2 -d -r -o /usr/local/sersync/confxml.xml Newer nfs高可用 Older Mysql bin-log日志设置自动清理及如何手工清理