Csync2

From CBLFS
Jump to: navigation, search
Download Source: http://oss.linbit.com/csync2/csync2-1.34.tar.gz

Contents

Introduction to Csync2

Csync2 is a cluster synchronization tool. It can be used to keep files on multiple hosts in a cluster in sync. Csync2 can handle complex setups with much more than just 2 hosts, file deletions, and conflicts.

Project Homepage: http://oss.linbit.com/csync2/

Dependencies

Required

Recommended

Configuration Information

--disable-gnutls: Build without gnutls support.

Non-Multilib

Compile the package:

./configure --prefix=/usr --sysconfdir=/etc/csync2 &&
make

Install the package:

make install

Multilib

32Bit

Compile the package:

CC="gcc ${BUILD32}" ./configure --prefix=/usr --sysconfdir=/etc/csync2 &&
make

Install the package:

make install

N32

Compile the package:

CC="gcc ${BUILDN32}" ./configure --prefix=/usr \
    --libdir=/usr/lib32 --sysconfdir=/etc/csync2 &&
make

Install the package:

make install

64Bit

Compile the package:

CC="gcc ${BUILD64}" ./configure --prefix=/usr \
    --libdir=/usr/lib64 --sysconfdir=/etc/csync2 &&
make

Install the package:

make install

Configuring

Create a key to share among the nodes of your cluster. Copy this key to each node running csync2.

csync2 -k <keyname>.key

The file /etc/csync2/csync2.cfg is used to setup the behavior of csync2 on your cluster. A sample csync2.cfg is installed, but you should read the documentation at http://oss.linbit.com/csync2/paper.pdf for details.

Assuming you have three nodes with hostnames of aragorn, legolas, and frodo, the following is an example of the csync2.cfg file.

# Keep aragorn and legolas in sync.  
# frodo and legolas only receive changes.
# aragorn sends changes to the other two hosts.
# You can have multiple groups in one cfg file.
group aragorn_legolas
{
       host aragorn;
       host (frodo);
       host (legolas);

       key /etc/clusterfsck.key;

   # Configuration files to keep synchronized.
       include /etc/csync2/csync2.cfg;
       include /etc/vimrc;
       include /etc/colors;
       include /etc/logrotate.conf;

   # Executables (scripts) to keep synchronized.
       include /usr/sbin/LinkCheck;

   # Directories to keep synchronized.
       include /shared_stuff/;
       include %homedir%/weibullguy;

   # Excluded items.
       exclude *~ .*;
       exclude /shared_stuff/;

   # What action to take when the csync2.cfg file is synced.
   # Execute the mailer script to send me an e-mail.
   # Log this action in the csync2 log file.
       action
       {
               pattern /etc/csync2/csync2.cfg;
               exec "/etc/csync2/mailer";
               logfile "/var/log/csync2_action.log";
               do-local;
       }

   # Create backups.
#       backup-directory /var/backups/csync2;
#       backup-generations 3;

       auto none;
}

# The homedir variable on frodo and legolas (hosts 2 and 3)
# is different than it is on all other hosts (only aragorn in this case).
prefix homedir
{
       on host[23]: /home/users;
       on *:        /home;
}

Add the following as a cron job to keep all the node in sync.

# Synchronize cluster nodes every day at 12:30 am.
30 00 * * * /usr/sbin/csync2 -x -r

Contents

Installed Directories: /etc/csync2, /var/lib/csync2
Installed Programs: csync2, csync2-compare
Installed Libraries: None

Short Descriptions

csync2 is a cluster synchronization tool.
csync2-compare is a utility to compare host synchronization.
Personal tools