ansible sersync

 

第一步: 配置rysnc 服务端: 

backup 服务器上安装

统一 配置虚拟用户 www 

rsync命令详解(rsync实时备份) rsync -avz (rsync安装)-白眉大叔 (baimeidashu.com)

第2步: 配置 客户端

要监控的文件

密码文件必须是这个:

[root@nfs /]#cat /etc/rsync.pas 
123456

 

sersync + rsync 实现linux 的实时同步-白眉大叔 (baimeidashu.com)

 

an'sible: 配置文件: 

[root@m01 /etc/ansible/roles/sersync/tasks]#cat main.yml 
- name: install inotify-tools
  yum:
    name:  inotify-tools
    state: present
- name: mkdir /server
  file:
    path: /server
    state: directory
- name: unarchive  serync.tar.gz
  unarchive:
    src: sersync2.5.4_64bit_binary_stable_final.tar.gz
    dest: /server/
   

- name: copy confxml.xml
  copy: 
    src: confxml.xml
    dest: /server/GNU-Linux-x86/

- name: create rsync password
  shell:
     cmd: echo '123456' > /etc/rsync.pas

   
- name: change mode  /etc/rsync.pas
  shell: 
    cmd: chmod 600 /etc/rsync.pas
- name: run sersync
  shell:
    cmd: /server/GNU-Linux-x86/sersync2 -dro /server/GNU-Linux-x86/confxml.xml

 

 

sersync2.5.4_64bit_binary_stable_final.tar.gz:

https://url69.ctfile.com/f/253469-848663146-dc88cd?p=2206  (访问密码: 2206)

 

confxml.xml

 

[root@m01 /etc/ansible/roles/sersync/files]#cat confxml.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="/code">
	    <remote ip="172.16.1.41" name="backup"/>
	    <!--<remote ip="192.168.8.39" name="tongbu"/>-->
	    <!--<remote ip="192.168.8.40" name="tongbu"/>-->
	</localpath>
	<rsync>
	    <commonParams params="-avz"/> 
	    <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.pas"/>
	    <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="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="/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="http://pic.xoyo.com/cms"/>
	    <regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/>
	</localpath>
    </plugin>
</head>

 

欢迎来撩 : 汇总all

白眉大叔

关于白眉大叔linux云计算: 白眉大叔

热门文章