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