<?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; How-To</title>
	<atom:link href="http://www.roaksoax.com/category/ubuntu/how-to/feed" rel="self" type="application/rss+xml" />
	<link>http://www.roaksoax.com</link>
	<description>My Personal Blog</description>
	<lastBuildDate>Wed, 28 Jul 2010 23:48:43 +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>Installing DRBD on Hardy Part 2.</title>
		<link>http://www.roaksoax.com/2008/08/installing-drbd-on-hardy-part-2</link>
		<comments>http://www.roaksoax.com/2008/08/installing-drbd-on-hardy-part-2#comments</comments>
		<pubDate>Mon, 04 Aug 2008 05:58:01 +0000</pubDate>
		<dc:creator>roaksoax</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Planet]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[DRBD]]></category>
		<category><![CDATA[heartbeat]]></category>
		<category><![CDATA[meatware]]></category>
		<category><![CDATA[stonith]]></category>
		<category><![CDATA[ubuntu hardy]]></category>

		<guid isPermaLink="false">http://roaksoax.wordpress.com/?p=82</guid>
		<description><![CDATA[As you know, in a previous post I showed how to install DRBD in Hardy Heron, in an active/passive configuration. Now, I&#8217;m gonna show you how to install and configure Heartbeat to automatically monitor this active/passive configuration, and provide High Availability. This means I&#8217;ll show you how to integrate DRBD in a simple Heartbeat V1 [...]]]></description>
			<content:encoded><![CDATA[<p>As you know, in a <a href="http://roaksoax.wordpress.com/2008/07/31/installing-drbd-on-hardy/">previous post</a> I showed <a href="http://roaksoax.wordpress.com/2008/07/31/installing-drbd-on-hardy/">how to install DRBD in Hardy Heron</a>, in an active/passive configuration. Now, I&#8217;m gonna show you how to install and configure <a href="http://www.linux-ha.org">Heartbeat</a> to automatically monitor this active/passive configuration, and provide High Availability. This means I&#8217;ll show you how to integrate <a href="http://www.drbd.org">DRBD</a> in a simple <a href="http://www.linux-ha.org">Heartbeat</a> V1 configuration, and as a plus, I&#8217;ll show you how to use the meatware software provided by <a href="http://www.linux-ha.org/STONITH">STONITH</a>.</p>
<p>To do this, we have to install <a href="http://www.linux-ha.org">Heartbeat</a> and make changes in three files, which are<strong><em> /etc/ha.d/ha.cf</em></strong>, <em><strong>/etc/ha.d/haresources</strong></em> and <em><strong>/etc/ha.d/authkeys</strong></em>. First of all we install <a href="http://www.linux-ha.org">Heartbeat</a> as follows, in both nodes:</p>
<blockquote><p><code>sudo apt-get install heartbeat-2</code></p></blockquote>
<p>After the installation is completed, the first file we need to configure, in both nodes, is <em><strong>/etc/ha.d/ha.cf</strong></em> as follows:</p>
<blockquote><p><code>logfile /var/log/ha-log<br />
keepalive 2<br />
deadtime 30<br />
udpport 695<br />
bcast eth0<br />
auto_failback off<br />
node drbd1 drbd2</code></p></blockquote>
<p><strong>Note: </strong>Notice that the <em><strong>auto_failback</strong></em> option is in <strong><em>off</em></strong>. This means that if the drbd1 fails, drbd2 will take control over the service, and if <em><strong>drbd1</strong></em> comes back online, <strong><em>drbd2</em></strong> will not failback to <strong><em>drbd1</em></strong> and <strong><em>drbd2</em></strong> will remain as the active node.</p>
<p>Now, as you know this is an active/passive configuration, so we have to decide which node is going to be the primary and which node is going to be the secondary one, for the <a href="http://www.linux-ha.org">Heartbeat</a> configuration. (If you have followed my previous post, the<strong><em> drbd1</em></strong> node is going to be our primary node, and <em><strong>drbd2</strong></em> will be our secondary node). We also have to consider here is where are we going to mount the DRBD resource in our filesystem, and which IP address is going to used as the VIP (The Virtual IP is going to be used to access a service, or a DRBD resource, over the network, since we are going to use <a href="http://www.drbd.org">DRBD</a> for NFS and/or MySQL).</p>
<p>So, assuming <strong><em>drbd1</em></strong> is the primary node, the VIP is <strong><em>172.16.0.135</em></strong> and we are going to mount the <a href="http://www.drbd.org">DRBD</a> resource in <strong><em>/data</em></strong> (so create the directory in both nodes), we edit <strong><em>/etc/ha.d/haresources</em></strong> as follows, in both nodes:</p>
<blockquote><p><code>drbd1  IPaddr::172.16.0.135/24/eth0 drbddisk::testing Filesystem::/dev/drbd0::/data::ext3</code></p></blockquote>
<p><strong>Note: </strong>Notice that we are specifying the <a href="http://www.drbd.org">DRBD</a> resource with the <strong><em>drbddisk</em></strong> option.</p>
<p>Then, we have to edit the <strong><em>/etc/ha.d/authkeys</em></strong> file, which is going to be used by <a href="http://www.linux-ha.org">Heartbeat</a> to authenticate with the other node. So, we edit it as follows in both nodes:</p>
<blockquote><p><code>auth 3<br />
3 md5 DesiredPassword</code></p></blockquote>
<p>Finally, we change file permissions to this last file as follows:</p>
<blockquote><p><code>sudo chmod 600 /etc/ha.d/authkeys</code></p></blockquote>
<p>Now that we have both nodes configured, I recommend you to power off both nodes and boot the node we want to have as primary. In our case, it is <strong><em>drbd1</em></strong>. After booting up this node, we need to verify that Heartbeat has started the <a href="http://www.drbd.org">DRBD</a> resource (we can see this with <em><strong>cat</strong></em> <strong><em>/proc/drbd</em></strong>) and mounted it in /data. If it has, start the secondary node and verify that it is the secondary one.</p>
<p>If everything has gone right, try the failover process powering off the primary node. You will notice that the node that had the <a href="http://www.drbd.org">DRBD</a> resource as secondary, it&#8217;s now the primary one and it has control over the service. Also verify is the VIP address is working (should appear as eth0:0 issuing ifconfig).</p>
<p>After verifying everything is working as expected, it is always recommendable to have a Fencing device to ensure data integrity. This fencing device will prevent an Split-Brain condition. A well-known Fencing mechanism is known as<a href="http://www.linux-ha.org/STONITH"> STONITH</a> (Shoot the Other Node in the Head). This mechanism will basically power off or reset a node which is supposed to be dead. This means that if <strong><em>drbd1</em></strong> is supposed to be dead, <strong><em>drbd2</em></strong> will take control of the service or, in this case, the <a href="http://www.drbd.org">DRBD</a> resource. But, if <strong><em>drbd1</em></strong> is not actually dead and <strong><em>drbd2</em></strong> tries to take control over the shared <a href="http://www.drbd.org">DRBD</a> resource, an Split-Brain condition will occur. So <a href="http://www.linux-ha.org/STONITH">STONITH</a> will ensure that <strong><em>drbd1</em></strong> has been reseted or powered off so that <strong><em>drbd2</em></strong> can take control of the <a href="http://www.drbd.org">DRBD</a> resource.</p>
<p>To do this, there is an <strong><em>stonith</em></strong> package that is used to work with <a href="http://www.linux-ha.org/STONITH">STONITH</a>/Fencing devices in Heartbeat. But, since we don&#8217;t have a real Fencing device, we will use meatware. Meatware is a software provided by <a href="http://www.linux-ha.org/STONITH">STONITH</a>, that simulates the use of a <a href="http://www.linux-ha.org/STONITH">STONITH</a>/Fencing device, by not allowing the secondary node (<strong><em>drbd2</em></strong>) to take control over the shared resources If there has not been a confirmation that the primary node (<em><strong>drbd1</strong></em>) has been powered off or rebooted. This requires operator intervention. So to integrate the meatware software with Heartbeat we do as follows:</p>
<blockquote><p><code>sudo apt-get install stonith</code></p></blockquote>
<p>Then, we have to modify <strong><em>/etc/ha.d/ha.cf</em></strong> like this (in both nodes):</p>
<blockquote><p><code>... [Output Ommitted]<br />
auto_failback off<br />
<em><strong>stonith_host drbd1 meatware drbd2<br />
stonith_host drbd2 meatware drbd1</strong></em><br />
node drbd1 drbd2</code></p></blockquote>
<p>Then we power off the primary node (in this case <strong><em>drbd1</em></strong>) and reboot secondary node (<strong><em>drbd2</em></strong>). After reboot, take a look at <strong><em>/var/log/ha-log</em></strong> until you see something like this:</p>
<div class="mceTemp mceIEcenter">
<dl class="wp-caption aligncenter">
<dt class="wp-caption-dt"><a href="http://roaksoax.files.wordpress.com/2008/08/ha-log.png"><img class="size-medium wp-image-85" src="http://roaksoax.files.wordpress.com/2008/08/ha-log.png?w=300" alt="ha-log" width="300" height="28" /></a></dt>
</dl>
</div>
<p>As you can see, STONITH is sending a message that says that we need to confirm that <strong><em>drbd1</em></strong> has been rebooted so that <strong><em>drbd2</em></strong> can take control over the service. So, take a look at <strong><em>/proc/drbd</em></strong> and you will see that the DRBD resource is still as secondary. So, we do as follows:</p>
<blockquote><p><code>sudo meatclient -c drbd1</code></p></blockquote>
<p>And we will see something like this:</p>
<div class="mceTemp mceIEcenter">
<dl class="wp-caption aligncenter">
<dt class="wp-caption-dt"><a href="http://roaksoax.files.wordpress.com/2008/08/meatclient1.png"><img class="size-medium wp-image-87" src="http://roaksoax.files.wordpress.com/2008/08/meatclient1.png?w=300" alt="meatclient" width="300" height="78" /></a></dt>
</dl>
</div>
<p>Now, we confirm that it has been rebooted and we can now see that <em><strong>drbd2</strong></em> will take control of the resource by setting the DRBD resource as primary (<strong><em>cat /proc/drbd</em></strong>).</p>
<p>So we can now start <strong><em>drbd1</em></strong>. Everytime the primary node fails, the secondary node will display a message on <strong><em>/var/log/ha-log</em></strong> saying that we should confirm that the primary has been rebooted so that the secondary can take control of the service and become the new primary.</p>
<p>In a next post I&#8217;ll cover how to make NFS make use of DRBD. Any comments, suggestions, etc, you know where to find me <img src='http://www.roaksoax.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.roaksoax.com/2008/08/installing-drbd-on-hardy-part-2/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Installing DRBD On Hardy!</title>
		<link>http://www.roaksoax.com/2008/07/installing-drbd-on-hardy</link>
		<comments>http://www.roaksoax.com/2008/07/installing-drbd-on-hardy#comments</comments>
		<pubDate>Fri, 01 Aug 2008 02:05:47 +0000</pubDate>
		<dc:creator>roaksoax</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Planet]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[DRBD]]></category>
		<category><![CDATA[hardy]]></category>

		<guid isPermaLink="false">http://roaksoax.wordpress.com/?p=59</guid>
		<description><![CDATA[DRBD (Distributed Replicated Block Device) is a technology that is used to replicate data over TCP/IP. It is used to build HA Clusters and it can be seen as a RAID-1 implementation over the network. As you may all know, the DRBD kernel module has now been included into Hardy Heron Server Edition&#8217;s kernel, so [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.drbd.org">DRBD</a> (Distributed Replicated Block Device) is a technology that is used to replicate data over TCP/IP. It is used to build HA Clusters and it can be seen as a RAID-1 implementation over the network.</p>
<p>As you may all know, the <a href="http://www.drbd.org">DRBD</a> kernel module has now been included into Hardy Heron Server Edition&#8217;s kernel, so there is no more source downloading and compiling, which makes it easier to install and configure. Here I&#8217;ll show you how to install and and make a simple configuration of <a href="http://www.drbd.org">DRBD</a>, using one resource (<em><strong>testing</strong></em>). I&#8217;ll not cover how to install and configure heartbeat for automatic failover (This will be showed in a next post).</p>
<p>First of all, we will have to install Ubuntu Hardy Heron Server Edition on to servers and manually edit the partition table. We do this to leave FREE SPACE that we will be used later on as the block device for <a href="http://www.drbd.org">DRBD</a>. If you&#8217;ve seen the <a href="http://www.howtoforge.com/high_availability_nfs_drbd_heartbeat_p4">DRBD + NFS HowTo on HowToForge.com</a>, creating the partitions for <a href="http://www.drbd.org">DRBD</a> and leaving them unmounted will NOT work, and we won&#8217;t we able to create the resource for <a href="http://www.drbd.org">DRBD</a>. This is why we leave the FREE SPACE, and we will create the partition later on, when the system is installed.</p>
<p>So, after the installation we will have to create the partition, or partitions (in case we are creating an external partition for the meta-data, but in this case it will be internal), that <a href="http://www.drbd.org">DRBD</a> will use as a block device. For this we will use<em><strong> fdisk </strong></em>and do as follows:</p>
<blockquote><p><code><br />
fdisk /dev/sda<br />
n (to create a new partition)<br />
l83 (to create it as logical and format it as Filesystem # 83)<br />
w (to write the changes)</code></p></blockquote>
<p>After creating the partitions we will have to REBOOT both servers so that the kernel uses the new partition table. After reboot we have to install <em><strong>drbd8-utils</strong></em> on both servers:</p>
<blockquote><p><code>sudo apt-get install drbd8-utils</code></p></blockquote>
<p>Now that we have drbd8-utils installed, we can now configure <em><strong>/etc/drbd.conf</strong></em>, which we will configure a simple DRBD resource, as follows:</p>
<blockquote><p><code> resource testing { # name of resources<br />
</code></p>
<p><code> protocol C;</code></p>
<p><code>on drbd1 { # first server hostname<br />
device /dev/drbd0; # Name of DRBD device<br />
disk /dev/sda7; # Partition to use, which was created using fdisk<br />
address 172.16.0.130:7788; # IP addres and port number used by drbd<br />
meta-disk internal; # where to store metadata meta-data<br />
}</code></p>
<p><code>on drbd2 { # second server hostname<br />
device /dev/drbd0;<br />
disk /dev/sda7;<br />
address 172.16.0.131:7788;<br />
meta-disk internal;<br />
}</code></p>
<p><code>disk {<br />
on-io-error detach;<br />
}</code></p>
<p><code>net {<br />
max-buffers 2048;<br />
ko-count 4;<br />
}</code></p>
<p><code>syncer {<br />
rate 10M;<br />
al-extents 257;<br />
}</code></p>
<p><code>startup {<br />
wfc-timeout 0;<br />
degr-wfc-timeout 120; # 2 minutos.<br />
}<br />
}</code></p></blockquote>
<p>Note that we are using<strong> drbd1</strong> and<strong> drbd2</strong> as hostnames. This hostnames must be configured and the servers should be able to ping the other via those hostnames (that means we need to have a DNS server or configure hosts for both servers in <em><strong>/etc/hosts</strong></em>).</p>
<p>After creating the configuration in /etc/drbd.conf, we now can create the <a href="http://www.drbd.org">DRBD</a> resources. For this we issue the following in both servers:</p>
<blockquote><p><code>sudo drbdadm create-md testing</code></p></blockquote>
<p>After issuing this, we will be asked for confirmation to create the meta-data in the block device.</p>
<p>Now we have to power off both servers. After powering them off, we start our first server and we will see something similar to this:</p>
<p><a href="http://roaksoax.files.wordpress.com/2008/07/drbd2.png"><img class="aligncenter size-medium wp-image-78" src="http://roaksoax.files.wordpress.com/2008/07/drbd2.png?w=300" alt="" width="300" height="187" /></a></p>
<p>After confirming with &#8216;yes&#8217;, we can now start the second server. After the second server is running. both nodes resources are secondary, so we have to make one of them primary. For this, we issue the following on the server we would like to have the resource as primary:</p>
<blockquote><p><code>drbdadm -- --overwrite-data-of-peer primary all</code></p></blockquote>
<p>We verify this by issuing:</p>
<blockquote><p><code>cat /proc/drbd</code></p></blockquote>
<p>And this should show something like this:</p>
<p style="text-align:center;">
<p style="text-align:center;"><a href="http://roaksoax.files.wordpress.com/2008/07/drbd.png"><img class="aligncenter size-medium wp-image-77" src="http://roaksoax.files.wordpress.com/2008/07/drbd.png?w=300" alt="" width="300" height="187" /></a></p>
<p>Well, up to this point, i&#8217;ve have showed you how to install and configure DRBD on Hardy, and how to make one of the servers have its resource as primary. But, we still don&#8217;t have automatic failover or automatic mounting. In a next post I&#8217;ll show how to configure heartbeat to have automatic failover and to take control of the resources, aswell as configuring STONITH to use the meatware device, so that we won&#8217;t have a split-brain condition (or at least try). I&#8217;ll also show how to configure NFS and MySQL to use this DRBD resource.</p>
<p>BTW, if you have questions you know where to find me <img src='http://www.roaksoax.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.roaksoax.com/2008/07/installing-drbd-on-hardy/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<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>
