<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>RoAkSoAx's Weblog &#187; tool</title>
	<atom:link href="http://www.roaksoax.com/tag/tool/feed" rel="self" type="application/rss+xml" />
	<link>http://www.roaksoax.com</link>
	<description>My Personal Blog</description>
	<lastBuildDate>Tue, 07 Sep 2010 14:17:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Cluster Sinchronization Tool (CSync2)</title>
		<link>http://www.roaksoax.com/2008/06/cluster-sinchronization-tool-csync2</link>
		<comments>http://www.roaksoax.com/2008/06/cluster-sinchronization-tool-csync2#comments</comments>
		<pubDate>Fri, 20 Jun 2008 22:45:00 +0000</pubDate>
		<dc:creator>roaksoax</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Planet]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[cluster]]></category>
		<category><![CDATA[csync2]]></category>
		<category><![CDATA[synchronization]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://roaksoax.wordpress.com/?p=35</guid>
		<description><![CDATA[As you may know, there are many tools for file synchronization between servers that can suit your needs, but Csync2 (Website and Paper) was specially designed for Cluster File Synchronization, which makes it a great tool to synchronize config files and folders. Now, I&#8217;ll show you a simple way of configuring it, by having a [...]]]></description>
			<content:encoded><![CDATA[<p>As you may know, there are many tools for file synchronization between servers that can suit your needs, but<em> Csync2 (<a href="http://oss.linbit.com/csync2/" target="_blank">Website</a> and <a href="http://oss.linbit.com/csync2/paper.pdf" target="_blank">Paper</a>)</em> was specially designed for Cluster File Synchronization, which makes it a great tool to synchronize config files and folders.</p>
<p>Now, I&#8217;ll show you a simple way of configuring it, by having a master server (where we can make changes to the config files) and one or multiple slave servers, where the files will be synchronized. First of all, we have to install it along with other packages:</p>
<blockquote><p>:~# sudo apt-get install csync2 sqlite3 openssl xinetd</p></blockquote>
<p>After having everything installed, we have to create the certificates that will allow <em>Csync2</em> authenticate between servers so that the files can be synchronized. To do that we do this:</p>
<p><span id="more-35"></span></p>
<blockquote><p>:~# openssl genrsa -out /etc/csync2_ssl_key.pem 1024</p></blockquote>
<blockquote><p>:~# openssl req -new -key /etc/csync2_ssl_key.pem -out /etc/csync2_ssl_cert.csr</p></blockquote>
<blockquote><p>:~# openssl x509 -req -days 600 -in /etc/csync2_ssl_cert.csr -signkey /etc/csync2_ssl_key.pem -out /etc/Csync2_ssl_cert.pem</p></blockquote>
<p>So after having all the certificates, we have to create the <em>Csync2</em> key by issuing the following:</p>
<blockquote><p>:~# csync2 -k /etc/csync2_ssl_cert.key</p></blockquote>
<p>Once all the keys and certificates have been generated, we have to copy them from the master server to the slaves. To do this we can use whatever method you are more familiarized with.</p>
<p>Now, we have to configure<em> xinetd</em> so that Csync2 can work, because it works as an <em>xinetd</em> service. To do this we create a <em>Csync2</em> file on <strong><em>/etc/xinetd.d/</em></strong> and edit it like this:</p>
<blockquote><p>:~# vim /etc/xinetd.d/Csync2</p></blockquote>
<blockquote><p>service Csync2<br />
{<br />
disable = no<br />
protocol = tcp<br />
socket_type = stream<br />
wait = no<br />
user = root<br />
server = /usr/sbin/csync2<br />
server_args = -i<br />
}</p></blockquote>
<p>and then we have to add the port number to <strong><em>/etc/services</em></strong>, by doing this:</p>
<blockquote><p>:~# echo &#8220;Csync2 30865/tcp&#8221; &gt;&gt; /etc/services</p></blockquote>
<p>After having done everything, we are now going to configure<em> Csync2 </em>so that we can determine which files are going to be synchronized. For this example, we are going to synchronize <em><strong>/etc/apache2</strong></em> and <em><strong>/etc/mysql</strong></em>. For that we open /etc/csync2.cfg and we configure it like this:</p>
<blockquote><p>group testing #group name, we can have multiple groups<br />
{<br />
host node1; #master server<br />
host (node2); #slave server<br />
host (node3);</p>
<p>key /etc/csync2_ssl_cert.key;</p>
<p>include /etc/apache2/;<br />
include /etc/mysql/;</p>
<p>backup-directory /var/backups/csync2;<br />
backup-generations 3;<br />
auto none; #no automatic sync<br />
}</p></blockquote>
<p><strong>Note:</strong> This tool does not just synchronize files but issues commands (such as restarting services) after the synchronization process is finished, but, I&#8217;ll let you find out how <img src='http://www.roaksoax.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . We can also have multiple groups with different servers on it. For further information you can refer to its <a href="http://oss.linbit.com/csync2/paper.pdf" target="_blank">Paper</a>.</p>
<p>Then, we create the <em>Csync2</em> backup directory:</p>
<blockquote><p>:~# mkdir /var/backups/csync2</p></blockquote>
<p>and we restart <em>xinetd</em>:</p>
<blockquote><p>:~# /etc/init.d/xinetd restart</p></blockquote>
<p>And finally, we do the first sync by issuing:</p>
<blockquote><p>:~# csync -x</p></blockquote>
<p>If errors are displayed here, just ignore them and check if the files have been synchronized. Every time we make a changes to the files in <strong><em>/etc/apache2</em></strong> or <em><strong>/etc/mysql</strong></em> on the master server, we have to synchronize the changes by issuing the command above.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.roaksoax.com/2008/06/cluster-sinchronization-tool-csync2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
