RSYNC+SERSYNC2 file synchronization (based on centos6.5)

Source: Internet
Author: User

RSYNC+SERSYNC2 file synchronization


Environment: centos6.5


Software: RSYNC+SERSYNC2


Source server: 192.168.10.109

Sync Server: 192.168.10.107,192.168.10.108


Prerequisite work:


Turn off SELinux

Vi/etc/selinux/config


#SELINUX =enforcing

Modify

Selinux=disabled


Reboot system in effect


Iptables Open Port


Vi/etc/sysconfig/iptables

-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 873-j ACCEPT


Service Iptables Restart



Synchronizing Server Environment Configuration


Installation:

Yum-y Install Rsync

Configuration

Vi/etc/rsyncd.conf


Log file =/var/log/rsyncd.log

Pidfile =/var/run/rsyncd.pid

Lock file =/var/run/rsync.lock

Secrets file =/etc/rsync.passwd

MOTD file =/etc/rsyncd. Motd

[web]

Path =/web

Comment = Web

UID = www

GID = www

port=873

Use chroot = no

Read Only = no

List = no

Max connections = 200

Timeout = 600

Auth users = Sam

Hosts allow = 192.168.10.109


Create a password file

vi/etc/rsync.passwd


sam:tcg2015


Set file permissions


chmod 600/etc/rsync.passwd


chmod 600/etc/rsyncd.conf


Start the service:

Rsync--daemon--config=/etc/rsyncd.conf


Both synchronization servers are configured the same way



Source Server Environment Configuration:


Installation:

Yum-y Install Rsync


To see if the server kernel supports inotify

Ll/proc/sys/fs/inotify


-rw-r--r--1 root root 0 11:20 max_queued_events

-rw-r--r--1 root root 0 11:41 max_user_instances

-rw-r--r--1 root root 0 11:20 max_user_watches


modifying system default Parameters

Vi/etc/sysctl.conf

Added at the end:

fs.inotify.max_queued_events=99999999

fs.inotify.max_user_watches=99999999

fs.inotify.max_user_instances=65535


Effective immediately

Sysctl-p


Download Sersync


Https://sersync.googlecode.com/files/sersync2.5_64bit_binary_stable_final.tar.gz


Tar zxvf sersync2.5_64bit_binary_stable_final.tar.gz


Mkdir/usr/local/sersync

Mkdir/usr/local/sersync/log

Mkdir/usr/local/sersync/bin

Mkdir/usr/local/sersync/conf


CD gnu-linux-x86


CP confxml.xml/usr/local/sersync/conf/

CP sersync2/usr/local/sersync/conf/


Editing a configuration file

Vi/usr/local/sersync/conf/confxml.xml


<?xml version= "1.0" encoding= "Iso-8859-1"?>

<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= "/web" >

<remote ip= "192.168.10.107" name= "Web"/>

<remote ip= "192.168.10.108" name= "Web"/>

</localpath>

<rsync>

<commonparams params= "-auvzp"/>

<auth start= "true" users= "Sam" passwordfile= "/etc/rsync.passwd"/>

<userdefinedport start= "false" port= "874"/><!--port=874--

<timeout start= "false" Time= "" "/><!--timeout=100--

<ssh start= "false"/>

</rsync>

<faillog path= "/tmp/rsync_fail_log.sh" timetoexecute= "/><!--default every 60mins execute once-->

<crontab start= "false" schedule= "><!--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= "" "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>


To create a validation password file:

vi/etc/rsync.passwd

tcg2015


Modify file Permissions


chmod 600/etc/rsync.passwd


To fully synchronize the files once:

/usr/local/sersync/bin/sersync2-r-o/usr/local/sersync/conf/confxml.xml


Kill SERSYNC2 Process after synchronization is complete


Start process

/usr/local/sersync/bin/sersync2-d-o/usr/local/sersync/conf/confxml.xml


This article from the "linux& Cloud Computing" blog, reproduced please contact the author!

RSYNC+SERSYNC2 file synchronization (based on centos6.5)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.