<?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; NFS</title>
	<atom:link href="http://www.roaksoax.com/tag/nfs/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>
	</channel>
</rss>
