User:Daemon/Sandbox/csync2

From Gentoo Wiki
Jump to:navigation Jump to:search

csync2 is a tool for asynchronous file synchronization in clusters.

Installation

USE flags

USE flags for sys-cluster/csync2 Cluster synchronization tool

mysql Add mySQL Database support
postgres Add support for the postgresql database
sqlite Add support for sqliteembedded sql database
ssl Add support for SSL/TLS connections (Secure Socket Layer / Transport Layer Security)
xinetd Add support for the xinetd super-server

Emerge

root #emerge --ask --oneshot sys-cluster/csync2

Configuration

Create ssl certificates for transfers

root #emerge --config sys-cluster/csync2

Create key for authentication with peers

root #csync2 -k /etc/csync2/csync2.key_mygroup

Setup synchronization

FILE /etc/csync2/csync2.cfg
group mygroup
{
	host hostname1 host2_ip (hostname3); # (hostname3) can only download changes. - #
	key /etc/csync2/csync2.key_mygroup;  # Identical file for all in group. - #

	include /mnt/shared;                 # Same list for all. - #
	exclude /mnt/shared/local*;
}

Things to note

  • All nodes (of a group) share a common key, for example /etc/csync2/csync2.key_mygroup. This means it has to be copied to each node.
  • The shared folder paths need to be identical for all nodes (of a group). The configuration file need not be identical.
  • Although the host parameter requires the actual hostname (or ip) to be used, it seems to work according to the /etc/hosts file.
    • The following command shows what csync2 sees as hostname:
    • root #csync2 -Tvv |& head

OpenRC

To enable the service to run at system boot:

root #rc-update add csync2 default

To start the daemon now:

root #rc-service csync2 start

Usage

Sample parameters

        -x [-d] [[-r] file..]   Run checks for all given files and update
                                remote hosts.
        -d      Dry-run on all remote update operations
        -P peer1,peer1,...
                Only update these peers (still mark all as dirty).
                Only show files for these peers in -o (compare) mode.
        -f [-r] file..          Force files to win next conflict resolution.
        -r      Recursive operation over subdirectories.
        -M      List all dirty files from status db.

Invocation

  • Update all with this one:
    • root #csync2 -x
  • Dry-run an update towards hostname3:
    • root #csync2 -P hostname3 -xd
    • Increased verbosity:
      • root #csync2 -P hostname3 -xdvvvvv
  • Force local files onto others:
    • root #csync2 -fr /mnt/shared/force_these
      root #csync2 -x

Troubleshooting

See also

  • git — distributed revision control and source code management software.
  • rsync — a powerful file sync program capable of efficient file transfers and directory synchronization.

External resources