<?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>Hack Admin &#187; filesystem</title>
	<atom:link href="http://www.hackadmin.com/tag/filesystem/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hackadmin.com</link>
	<description></description>
	<lastBuildDate>Tue, 16 Mar 2010 21:31:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Quick and Dirty DRBD with HA</title>
		<link>http://www.hackadmin.com/2008/05/06/quick-and-dirty-drbd-with-ha/</link>
		<comments>http://www.hackadmin.com/2008/05/06/quick-and-dirty-drbd-with-ha/#comments</comments>
		<pubDate>Tue, 06 May 2008 13:46:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Replication]]></category>
		<category><![CDATA[DRBD]]></category>
		<category><![CDATA[failover]]></category>
		<category><![CDATA[file system]]></category>
		<category><![CDATA[filesystem]]></category>
		<category><![CDATA[ha]]></category>
		<category><![CDATA[master]]></category>
		<category><![CDATA[mount]]></category>
		<category><![CDATA[server pair]]></category>
		<category><![CDATA[slave]]></category>

		<guid isPermaLink="false">http://www.hackadmin.com/2008/05/06/quick-and-dirty-drbd-with-ha/</guid>
		<description><![CDATA[I had to dig a while on this one.  I think it was mostly because it took me a while to get what was going on.  Basically, I have 4 server pairs that I needed to setup.  Three where to be mysql instances, a master instance, a slave instance that was only [...]]]></description>
			<content:encoded><![CDATA[<p>I had to dig a while on this one.  I think it was mostly because it took me a while to get what was going on.  Basically, I have 4 server pairs that I needed to setup.  Three where to be mysql instances, a master instance, a slave instance that was only a partial replication of the master and a global slave instance.  The 4th pair was for crunching stats from another series of XML servers.</p>
<p>So I built all of these instances to give hardware based failover options in case of total failure or need for upgrade.  I honestly am not counting on any of these instances to be a seamless failover scenario, but I figure it could work in a crisis and worst case, I have a copy of important data that is ready to go live.</p>
<p><span id="more-9"></span>Needless to say, through setting up 4 pairs of servers I got handy with the routine that I knew worked.  Here was my process:</p>
<p><strong>DRBD Setup</strong></p>
<p>1.) Kickstart both boxes with the following KS disk layout:</p>
<p>part / &#8211;size 10000<br />
part /data &#8211;size 5000 &#8211;grow<br />
part /boot &#8211;size 100<br />
part swap &#8211;size 2000</p>
<p>The data slice is what I will share between the DRBD pair.</p>
<p>*NOTE &#8211; The next steps &#8211; Step 2 through 9 need to be completed on both servers in the HA, DRBD setup.</p>
<p>2.) Download the latest DRBD <a title="DRBD Source" href="http://oss.linbit.com/drbd/8.2/drbd-8.2.5.tar.gz">source.</a></p>
<p>3.) I wanted to make the install much harder than it actually is, so I spent time on many sites staring at kernel patches and such.. Oh well.  When all was said and done, I really just needed to make sure the kernel source was in my kickstart, then run the following from within the source directory:</p>
<p>make clean all<br />
make install<br />
make install-tools</p>
<p>4.) Brew up a config file for DRBD ( there should be a default in /etc/drbd.conf ) :</p>
<p># The important logicstics as best I can tell.<br />
# Protocol &#8211; there are 3 options I chose C as it appeared to be the best to use with mysql<br />
# syncer &#8211; this was a head scratcher.  When I first tried to sync my disks I had left it at default<br />
# and our 56G chunks were taking about 6 hours to complete.  I&#8217;m not only on GB interfaces here<br />
# but the servers in question are blades and they share a chassis backplane, so I cranked it up<br />
# 500M is close to the threshold, don&#8217;t remember what it was  but I hit it when I was being all<br />
# crazy with this setting to start.<br />
# Server Names &#8211; in this example, server1 and server2, make sure they are in /etc/host<br />
# Resource &#8211; this is going to be used through out the example as a way for the DRBD system to  identify t<br />
# the config params that create this disk replication scenario</p>
<p>global {<br />
usage-count yes;<br />
}<br />
common {<br />
protocol C;<br />
syncer { rate 500M; }<br />
}<br />
resource r0 {<br />
on server1 {<br />
device    /dev/drbd1;<br />
disk      /dev/sda3;<br />
address   192.168.195.124:7789;<br />
meta-disk internal;<br />
}<br />
on server2 {<br />
device    /dev/drbd1;<br />
disk      /dev/sda3;<br />
address   192.168.195.125:7789;<br />
meta-disk internal;<br />
}<br />
}</p>
<p>5.) Next, I umounted the disk in question, since it was built with kickstart, it came up as a mounted ext3 slice at /data</p>
<p>6.) Then I zeroed out /dev/sda3 ( what was our /data mount ) with the following command:</p>
<p>dd if=/dev/zero bs=1M count=1 of=/dev/sda3 ; sync</p>
<p>7.) Next, we need to create the device that we refer to in the config file /dev/drbd1 .  I found a bash line in a search that creates several so I just did it up  in case I ever wanted to expand this config:</p>
<p>for i in `seq 0 1` ; do mknod -m 0660 /dev/drbd$i b 147 $i; done</p>
<p>Just change the seq numbers if you want more or less.</p>
<p>8.) Next we use the drbdadm command to create our resource ( r0 ):</p>
<p>drbdadm create-md r0</p>
<p>9.) Start the drbd service</p>
<p>/etc/init.d/drbd start</p>
<p>10.) Pick the server that you want to be the primary in the pair and run the following command:</p>
<p>drbdadm &#8212; &#8211;overwrite-data-of-peer primary r0</p>
<p>This will create the sync between the 2 disks you can watch the progress of the sync with the following command:</p>
<p>watch cat /proc/drbd</p>
<p>11.) Once the disks are in sync, create a file system on both sides.  This where it can get kind of tricky if you&#8217;re not sure what it&#8217;s doing.  We just told server1 to be the primary server in the pair so when you look at /proc/drbd you&#8217;ll see the following that verifies this is the case:</p>
<p>1: cs:Connected st:Primary/Secondary ds:UpToDate/UpToDate C r&#8212;</p>
<p>I added the following to /etc/fstab so I could mount and make a file system:</p>
<p>/dev/drbd1            /data                   ext3    defaults        1 2</p>
<p>Then:</p>
<p>mount /data</p>
<p>Then:</p>
<p>/sbin/mkfs -t ext3 /dev/drbd1</p>
<p>12.) Now we are going to create the filesystem on the secondary server.  ( I&#8217;m not sure this is entirely necessary, but it&#8217;s a good exercise in moving the slice around ).</p>
<p>* Unmount the /data slice on the primary server:</p>
<p>umount /data</p>
<p>* Make the primary box ( server1 in our case ) the secondary in the drbd pair:</p>
<p>drbdadm secondary r0</p>
<p>* Make the secondary box ( server2 in our case ) the primary in the drbd pair:</p>
<p>drbdadm primary r0</p>
<p>* Add the /etc/fstab line</p>
<p>/dev/drbd1            /data                   ext3    defaults        1 2</p>
<p>* Mount the slice:</p>
<p>mount /data</p>
<p>* Create the filesystem:</p>
<p>/sbin/mkfs -t ext3 /dev/drbd1</p>
<p>Once this is complete, use the same series of commands to make server1 the primary, remove all of the /etc/fstab entries for /data ( Linux HA is going to take care of this for us ) and move on to the HA config below.</p>
<p><strong>Linux HA Setup</strong></p>
<p>The goal of this setup is as follows:</p>
<p>a.) Choose a VIP for your HA pair</p>
<p>b.) Build a config file that starts and stops services on startup and failover</p>
<p>HA is pretty simple when all is said and done ( at least in this config ).  It comes rolled up with scripts that take care of the following:</p>
<p>- Manage VIP<br />
- Manage DRBD resource<br />
- Mounting file systems<br />
- Starting services</p>
<p><strong>Install</strong></p>
<p>To install in my setup I just ran:</p>
<p>yum  -y install heartbeat</p>
<p><strong>Config</strong></p>
<p>Once heartbeat is installed there are 3 files to worry about:</p>
<p>- ha.cf<br />
- haresources<br />
- authkeys</p>
<p>All of these files will live in /etc/ha.d</p>
<p>All of these files must be identical on both servers in the pair.</p>
<p>1.) ha.cf</p>
<p>keepalive 100ms<br />
deadtime 2<br />
warntime 10<br />
initdead 120<br />
bcast   eth1 eth0<br />
autojoin none<br />
auto_failback on<br />
node    server1 server2</p>
<p>You can play with the values of each of these and there is further information <a href="http://www.linux-ha.org/ha.cf">here.</a></p>
<p>Again in this config ( and this should already be done ) .. make sure you have server1 and server2 in /etc/hosts</p>
<p>2.) haresources</p>
<p>This is basically the command file, it tells HA what to do and in what order.  Here is my config file:</p>
<p>Server1 IPaddr::192.168.195.212/24 drbddisk::r0 \<br />
Filesystem::/dev/drbd1::/data::ext3::defaults mysql.server</p>
<p>Breakdown:</p>
<p>Server1  &#8211; This will be the same on both primary and secondary, it tells HA who should be in charge.<br />
IPaddr &#8211;  This identifies the VIP that will be used between the two systems.  If you have multiple NICs, it is smart enough to figure out which one it should be a sub of.</p>
<p>* SIDE NOTE &#8211; In the haresources file, the syntax basically indicates that you are asking HA to run a script.  HA looks for scripts in /etc/ha.d/resource.d and /etc/init.d by default, take the following example:</p>
<p>IPaddr::192.168.195.212/24</p>
<p>This means you are asking HA to run the following:</p>
<p>/etc/ha.d/resource.d/IPaddr 192.168.195.212/24 start</p>
<p>The result will be an added ethernet interface with the VIP for the pair.</p>
<p>* END SIDE NOTE</p>
<p>drbddisk &#8211; This tells HA to use the drbddisk command in /etc/ha.d/resource.d to initialize the drbd resource ( r0 in our case ) and make it primary.</p>
<p>Filesystem &#8211; This tells HA to mount the drbd resource at /data</p>
<p>mysql.server &#8211; This tells HA to use the script in /etc/init.d to fire up mysql</p>
<p>* SIDE NOTE</p>
<p>You can imagine how important the sequence is here.  If I were to try to mount /data before I initialize drbd, it&#8217;s going to fail.  Unfortunately,  HA is not real clear on what is going wrong when it&#8217;s failing, it just fails.  There are log file lines you can use in ha.cf, but everything goes to /var/messages by default so don&#8217;t waste your time.</p>
<p>Also, if you are setting up multiple HA pairs that should not know about other pairs, you need to change the following parameters in your ha.cf:</p>
<p>- Remove this: bcast   eth1 eth0<br />
- Add this: mcast eth0 224.1.2.6 694 1 0</p>
<p>For each pair you will want to modify the broadcast address so that it is unique, so for the second pair you could use this:</p>
<p>- mcast eth0 224.1.2.7 694 1 0</p>
<p>Changing the &#8220;6&#8243; to a &#8220;7&#8243; makes sure that pairs aren&#8217;t chatting with each other and failing.  The result of not doing this is a /var/log/messages file that grows out of control ( I&#8217;m not kidding either, with 4 pairs on the same net this thing was growing at about 500M an hour ).  It also drives the server load up on the pair from all the logd action, to the tune of load 0 when only one pair to load 2 when 4 pairs on the same net.</p>
<p>* END SIDE NOTE</p>
<p>3.) authkeys</p>
<p>This can be pretty generic.  I thought initially changing this secret around would avoid the issue listed in the last side note, it doesn&#8217;t.  The only catch with this file is that it has to have perms of 600 or HA won&#8217;t start.</p>
<p>auth 2<br />
2 sha1 MySecret</p>
<p><strong>Verification</strong></p>
<p>As I have mentioned, the haresources file basically contains script to argument pairs.  It is good practice to walk through all of these with a &#8220;start&#8221;, then go back through with a &#8220;stop&#8221;.  This will ensure that what HA will run will actually work when HA attempts to run them.</p>
<p>Once you are satisfied with the results of your testing, just run /etc/init.d/heartbeat start on each box.  If all goes well, you should see the new VIP on the primary box, the mounted /data slice, and you should be able to log into mysql</p>
<p>* SIDE NOTE</p>
<p>To install mysql I did the following:</p>
<p>- Downloaded preferred tarball<br />
- Changed this in my.cf -  datadir=/data/mysql_data<br />
- Added this to my.cf &#8211; bind-address=192.168.195.212 ( This ensures that mysql binds to the VIP on startup)</p>
<p>* END SIDE NOTE</p>
<p>This may be a bit scattered, read it a couple times and it should all be clear.  This is basically a compilation of 2 days worth of poking at this process to find something that consistently worked.</p>
<p>Good Luck</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackadmin.com/2008/05/06/quick-and-dirty-drbd-with-ha/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mount an ISO</title>
		<link>http://www.hackadmin.com/2008/04/04/mount-an-iso/</link>
		<comments>http://www.hackadmin.com/2008/04/04/mount-an-iso/#comments</comments>
		<pubDate>Fri, 04 Apr 2008 13:17:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[file system]]></category>
		<category><![CDATA[filesystem]]></category>
		<category><![CDATA[iso]]></category>
		<category><![CDATA[mount]]></category>
		<category><![CDATA[Mount ISO]]></category>

		<guid isPermaLink="false">http://www.hackadmin.com/2008/04/04/mount-an-iso/</guid>
		<description><![CDATA[mount -o loop -t iso9660 file.iso /mnt/test
]]></description>
			<content:encoded><![CDATA[<p>mount -o loop -t iso9660 file.iso /mnt/test</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackadmin.com/2008/04/04/mount-an-iso/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
