<?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>marius &#187; Cluster</title>
	<atom:link href="http://devilx.net/tag/cluster/feed/" rel="self" type="application/rss+xml" />
	<link>http://devilx.net</link>
	<description></description>
	<lastBuildDate>Mon, 14 May 2012 21:25:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>A brief summary of setting up a CentOS 5.4 DRBD Cluster in Primary/Primary</title>
		<link>http://devilx.net/2009/11/14/a-brief-summary-of-setting-up-a-centos-5-4-drbd-cluster-in-primaryprimary/</link>
		<comments>http://devilx.net/2009/11/14/a-brief-summary-of-setting-up-a-centos-5-4-drbd-cluster-in-primaryprimary/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 20:10:45 +0000</pubDate>
		<dc:creator>Marius</dc:creator>
				<category><![CDATA[Linux and stuff ...]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Cluster]]></category>
		<category><![CDATA[CMAN]]></category>
		<category><![CDATA[Coffee]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[DRBD]]></category>
		<category><![CDATA[GFS]]></category>
		<category><![CDATA[Grub]]></category>
		<category><![CDATA[High Availability]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[HPET]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OCFS]]></category>
		<category><![CDATA[OpenAIS]]></category>
		<category><![CDATA[RedHat]]></category>
		<category><![CDATA[RHEL]]></category>
		<category><![CDATA[SELinux]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Storage]]></category>
		<category><![CDATA[SuSE]]></category>
		<category><![CDATA[TSC]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[x86_64]]></category>

		<guid isPermaLink="false">http://www.devilx.net/?p=1090</guid>
		<description><![CDATA[Clustering is cool and fun when it&#8217;s working, but for getting to such status it mostly takes like a dozen hours, coffee and many nerves. To simplify it a bit, I&#8217;d like to share some information on that topic, especially &#8230; <a href="http://devilx.net/2009/11/14/a-brief-summary-of-setting-up-a-centos-5-4-drbd-cluster-in-primaryprimary/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Clustering is cool and fun when it&#8217;s working, but for getting to such status it mostly takes like a dozen hours, coffee and many nerves. To simplify it a bit, I&#8217;d like to share some information on that topic, especially the stones I stumbled over.</p>
<p>First of all, we defined our scenario. Let&#8217;s assume that we&#8217;d like to have a cluster of two servers, both running the latest CentOS (5.4), both up-to-date, both using the very same partitioning and both using DRBD and GFS(2). On most SuSE or Debian systems, the installation would be pretty straight-forward: You install the base system, set up the DRBD, format it with some OCFS and make Heartbeat monitor everything. So far so good. On RHEL/CentOS it seems to work a bit different, due to the different tools they&#8217;re using. When installing the installation-group &#8220;Cluster Storage&#8221; for example, yum fetches packages named openais and cman &#8211; tools you&#8217;ve probably never heard of, when you come form the Debian corner (as I do). But before I describe those in detail, let&#8217;s just configure our plain base-installation.</p>
<p>What do we need to do first? What&#8217;s one of the most important things on two systems that should run &#8220;symmetrically&#8221; and have the very same data available, with every change that&#8217;s being made every second? Exactly, the time would be one of those things. We need to assure that both systems use the very same time. Mostly, you&#8217;ll be using some x86_64 hardware for such setups, where the problems start: On 64-bit hardware, the timekeeping with TSC doesn&#8217;t run <strong>that</strong> perfect, which is why we should just deactivate it and leave HPET do its job alone. After installing ntpd we need to open our grub.conf and add the notsc option to our kernels. It should looks something like this:</p>
<blockquote><p>===================================================================<br />
RCS file: /etc/grub.conf,v<br />
retrieving revision 1.1<br />
diff -u -r1.1 /etc/grub.conf<br />
&#8212; /etc/grub.conf	2009/11/13 13:30:26	1.1<br />
+++ /etc/grub.conf	2009/11/13 13:32:26<br />
@@ -13,9 +13,9 @@<br />
hiddenmenu<br />
title CentOS (2.6.18-164.6.1.el5)<br />
root (hd0,0)<br />
-	kernel /vmlinuz-2.6.18-164.6.1.el5 ro root=LABEL=/<br />
+	kernel /vmlinuz-2.6.18-164.6.1.el5 ro root=LABEL=/ notsc<br />
initrd /initrd-2.6.18-164.6.1.el5.img<br />
title CentOS (2.6.18-164.el5)<br />
root (hd0,0)<br />
-	kernel /vmlinuz-2.6.18-164.el5 ro root=LABEL=/<br />
+	kernel /vmlinuz-2.6.18-164.el5 ro root=LABEL=/ notsc<br />
initrd /initrd-2.6.18-164.el5.img</p></blockquote>
<p>Now, we can shutdown the ntpd and set its drift-file to 0.000. After that, simply reboot and check the dmesg for the HPET-lines and of course also check the time on both systems to be identically.</p>
<p>Now, what else should we configure until we start building our actual cluster? Probably, we should take a look into the system-config-securitylevel-tui tool. Depending on what environment you plan your cluster to run in, you either want to open each port by port manually in the firewall and configure your SELinux to allow CMAN/OpenAIS and DRBD to work properly &#8211; or you simply turn of those &#8220;toys&#8221; and configure the network-segment to be secure by itself. It depends to you and I&#8217;m not going to write how to reconfigure the firewall or your SELinux-environment. For my tests, I simply turned both off. Especially the combination of CMAN/OpenAIS and SELinux can become pretty tricky, when SELinux runs in any other mode than &#8220;Disabled&#8221;. <img src='http://devilx.net/wp-content/plugins/smilies-themer/Riceballs/smile.png' alt=':-)' class='wp-smiley' /> </p>
<p>Now, let&#8217;s finally please our inner kid and install some software:</p>
<blockquote><p># yum groupinstall &#8220;Cluster Storage&#8221;<br />
&#8230;<br />
# yum install drbd83 kmod-drbd83<br />
&#8230;</p></blockquote>
<p>I&#8217;ve chosen to use drbd83 since it&#8217;s the next stable release and already obsoletes drbd82 in CentOS 5.4 &#8211; and drbd is simply just too old. Of course, upgrades might become tricky when using explicitly versioned packages, but on DRBD it&#8217;s always a bit tricky, since there could be configuration changes which would have to be implemented manually on future versions.</p>
<p>However, now let&#8217;s create the infamous and poorly documented /etc/cluster/cluster.conf. For testing, we could simply use something like this:</p>
<blockquote><p>&lt;?xml version=&#8221;1.0&#8243;?&gt;<br />
&lt;cluster alias=&#8221;cluster-setup&#8221; config_version=&#8221;1&#8243; name=&#8221;cluster-setup&#8221;&gt;<br />
&lt;rm log_level=&#8221;4&#8243;/&gt;<br />
&lt;fence_daemon clean_start=&#8221;1&#8243; post_fail_delay=&#8221;0&#8243; post_join_delay=&#8221;3&#8243;/&gt;<br />
&lt;clusternodes&gt;<br />
&lt;clusternode name=&#8221;server-1.cross&#8221; nodeid=&#8221;1&#8243; votes=&#8221;1&#8243;&gt;<br />
&lt;fence&gt;<br />
&lt;method name=&#8221;2&#8243;&gt;<br />
&lt;device name=&#8221;LastResortNode01&#8243;/&gt;<br />
&lt;/method&gt;<br />
&lt;/fence&gt;<br />
&lt;/clusternode&gt;<br />
&lt;clusternode name=&#8221;server-2.cross&#8221; nodeid=&#8221;2&#8243; votes=&#8221;1&#8243;&gt;<br />
&lt;fence&gt;<br />
&lt;method name=&#8221;2&#8243;&gt;<br />
&lt;device name=&#8221;LastResortNode02&#8243;/&gt;<br />
&lt;/method&gt;<br />
&lt;/fence&gt;<br />
&lt;/clusternode&gt;<br />
&lt;/clusternodes&gt;<br />
&lt;cman expected_votes=&#8221;1&#8243; two_node=&#8221;1&#8243;/&gt;<br />
&lt;fencedevices&gt;<br />
&lt;fencedevice agent=&#8221;fence_manual&#8221; name=&#8221;LastResortNode01&#8243; nodename=&#8221;server-1.cross&#8221;/&gt;<br />
&lt;fencedevice agent=&#8221;fence_manual&#8221; name=&#8221;LastResortNode02&#8243; nodename=&#8221;server-2.cross&#8221;/&gt;<br />
&lt;/fencedevices&gt;<br />
&lt;rm/&gt;<br />
&lt;totem consensus=&#8221;4800&#8243; join=&#8221;60&#8243; token=&#8221;10000&#8243; token_retransmits_before_loss_const=&#8221;20&#8243;/&gt;<br />
&lt;/cluster&gt;</p></blockquote>
<p>Configuring OpenAIS this way isn&#8217;t actually the best way&#8230; it&#8217;s not even &#8220;good&#8221;. But for testing (and understanding how stuff works) it should be enough. Those rules expect manual intervention when one of the two server should become unavailable and needs to be brought back into the cluster.</p>
<p>The domain &#8220;.cross&#8221; is expected to be a hostname.domainname entry within the /etc/hosts of each server and defines the direct cross-cable-connection from one server to another. We need this connection to shrink down network latency and provide a way for OpenAIS and (in this example) also DRBD to directly communicate with each other. A better setup would be to set the heartbeat on top of a serial-line, since it would be most fault-tolerant.</p>
<p>Okay, next. What&#8217;s left? Exactly, the actual DRBD &#8211; so let&#8217;s set it up:</p>
<blockquote><p>global { usage-count yes; }<br />
common { syncer { rate 100M; } }<br />
resource the-disk {<br />
protocol C;<br />
startup {<br />
wfc-timeout 20;<br />
degr-wfc-timeout 10;<br />
# become-primary-on both; # Uncomment this only after tested!<br />
}<br />
net {<br />
cram-hmac-alg sha1;<br />
shared-secret &#8220;i4m501337&#8243;;<br />
allow-two-primaries;<br />
}<br />
on server-1 {<br />
device    /dev/drbd1;<br />
disk      /dev/sdb;<br />
address   10.100.0.1:7789;<br />
meta-disk  internal;<br />
}<br />
on server-2 {<br />
device    /dev/drbd1;<br />
disk      /dev/sdb;<br />
address   10.100.0.2:7789;<br />
meta-disk  internal;<br />
}<br />
disk {<br />
fencing resource-and-stonith;<br />
}<br />
handlers {<br />
#outdate-peer &#8220;/sbin/handler&#8221;;<br />
}<br />
}</p></blockquote>
<p>This configuration defines our two servers and tells DRBD to use /dev/sdb on both for the actual data. Our meta-disk will be internal and with address we defined &#8211; guess what? &#8211; the IP addresses of our two servers. Those are the .cross-domain addresses!</p>
<p>Next, we initialize our meta-disks (on both nodes), set our generation identifier, start the actual DRBD service and check the roles it currently runs in:</p>
<blockquote><p># drbdadm create-md the-disk<br />
&#8230;<br />
# drbdadm &#8212; 6::::1 set-gi the-disk<br />
&#8230;<br />
# service drbd start<br />
&#8230;<br />
# drbdadm role all<br />
Secondary/Secondary</p></blockquote>
<p>If all those steps succeed, we can try to promote both nodes to primary:</p>
<blockquote><p># drbdadm primary all<br />
# drbdadm role all<br />
Primary/Primary</p></blockquote>
<p>And if this now worked out properly, we can enable the automatic promotion from within our drbd.conf:</p>
<blockquote><p># rcsdiff -u /etc/drbd.conf<br />
===================================================================<br />
RCS file: /etc/drbd.conf,v<br />
retrieving revision 1.2<br />
diff -u -r1.2 /etc/drbd.conf<br />
&#8212; /etc/drbd.conf	2009/11/13 10:34:23	1.2<br />
+++ /etc/drbd.conf	2009/11/13 15:16:26<br />
@@ -9,7 +9,7 @@<br />
startup {<br />
wfc-timeout 20;<br />
degr-wfc-timeout 10;<br />
-                # become-primary-on both; # Uncomment this only after tested!<br />
+                become-primary-on both; # Uncomment this only after tested!<br />
}<br />
net {<br />
cram-hmac-alg sha1;</p></blockquote>
<p>Great. <em>So we&#8217;re set up now?</em> Nope. We&#8217;re not. Next, we need to change DRBDs boot order in order for it to work properly with the GFS auto-mounting on boot:</p>
<blockquote><p># rcsdiff -u /etc/init.d/drbd<br />
===================================================================<br />
RCS file: /etc/init.d/drbd,v<br />
retrieving revision 1.1<br />
diff -u -r1.1 /etc/init.d/drbd<br />
&#8212; /etc/init.d/drbd	2009/11/13 10:57:15	1.1<br />
+++ /etc/init.d/drbd	2009/11/13 10:58:15<br />
@@ -1,6 +1,6 @@<br />
#!/bin/bash<br />
#<br />
-# chkconfig: 345 70 08<br />
+# chkconfig: 345 22 75<br />
# description: Loads and unloads the drbd module<br />
#<br />
# Copright 2001-2008 LINBIT Information Technologies</p></blockquote>
<p>And let it run on boot:</p>
<blockquote><p># chkconfig &#8211;level 345 drbd on</p></blockquote>
<p>Great! <em>So, now we are set up, right?</em> Nope, wrong. We have a running DRBD setup now, but we still lack of a cluster-able file-system. GFS2 is a pretty good choice for such a task, so let&#8217;s try to format the DRBD-device on <strong>one of our nodes</strong> with it:</p>
<blockquote><p># mkfs.gfs2 -p lock_dlm -t cluster-setup:mycluster /dev/drbd1 -j 2</p></blockquote>
<p>Before we can try to mount the device, we need to have OpenAIS/CMAN running, in order to manage our GFS consistency. Let&#8217;s start the cman service therefor (on both nodes!):</p>
<blockquote><p># service cman start</p></blockquote>
<p>Starting cman and starting fenced could take several seconds, be patient. If you installed both servers identically and followed this documentation step by step everything should work out just fine. <img src='http://devilx.net/wp-content/plugins/smilies-themer/Riceballs/smile.png' alt=':-)' class='wp-smiley' /> </p>
<p>At last, we can now mount our DRBD device into some folder (on both nodes) and start playing around with our fresh setup:</p>
<blockquote><p># mount -t gfs2 /dev/drbd1 /mnt/somefolder</p></blockquote>
<p>I hope everything worked out for you and I also hoped that this brief summary helped you getting a bit easier into the actual setup of such a cluster setup. Feel free to ask any questions or provide feedback in any form.</p>
<p>Enjoy! <img src='http://devilx.net/wp-content/plugins/smilies-themer/Riceballs/smile.png' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://devilx.net/2009/11/14/a-brief-summary-of-setting-up-a-centos-5-4-drbd-cluster-in-primaryprimary/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

