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, handle file deletions and can detect conflicts. It is expedient for HA-clusters, HPC-clusters, COWs and server farms.


root@node1:~# apt-get install csync2
root@node1:~# openssl genrsa -out csync2_ssl_key.pem 2048
root@node1:~# openssl req -new -x509 -days 365 -key csync2_ssl_key.pem -out csync2_ssl_cert.pem
root@node2:~# apt-get install csync2
root@node2:~# openssl genrsa -out csync2_ssl_key.pem 2048
root@node2:~# openssl req -new -x509 -days 365 -key csync2_ssl_key.pem -out csync2_ssl_cert.pem
root@node3:~# apt-get install csync2
root@node3:~# openssl genrsa -out csync2_ssl_key.pem 2048
root@node3:~# openssl req -new -x509 -days 365 -key csync2_ssl_key.pem -out csync2_ssl_cert.pem


root@node1:~# more /etc/csync2.cfg
#nossl * *;

group web
	host node1;
	host node2;
	host node3;

	key /etc/csync2_web.key;

	include /etc/csync2.cfg;
	include /etc/nginx/sites-enabled/;
	include %wwwdir%;
	exclude %wwwdir%/.*/awstats/.*;
	exclude %wwwdir%/.*/logs/.*;
	exclude %wwwdir%/.*/tmp/.*;

		pattern /etc/nginx/sites-enabled/*;
		exec "/etc/init.d/nginx reload";
		logfile "/var/log/csync2/action.log";

	#backup-directory /var/backups/csync2;
	#backup-generations 2;

	auto first;

prefix wwwdir
	on node1: /var/www;
	on node2: /var/www;
	on node3: /home/www;
root@node1:~# csync2 -k /etc/csync2_web.key
root@node1:~# scp /etc/csync2.cfg /etc/csync2_web.key node2:/etc node3:/etc

Lancement de la synchronisation

root@node1:~# csync2 -rxv
root@node1:~# csync2 -xv