Live Sync Deamon

LSYNCD…

What is LSYNCD ?

LSYNCD is a Service which uses Rsync to sync the changes between 2 Directories in real time .

why to use LSYNCD ?

If you need to replicate data in some location to another one in a very short time.

example of usage :

if you need to create 2 load balanced replicated servers .

Installing LSYNCD on CENTOS:

The first step is to install yum atomic repository .

so follow the steps :

# cd /etc/yum.repos.d/

# touch atomic.repo

#vim atomic.repo

now paste these Lines int atomic.repo

# Name: Atomic Rocket Turtle RPM Repository for CentOS / Red Hat Enterprise Linux 6 –
# URL: http://www.atomicrocketturtle.com/
# Note: This isn’t covered by ASL support. -Scott
[atomic]
name = CentOS / Red Hat Enterprise Linux $releasever – atomicrocketturtle.com
mirrorlist = http://www.atomicorp.com/mirrorlist/atomic/centos-6-$basearch
#mirrorlist = http://www.atomicorp.com/channels/atomic/centos/6/mirrors-atomic
enabled = 1
priority = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY.art.txt
gpgcheck = 1

# Almost Stable, release candidates for [atomic]
# Note these are not supported by anyone. -Scott
[atomic-testing]
name = CentOS / Red Hat Enterprise Linux $releasever – atomicrocketturtle.com – (Testing)
mirrorlist = http://www.atomicorp.com/mirrorlist/atomic-testing/centos-6-$basearch
enabled = 1
priority = 1
protect = 0
gpgcheck = 0

after saving the file you have to install the LSYNCD using yum.

yum -y install LSYNCD

now you have the LSYNCD installed on your machine.

we have to write the configuration file now.

so we will create the configuration file in /etc/lsyncd

#mkdir /etc/lsyncd

#vim /etc/lsyncd/NAME.conf

now write the following:

sync{
default.rsync,
source=”/Source/Full/Path/”,
target=”/Destination/Full/path/”,
delay=0,#this is the time delay between the change and the sync trigger
rsyncOpts={“–delete”,”-az”,”-o”,”-g”},#normal Rsync Options
logfile = ‘/var/log/lsyncd.log’#this is the log file
}

to Execute the lsyncd Service

#lsyncd /etc/lsyncd/NAME.conf

if you need to execute LSYNCD through the network then you need to setup a no password ssh session from the master node to the slave node.

and then write a configuration file as shown below

sync{
default.rsync,
source=”/Source/Full/Path/”,
target=”192.168.1.2:/Destination/Full/path/”,
delay=0,#this is the time delay between the change and the sync trigger
rsyncOpts={“–delete”,”-az”,”-o”,”-g”},#normal Rsync Options
logfile = ‘/var/log/lsyncd.log’#this is the log file
}

Assume 192.168.1.2 the target Machine IP.

This is the only difference between the local and the network sync.

Regards,

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s