<?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; ubuntu hardy</title>
	<atom:link href="http://www.roaksoax.com/tag/ubuntu-hardy/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>DRBD and NFS</title>
		<link>http://www.roaksoax.com/2008/10/drbd-and-nfs</link>
		<comments>http://www.roaksoax.com/2008/10/drbd-and-nfs#comments</comments>
		<pubDate>Thu, 16 Oct 2008 19:23:28 +0000</pubDate>
		<dc:creator>roaksoax</dc:creator>
				<category><![CDATA[Planet]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[DRBD]]></category>
		<category><![CDATA[DRBD NFS]]></category>
		<category><![CDATA[hardy]]></category>
		<category><![CDATA[NFS]]></category>
		<category><![CDATA[ubuntu hardy]]></category>

		<guid isPermaLink="false">http://roaksoax.wordpress.com/?p=113</guid>
		<description><![CDATA[Hey all. Sorry for the delay in posting this tutorial, I&#8217;ve been pretty busy and I finally had some time to finish it. Enjoy . Well, as you may know, in previous posts (Post 1, Post 2) I&#8217;ve showed you how to install and configure DRBD in an active/passive configuration with failover, automatically, using Heartbeat. [...]]]></description>
			<content:encoded><![CDATA[<p>Hey all. Sorry for the delay in posting this tutorial, I&#8217;ve been pretty busy and I finally had some time to finish it. Enjoy <img src='http://www.roaksoax.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Well, as you may know, in previous posts (<a href="http://roaksoax.wordpress.com/2008/07/31/installing-drbd-on-hardy/" target="_blank">Post 1</a>, <a href="http://roaksoax.wordpress.com/2008/08/04/installing-drbd-on-hardy-part-2/" target="_blank">Post 2</a>) I&#8217;ve showed you how to install and configure DRBD in an active/passive configuration with failover, automatically, using Heartbeat. Now, I&#8217;m going to show you how to use that configuration to export the data stored in the DRBD device (make it available for other servers in a network) using NFS.</p>
<p>So, the first thing to do is to install NFS in both <em><strong>drbd1</strong></em> and <strong><em>drbd2</em></strong>, stop the daemon, and remove it from the upstart process (This means that we&#8217;ll have to remove the NFS daemon from starting during the boot up process). We do this as follows in both servers:</p>
<blockquote><p><code>:~$ sudo apt-get install nfs-kernel-server nfs-common<br />
:~$ sudo /etc/init.d/nfs-kernel-server stop<br />
:~$ sudo update-rc.d -f nfs-kernel-server remove<br />
:~$ sudo update-rc.d -f nfs-common remove</code></p></blockquote>
<p>Now, you may wonder how is NFS going to work. The NFS daemon will be working only in the active (or primary) server, and this is going to be controlled by Heartbeat. But, since NFS stores information in <em><strong>/var/lib/nfs</strong></em>, on each server, we have to make both servers have the same information. This is because if <strong><em>drbd1</em></strong> goes down,<em> <strong>drbd2</strong></em> will take over, but its information in <em><strong>/var/lib/nfs</strong></em> will be different from <em><strong>drbd1</strong></em>&#8216;s info, and this will stop NFS from working. So, to make both servers have the same information in<em> <strong>/var/lib/nfs</strong></em>, we are going to copy this information to the DRBD device and create a symbolic link, so that the information gets stored in the DRBD device and not in the actual disk. This way, both servers will have the same information. To do this, we do as follows in the primary server (<em><strong>drbd1</strong></em>):</p>
<blockquote><p><code>mv /var/lib/nfs/ /data/<br />
ln -s /data/nfs/ /var/lib/nfs<br />
mkdir /data/export<br />
</code></p></blockquote>
<p>After that, since we already copied the NFS lib files to the DRBD device in the primary server (<em><strong>drbd1</strong></em>), we have to remove them from the secondary server (<strong><em>drbd2</em></strong>) and create the link.</p>
<blockquote><p><code>rm -rf /var/lib/nfs/<br />
ln -s /data/nfs/ /var/lib/nfs</code></p></blockquote>
<p>Now, since Heartbeat is going to control the NFS daemon, we have to tell Heartbeat to start the <em><strong>nfs-kernel-server</strong></em> daemon whenever it takes the control of the server. We do this in <em><strong>/etc/ha.d/haresources</strong></em> and we add <em><strong>nfs-kernel-server</strong></em> at the end. The file should look like this:</p>
<blockquote><p><code>drbd1  IPaddr::172.16.0.135/24/eth0 drbddisk::testing Filesystem::/dev/drbd0::/data::ext3 <strong>nfs-kernel-server</strong></code></p></blockquote>
<p>Now that we&#8217;ve configured everything, we have to power off both servers, first the secondary and then the primary. Then we start the primary server, and during the boot up process we&#8217;ll see a message that will require us to type <em><strong>&#8220;yes&#8221;</strong></em> (This is the same message showed during the installation of DRBD in <a href="http://roaksoax.wordpress.com/2008/07/31/installing-drbd-on-hardy/" target="_blank">my first pos</a><a href="http://roaksoax.wordpress.com/2008/07/31/installing-drbd-on-hardy/" target="_blank">t</a>).  After confirming, and If you have stonith configured, it is probable that <strong><em>drbd1</em></strong> wont start its DRBD device, so it will remain as secondary, and won&#8217;t be able to mount it. This is because we will have to tell stonith to take over the service (To see if stonith is the problem, we can take a look at <strong><em>/var/log/ha-log</em></strong>). So, to do this, we do as follows in the primary server (<strong><em>drbd1</em></strong>):</p>
<blockquote><p><code>meatclient -c drbd2</code></p></blockquote>
<p>After doing this, we have to confirm. After the confirmation, Heartbeat will take the control, change the DRBD device to primary, and start NFS. Then, we can boot up the secondary server (<strong><em>drbd2</em></strong>). Enojy <img src='http://www.roaksoax.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<p><strong>Note:</strong> I made the choice of powering off both servers. You could just restart them, one at a time, and see what happens <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/10/drbd-and-nfs/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>
	</channel>
</rss>
