Rsync+lsync implementation of triggered real-time synchronization

Source: Internet
Author: User
Tags rsync

Use Rsync+lsync implement triggered real-time synchronization

Server information

centos6.5

Main: 192.168.5.4 Build Lsync

from: 192.168.5.3 Build rsync

1.1 from server settings

# yum-y Install rsync xinetd# cp/etc/xinetd.d/rsync/etc/xinetd.d/rsync.blk# Vim/etc/xinetd.d/rsync# Default:off# description:the Rsync server is a good addition to an FTP server, as it \# allows CRC Checksumming etc.Service Rsync{        Disable = no→ Modify 'Yes 'as 'No '        flags = ipv6→Modify 'IPv6 'as 'IPv4 '        Socket_type = Stream        wait = no        user = root        Server =/usr/bin/rsync        Server_args =--daemon        log_on_failure + = USERID}1.2.Startxinetdand set the boot entry. 

# service XINETD Start

# Chkconfig xinetd on

1.3. Create a storage directory for synchronized files.

# Mkdir/home/backup

1.4. Create a rsyncd.conf profile.

# vim/etc/rsyncd.conf

[Backup] → name Any

Path =/home/backup → synchronizing file storage paths

hosts allow = 192.168.5.4→ Allow connected hosts (specify the primary server IP )

Hosts deny = *

List = True

UID = root

GID = root

Read Only = False

2. master server settings .

2.1. Installing rsync.

# yum-y Install rsync

2.2. Create a synchronization object, a list of files that do not need to be synchronized.

# Vim/etc/rsync_exclude.lst

Xx

Xx.txt

2.3. on the primary server, execute the following command .

testing the master server /data/ The following files are synchronized to the slave server /home/backup

# Rsync-avz--delete--exclude-from=/etc/rsync_exclude.lst/data 192.168.5.3::backup

3. using Rsync + lsync, when the file or directory changes, you can do real-time synchronization.

3.1. log in to the master server and download the installation lsync.

# RPM-IVH http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

# yum Install Lsyncd-y

3.2. Configure the lsyncd file.

# CP/ETC/SYSCONFIG/LSYNCD/ETC/SYSCONFIG/LSYNCD.BLK

# VIM/ETC/SYSCONFIG/LSYNCD

# Keep The space there for SYSTEMD. Don ' t nest variables without

# Changing the SYSTEMD service file to use:/usr/bin/sh-c ' eval XXXX '

#

lsyncd_options= "-pidfile/var/run/lsyncd.pid/etc/lsyncd.conf" → Remove ' # '

#LSYNCD_OPTIONS = ""

3.3. Configure lsyncd.conf, add the following:

# vim/etc/lsyncd.conf

settings{

Statusfile = "/tmp/lsyncd.stat",

Statusinterval = 1,

}

sync{

Default.rsync,

source= "/data", → Specify the source file directory to be synchronized

target= "192.168.5.3::backup", → Slave Server IP: (rsyncd.conf Set the name )

excludefrom= "/etc/rsync_exclude.lst", → exclude file list

}

3.4. start lsync.

#/ETC/RC.D/INIT.D/LSYNCD Start

# Chkconfig LSYNCD on

3.5. on the primary server, create a new test file.

data]# Touch XX

3.6. on confirmation from the server , synchronization succeeded.

# Ls/home/backup



Rsync+lsync implementation of triggered real-time synchronization

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.