<?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>Running Systems</title>
	<atom:link href="http://run.tournament.org.il/feed/" rel="self" type="application/rss+xml" />
	<link>http://run.tournament.org.il</link>
	<description>(and me chasing them)</description>
	<lastBuildDate>Sun, 13 Dec 2009 09:03:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>NetApp SnapMirror monitor script</title>
		<link>http://run.tournament.org.il/netapp-snapmirror-monitor-script/</link>
		<comments>http://run.tournament.org.il/netapp-snapmirror-monitor-script/#comments</comments>
		<pubDate>Sun, 13 Dec 2009 09:02:18 +0000</pubDate>
		<dc:creator>ez-aton</dc:creator>
				<category><![CDATA[Disk Storage]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[bandwidth limits]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[netapp]]></category>
		<category><![CDATA[replication]]></category>
		<category><![CDATA[storage device]]></category>

		<guid isPermaLink="false">http://run.tournament.org.il/?p=499</guid>
		<description><![CDATA[I have had some work done lately with NetApp SnapMirror. I have snapped-mirrored some volumes and qtrees and I wanted to monitor their use and behavior over the line.
As you can expect, site-to-site replication of data is a fragile thing, especially when done on the level of the storage device, which is agnostic to the [...]


Related posts:<ol><li><a href='http://run.tournament.org.il/citrix-xenserver-5-0-cannot-cooperate-with-netapp-snapmirror/' rel='bookmark' title='Permanent Link: Citrix XenServer 5.0 cannot cooperate with NetApp SnapMirror'>Citrix XenServer 5.0 cannot cooperate with NetApp SnapMirror</a> <small>It has been a long while, I know. I was...</small></li>
<li><a href='http://run.tournament.org.il/netapp-ontap-71/' rel='bookmark' title='Permanent Link: NetApp Ontap 7.1'>NetApp Ontap 7.1</a> <small>I&#8217;ve had the pleasure of playing with Ontap Simulator. This...</small></li>
<li><a href='http://run.tournament.org.il/ontap-simulator-and-some-insights-about-netapp/' rel='bookmark' title='Permanent Link: Ontap Simulator, and some insights about NetApp'>Ontap Simulator, and some insights about NetApp</a> <small>First and foremost &#8211; the Ontap simulator, a great tool...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I have had some work done lately with NetApp SnapMirror. I have snapped-mirrored some volumes and qtrees and I wanted to monitor their use and behavior over the line.</p>
<p>As you can expect, site-to-site replication of data is a fragile thing, especially when done on the level of the storage device, which is agnostic to the data kept on it. When replicating volumes, I should expect the relevant employees to be responsible regarding what&#8217;s placed there, because the storage does not filter out the junk. If someone had decided to add a new DVD image on the DB storage space, well &#8211; the DB won&#8217;t care, as long as there is enough free space, but the storage will attempt to replicate the added data to the alternate site, which means that if you are around your bandwidth limits, which is never a good thing, you will just create a delay gap you would hardly (if at all) be able to close.</p>
<p>For that, and since I don&#8217;t tend to trust people not to do stupid things, I have written this script.</p>
<p><span style="text-decoration: underline;">What does it do?</span></p>
<p>This script will perform the following:</p>
<p><strong>Alerting about non-idle SnapMirror session</strong></p>
<p>Use with &#8216;-m alert&#8217;</p>
<p>Assuming SnapMirror is scheduled to a specific time, the script will alert if a session is active. With the flag &#8216;-a no&#8217;, it will not send an e-mail (if possible, see the configuration section below). With &#8216;-r yes&#8217;, it will react, setting throttle for each non-idle session, but then &#8216;-t VALUE&#8217; should be specified, where VALUE is the numeric throttle in KB/s.</p>
<p><strong>Limiting throttle to a SnapMirror session</strong></p>
<p>Use with &#8216;-m throttle_limit&#8217;</p>
<p>The script will set a throttle for SnapMirror session(s). Setting limit by the flag &#8216;-t VALUE&#8217;, where VALUE is the numeric throttle in KB/s per each session.</p>
<p><strong>Cancelling throttle limit</strong></p>
<p>Use with &#8216;-m throttle_unlimit&#8217;</p>
<p>The script will set unlimited throttle for SnapMirror session(s).</p>
<p><strong>Checking SnapMirror lag</strong></p>
<p>Use with the &#8216;-m check_lag&#8217;</p>
<p>Since replication has a purpose of recovering, the lag of each SnapMirror session would show how far back we are. Use with &#8216;-d VALUE&#8217;, VALUE being numeric time in minutes to set alert threshold. The default threshold delay is one day (1440 minutes).</p>
<p><strong>Checking snapshots size</strong></p>
<p>Use with the &#8216;-m check_size&#8217;</p>
<p>This reports the expected delta to transfer. This can help estimate the success or failure of a future sync of data (snapmirror update) before it begins. Use with &#8216;-l&#8217; flag to set it to log date/time of measure and the expected sizes into a file. By default, in /tmp/target_name.txt, where the target is the SnapMirror target.</p>
<p><strong>General Options</strong></p>
<p>Use with &#8216;-c filename&#8217; for alternate configuration file.</p>
<p>Use with &#8216;-h&#8217; to get general help.</p>
<p>Use with a list target names in the format of storage:/vol/volname/qtree or storage:volname to ignore targets in configuration file and use your own.</p>
<p><strong>Configuration File</strong></p>
<p>The configuration file is rather simple. By default it should be called &#8220;<em>/etc/snapmirror_monitor.conf</em>&#8220;. It consists of two main variables for the system:</p>
<blockquote><p>TGTS=&#8221;storage2:/vol/volname/qtree</p>
<p>storage3:volname2</p>
<p>storage1:/vol/volnew/qtr2&#8243;</p>
<p>EMAIL=&#8221;user@domain.com another_user@domain.com&#8221;</p></blockquote>
<p><strong>Prerequisites</strong></p>
<p>This script will run on any modern Linux machine. For it to communicate with the NetApp devices, you will need SSH enabled on the NetApps, and ssh key exchange so that the Linux would be able to access the NetApp without using passwords.</p>
<p><span style="text-decoration: underline;">The Script</span></p>
<p>Below is the script. You can download it and use it as you like.</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://run.tournament.org.il/wp-content/plugins/wp-codebox/wp-codebox.php?p=499&amp;download=snapshot_mirror.sh">snapshot_mirror.sh</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4992"><td class="code" id="p499code2"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># This script will monitor snapmirror status</span>
<span style="color: #666666; font-style: italic;"># Assumption: Access through ssh to root on all storage devices involved</span>
<span style="color: #666666; font-style: italic;"># This will also attempt to detect the diff which is to sync</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Written by Ez-Aton. Check http://run.tournament.org.il for updates or</span>
<span style="color: #666666; font-style: italic;"># additional information</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Modes: </span>
<span style="color: #666666; font-style: italic;"># alert -&gt; alert if snapmirror is still active</span>
<span style="color: #666666; font-style: italic;"># throttle_limit -&gt; Limit throttle to a given number (default or manually set)</span>
<span style="color: #666666; font-style: italic;"># throttle_unlimit -&gt; Open throttle limitation</span>
<span style="color: #666666; font-style: italic;"># check_lag -&gt; Report the snapmirror lage</span>
<span style="color: #666666; font-style: italic;"># check_size -&gt; Report the estimated data size to move</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Global variables</span>
<span style="color: #007800;">CONF</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>snapmirror_monitor.conf
<span style="color: #007800;">LOG_PREFIX</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp
&nbsp;
test_connection <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #666666; font-style: italic;"># Test to see that you can access the storage device</span>
        <span style="color: #666666; font-style: italic;"># Arguments: NetApp name</span>
        <span style="color: #007800;">SSH_OPTS</span>=<span style="color: #ff0000;">&quot;-o ConnectTimeout=2&quot;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #007800;">$SSH_OPTS</span> <span style="color: #007800;">$1</span> <span style="color: #c20cb9; font-weight: bold;">hostname</span> <span style="color: #000000; font-weight: bold;">&amp;&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
        <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Cannot communicate via SSH to $1&quot;</span>
                <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
abort <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #666666; font-style: italic;"># Exit with a predefined error message</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$*</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
get_arguments <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #666666; font-style: italic;"># Get all arguments and define options</span>
        <span style="color: #666666; font-style: italic;"># Argument: $@</span>
        <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">--</span> <span style="color: #660033;">-h</span>
        <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
        <span style="color: #000000; font-weight: bold;">do</span>
                <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
                        -m<span style="color: #7a0874; font-weight: bold;">&#41;</span>     <span style="color: #7a0874; font-weight: bold;">shift</span>
                                <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
                                        alert<span style="color: #000000; font-weight: bold;">|</span>throttle_limit<span style="color: #000000; font-weight: bold;">|</span>throttle_unlimit<span style="color: #000000; font-weight: bold;">|</span>check_lag<span style="color: #000000; font-weight: bold;">|</span>check_size<span style="color: #7a0874; font-weight: bold;">&#41;</span>     <span style="color: #007800;">MODE</span>=<span style="color: #007800;">$1</span>
                                        <span style="color: #000000; font-weight: bold;">;;</span>
                                        <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>      abort <span style="color: #ff0000;">&quot;Mode is mandatory. Use -h flag to get list of avialable flags&quot;</span>
                                        <span style="color: #000000; font-weight: bold;">;;</span>
                                <span style="color: #000000; font-weight: bold;">esac</span>
                                <span style="color: #000000; font-weight: bold;">;;</span>
                        -a<span style="color: #7a0874; font-weight: bold;">&#41;</span>     <span style="color: #7a0874; font-weight: bold;">shift</span>
                                <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
                                        <span style="color: #7a0874; font-weight: bold;">&#91;</span>nN<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>oO<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>       <span style="color: #007800;">NOMAIL</span>=<span style="color: #000000;">1</span>
                                                        <span style="color: #000000; font-weight: bold;">;;</span>
                                        <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>              <span style="color: #007800;">NOMAIL</span>=<span style="color: #000000;">0</span>
                                                        <span style="color: #000000; font-weight: bold;">;;</span>
                                <span style="color: #000000; font-weight: bold;">esac</span>
                                <span style="color: #000000; font-weight: bold;">;;</span>
                        -r<span style="color: #7a0874; font-weight: bold;">&#41;</span>     <span style="color: #7a0874; font-weight: bold;">shift</span>
                                <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
                                        <span style="color: #7a0874; font-weight: bold;">&#91;</span>yY<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>eE<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>sS<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>   <span style="color: #007800;">REACT</span>=<span style="color: #000000;">1</span>
                                                        <span style="color: #000000; font-weight: bold;">;;</span>
                                        <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>              <span style="color: #007800;">REACT</span>=<span style="color: #000000;">0</span>
                                                        <span style="color: #000000; font-weight: bold;">;;</span>
                                <span style="color: #000000; font-weight: bold;">esac</span>
                                <span style="color: #000000; font-weight: bold;">;;</span>
                        -d<span style="color: #7a0874; font-weight: bold;">&#41;</span>     <span style="color: #7a0874; font-weight: bold;">shift</span>
                                <span style="color: #7a0874; font-weight: bold;">declare</span> <span style="color: #660033;">-i</span> DELAY_TMP
                                <span style="color: #007800;">DELAY_TMP</span>=<span style="color: #007800;">$1</span>
                                <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DELAY_TMP</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> abort <span style="color: #ff0000;">&quot;Delay needs to be a number in minutes&quot;</span>
                                <span style="color: #007800;">DELAY</span>=<span style="color: #007800;">$DELAY_TMP</span>
                                <span style="color: #000000; font-weight: bold;">;;</span>
                        -t<span style="color: #7a0874; font-weight: bold;">&#41;</span>     <span style="color: #7a0874; font-weight: bold;">shift</span>
                                <span style="color: #7a0874; font-weight: bold;">declare</span> <span style="color: #660033;">-i</span> THROTTLE_TMP
                                <span style="color: #007800;">THROTTLE_TMP</span>=<span style="color: #007800;">$1</span>
                                <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$THROTTLE_TMP</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> abort <span style="color: #ff0000;">&quot;Throttle needs to be a number&quot;</span>
                                <span style="color: #007800;">THROTTLE</span>=<span style="color: #007800;">$THROTTLE_TMP</span>
                                <span style="color: #000000; font-weight: bold;">;;</span>
                        -c<span style="color: #7a0874; font-weight: bold;">&#41;</span>     <span style="color: #7a0874; font-weight: bold;">shift</span>
                                <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">||</span> abort <span style="color: #ff0000;">&quot;Cannot find specified conf file&quot;</span>
                                <span style="color: #007800;">CONF</span>=<span style="color: #ff0000;">&quot;$1&quot;</span>
                                <span style="color: #000000; font-weight: bold;">;;</span>
                        -l<span style="color: #7a0874; font-weight: bold;">&#41;</span>     <span style="color: #007800;">LOG</span>=<span style="color: #000000;">1</span>
                                <span style="color: #000000; font-weight: bold;">;;</span>
                        -h<span style="color: #7a0874; font-weight: bold;">&#41;</span>     <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: $0 -m [alert|throttle_limit|throttle_unlimit|check_lag|check_size] (-c CONF_FILE) [tgt_filer:volume tgt_filer:/vol/vol/qtree]&quot;</span>
                                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Alert if SnapMirror is still running: $0 -m alert [-a no] (-r yes) [tgt_filer:volume tgt_filer:/vol/vol/qtree]&quot;</span>
                                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Alert and throttle (react): $0 -m alert [-a no] -r yes -t [throttle_in_kb] [tgt_filer:volume tgt_filer:/vol/vol/qtree]&quot;</span>
                                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Throttle a running SnapMirror: $0 -m throttle_limit -t throttle_in_kb [tgt_filer:volume tgt_filer:/vol/vol/qtree]&quot;</span>
                                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Unlimit SnapMirror throttle: $0 -m throttle_unlimit [tgt_filer:volume tgt_filer:/vol/vol/qtree]&quot;</span>
                                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;To check lag: $0 -m check_lag -d delay_in_minutes (-a no) [tgt_filer:volume tgt_filer:/vol/vol/qtree]&quot;</span>
                                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;To check delta: $0 -m check_size [tgt_filer:volume tgt_filer:/vol/vol/qtree]&quot;</span>
                                <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>
                                <span style="color: #000000; font-weight: bold;">;;</span>
                        <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>      <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$MODE</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> abort <span style="color: #ff0000;">&quot;$0 mode required&quot;</span>
                                <span style="color: #007800;">TGTS</span>=<span style="color: #ff0000;">&quot;$*&quot;</span>
                                <span style="color: #000000; font-weight: bold;">;;</span>
                <span style="color: #000000; font-weight: bold;">esac</span>
                <span style="color: #7a0874; font-weight: bold;">shift</span>
        <span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
notify <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #666666; font-style: italic;"># Send an e-mail notification</span>
        <span style="color: #666666; font-style: italic;"># Arguments: $@ - the subject</span>
        <span style="color: #666666; font-style: italic;"># Contents are empty</span>
        <span style="color: #666666; font-style: italic;"># And yes - one e-mail per event</span>
        mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;$@&quot;</span> <span style="color: #007800;">$EMAIL</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
idle <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #666666; font-style: italic;"># Check if transaction is idle</span>
        <span style="color: #666666; font-style: italic;"># Arguments: Target name (example: storage:/vol/volname/qtree</span>
&nbsp;
        <span style="color: #666666; font-style: italic;"># Get the storage name out</span>
        <span style="color: #007800;">NETAPP</span>=<span style="color: #800000;">${1%%:*}</span>
        test_connection <span style="color: #007800;">$NETAPP</span> <span style="color: #666666; font-style: italic;">#Verify this netapp is accessible</span>
        <span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #007800;">$NETAPP</span> snapmirror status <span style="color: #007800;">$1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> Idle$ <span style="color: #000000; font-weight: bold;">&amp;&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #666666; font-style: italic;">#Checks if the snapmirror is idle. If so, return true</span>
        <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #007800;">$?</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
set_throttle <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #666666; font-style: italic;"># Sets throttle for target</span>
        <span style="color: #666666; font-style: italic;"># Arguments: $1 Target name (example: storage:/vol/volname/qtree)</span>
        <span style="color: #666666; font-style: italic;"># Arguments: $2 throttle value (number)</span>
&nbsp;
        <span style="color: #666666; font-style: italic;"># Get the storage name out</span>
        <span style="color: #007800;">NETAPP</span>=<span style="color: #800000;">${1%%:*}</span>
        test_connection <span style="color: #007800;">$NETAPP</span> <span style="color: #666666; font-style: italic;">#Verify this netapp is accessible</span>
        <span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #007800;">$NETAPP</span> snapmirror throttle <span style="color: #007800;">$2</span> <span style="color: #007800;">$1</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
get_lag <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #666666; font-style: italic;"># Gets the lag of snapmirror relationship in minutes</span>
        <span style="color: #666666; font-style: italic;"># Arguments: Target name (example: storage:/vol/volname/qtree)</span>
&nbsp;
        <span style="color: #666666; font-style: italic;"># Get the storage name out</span>
        <span style="color: #007800;">NETAPP</span>=<span style="color: #800000;">${1%%:*}</span>
        test_connection <span style="color: #007800;">$NETAPP</span> <span style="color: #666666; font-style: italic;">#Verify this netapp is accessible</span>
        <span style="color: #007800;">LAG</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #007800;">$NETAPP</span> snapmirror status <span style="color: #007800;">$1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $4}'</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #666666; font-style: italic;"># LAG is in hh:mm:ss. We need to transfer it to minutes only</span>
        <span style="color: #007800;">H</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$LAG</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-f</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-d</span> :<span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #007800;">M</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$LAG</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-f</span> <span style="color: #000000;">2</span> <span style="color: #660033;">-d</span> :<span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #007800;">M</span>=<span style="color: #007800;">$M</span>+<span style="color: #007800;">$H</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">60</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$M</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
check_size <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #666666; font-style: italic;"># Checks the size of the snapshot to copy (diff)</span>
        <span style="color: #666666; font-style: italic;"># Arguments: Target name (example: storage:/vol/volname/qtree)</span>
&nbsp;
        <span style="color: #666666; font-style: italic;"># Get the storage name out</span>
        <span style="color: #007800;">NETAPP</span>=<span style="color: #800000;">${1%%:*}</span>
        test_connection <span style="color: #007800;">$NETAPP</span> <span style="color: #666666; font-style: italic;">#Verify this netapp is accessible</span>
        <span style="color: #666666; font-style: italic;"># Get source storage name and path</span>
        <span style="color: #007800;">SRC</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #007800;">$NETAPP</span> snapmirror status <span style="color: #007800;">$1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #666666; font-style: italic;"># Get the source filer and vol name from that</span>
        <span style="color: #007800;">NETAPP</span>=<span style="color: #800000;">${SRC%%:*}</span>
        <span style="color: #007800;">SPATH</span>=<span style="color: #800000;">${SRC##*:}</span>
        <span style="color: #007800;">SPATH</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$SPATH</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> s<span style="color: #000000; font-weight: bold;">/</span><span style="color: #ff0000;">'\/vol\/'</span><span style="color: #000000; font-weight: bold;">//`</span>
        <span style="color: #007800;">SPATH</span>=<span style="color: #800000;">${SPATH%%/*}</span>
&nbsp;
        test_connection <span style="color: #007800;">$NETAPP</span> <span style="color: #666666; font-style: italic;"># Verify the target NetApp is accessible</span>
        <span style="color: #007800;">SNAP</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #007800;">$NETAPP</span> snap list <span style="color: #660033;">-n</span> <span style="color: #007800;">$SPATH</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> snapmirror <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $4}'</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #007800;">DELTA</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #007800;">$NETAPP</span> snap delta <span style="color: #007800;">$SPATH</span> <span style="color: #007800;">$SNAP</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-2</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">head</span> <span style="color: #660033;">-1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $5}'</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Snap delta for $1 is <span style="color: #007800;">$DELTA</span> KB&quot;</span>  
        <span style="color: #007800;">LOG_TARGET</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #000000; font-weight: bold;">/</span> _<span style="color: #000000; font-weight: bold;">`</span>.txt
        <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$LOG</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #780078;">`date`</span> <span style="color: #007800;">$DELTA</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOG_PREFIX</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$LOG_TARGET</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">### MAIN ###</span>
get_arguments $<span style="color: #000000; font-weight: bold;">@</span>
. <span style="color: #007800;">$CONF</span> <span style="color: #000000; font-weight: bold;">&amp;&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
<span style="color: #666666; font-style: italic;"># if e-mail is not set, don't try to send</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$EMAIL</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #007800;">NOMAIL</span>=<span style="color: #000000;">1</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TGTS</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> abort <span style="color: #ff0000;">&quot;You need at least one snapmirror target&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #007800;">$MODE</span> <span style="color: #000000; font-weight: bold;">in</span>
        alert<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$REACT</span>&quot;</span> == <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
                <span style="color: #000000; font-weight: bold;">then</span>
                        <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$THROTTLE</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> abort <span style="color: #ff0000;">&quot;When setting 'react' flag, you must specify throttle&quot;</span>
                <span style="color: #000000; font-weight: bold;">fi</span>
                <span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$TGTS</span>
                <span style="color: #000000; font-weight: bold;">do</span>
                        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">!</span> idle <span style="color: #007800;">$i</span>
                        <span style="color: #000000; font-weight: bold;">then</span>
                                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$i</span> is not idle. &quot;</span>
                                <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$NOMAIL</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> notify <span style="color: #ff0000;">&quot;<span style="color: #007800;">$i</span> is not idle&quot;</span>
                                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$REACT</span>&quot;</span> == <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
                                <span style="color: #000000; font-weight: bold;">then</span>
                                        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;We are set to react. Limiting throttle&quot;</span>
                                        set_throttle <span style="color: #007800;">$i</span> <span style="color: #007800;">$THROTTLE</span>
                                <span style="color: #000000; font-weight: bold;">fi</span>
                                <span style="color: #7a0874; font-weight: bold;">echo</span>
                        <span style="color: #000000; font-weight: bold;">fi</span>
                <span style="color: #000000; font-weight: bold;">done</span>
                <span style="color: #000000; font-weight: bold;">;;</span>
        throttle_limit<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$THROTTLE</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> abort <span style="color: #ff0000;">&quot;Throttle requires throttle value&quot;</span>
                        <span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$TGTS</span>
                        <span style="color: #000000; font-weight: bold;">do</span>
                                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Setting throttle for <span style="color: #007800;">$i</span> to <span style="color: #007800;">$THROTTLE</span>&quot;</span>
                                set_throttle <span style="color: #007800;">$i</span> <span style="color: #007800;">$THROTTLE</span>
                        <span style="color: #000000; font-weight: bold;">done</span>
                        <span style="color: #000000; font-weight: bold;">;;</span>
        throttle_unlimit<span style="color: #7a0874; font-weight: bold;">&#41;</span>       <span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$TGTS</span>
                                <span style="color: #000000; font-weight: bold;">do</span>
                                        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Setting throttle for <span style="color: #007800;">$i</span> to unlimited&quot;</span>
                                        set_throttle <span style="color: #007800;">$i</span> <span style="color: #000000;">0</span>
                                <span style="color: #000000; font-weight: bold;">done</span>
                        <span style="color: #000000; font-weight: bold;">;;</span>
        check_lag<span style="color: #7a0874; font-weight: bold;">&#41;</span>      <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DELAY</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #007800;">DELAY</span>=<span style="color: #000000;">1440</span>
                        <span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$TGTS</span>
                        <span style="color: #000000; font-weight: bold;">do</span>
                                <span style="color: #007800;">LAG</span>=<span style="color: #000000; font-weight: bold;">`</span>get_lag <span style="color: #007800;">$i</span><span style="color: #000000; font-weight: bold;">`</span>
                                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$LAG</span>&quot;</span> <span style="color: #660033;">-gt</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DELAY</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
                                <span style="color: #000000; font-weight: bold;">then</span>
                                        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Failure: The delay for <span style="color: #007800;">$i</span> is <span style="color: #007800;">$LAG</span> minutes&quot;</span>
                                        <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$NOMAIL</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> notify <span style="color: #ff0000;">&quot;<span style="color: #007800;">$i</span> is lagged <span style="color: #007800;">$LAG</span> minutes, above the threshold <span style="color: #007800;">$DELAY</span>&quot;</span>
                                <span style="color: #000000; font-weight: bold;">else</span>
                                        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Normal: The delay for <span style="color: #007800;">$i</span> is <span style="color: #007800;">$LAG</span> minutes&quot;</span>
                                <span style="color: #000000; font-weight: bold;">fi</span>
                        <span style="color: #000000; font-weight: bold;">done</span>
                        <span style="color: #000000; font-weight: bold;">;;</span>
        check_size<span style="color: #7a0874; font-weight: bold;">&#41;</span>     <span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$TGTS</span>
                        <span style="color: #000000; font-weight: bold;">do</span>
                                check_size <span style="color: #007800;">$i</span>
                        <span style="color: #000000; font-weight: bold;">done</span>
                        <span style="color: #000000; font-weight: bold;">;;</span>
        <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>      <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Option <span style="color: #007800;">$MODE</span> is not implemented yet&quot;</span>
                <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>
                <span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span></pre></td></tr></table></div>



<p>Related posts:<ol><li><a href='http://run.tournament.org.il/citrix-xenserver-5-0-cannot-cooperate-with-netapp-snapmirror/' rel='bookmark' title='Permanent Link: Citrix XenServer 5.0 cannot cooperate with NetApp SnapMirror'>Citrix XenServer 5.0 cannot cooperate with NetApp SnapMirror</a> <small>It has been a long while, I know. I was...</small></li>
<li><a href='http://run.tournament.org.il/netapp-ontap-71/' rel='bookmark' title='Permanent Link: NetApp Ontap 7.1'>NetApp Ontap 7.1</a> <small>I&#8217;ve had the pleasure of playing with Ontap Simulator. This...</small></li>
<li><a href='http://run.tournament.org.il/ontap-simulator-and-some-insights-about-netapp/' rel='bookmark' title='Permanent Link: Ontap Simulator, and some insights about NetApp'>Ontap Simulator, and some insights about NetApp</a> <small>First and foremost &#8211; the Ontap simulator, a great tool...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://run.tournament.org.il/netapp-snapmirror-monitor-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rapid-guide &#8211; Updating RedHat initrd</title>
		<link>http://run.tournament.org.il/rapid-guide-updating-redhat-initrd/</link>
		<comments>http://run.tournament.org.il/rapid-guide-updating-redhat-initrd/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 21:46:09 +0000</pubDate>
		<dc:creator>ez-aton</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[boot loader]]></category>
		<category><![CDATA[initrd]]></category>
		<category><![CDATA[storage drivers]]></category>

		<guid isPermaLink="false">http://run.tournament.org.il/?p=497</guid>
		<description><![CDATA[Warning: This is not the recommended method if you&#8217;re not sure you know what you&#8217;re doing.
Linux Initial Ram Disk (initrd) is a mechanism to perform disk-independent actions before attempting to mount the &#8216;/&#8217; disk. These actions usually include loading disk drivers, setting up LVM or software RAID, etc.
The reason these actions are performed within initrd is that [...]


Related posts:<ol><li><a href='http://run.tournament.org.il/quick-and-dirty-modifying-boel-initrd-files-manually/' rel='bookmark' title='Permanent Link: Quick and dirty &#8211; modifying Boel initrd files manually'>Quick and dirty &#8211; modifying Boel initrd files manually</a> <small>Boel initrd files are actually compressed cramfs files. This is...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Warning: This is not the recommended method if you&#8217;re not sure you know what you&#8217;re doing.</p>
<p>Linux Initial Ram Disk (initrd) is a mechanism to perform disk-independent actions before attempting to mount the &#8216;/&#8217; disk. These actions usually include loading disk drivers, setting up LVM or software RAID, etc.</p>
<p>The reason these actions are performed within initrd is that it is all based on Ram Disk loaded by the boot loader, and thus it breaks the loop of &#8220;how would I load storage drivers without storage access?&#8221;</p>
<p>It happens that due to some special even we need to modify it manually. To do so we need first to open it, and then to close it back in, replacing (backup the old one, will you?) the previous one.</p>
<p>This is rather simple. The tools used by us will be &#8216;gzip&#8217; and &#8216;cpio&#8217;.</p>
<p>Lets begin.</p>
<p>First &#8211; create a temporary directory:</p>
<blockquote><p>mkdir /tmp/initrd</p></blockquote>
<p><span style="text-decoration: underline;">Extracting</span></p>
<p>We have our temporary directory, so now, we need to extract the initrd into it. I assume the name of the file is /boot/initrd.img. You should replace my line with whatever the name of your initrd file:</p>
<blockquote><p>cd /tmp/initrd</p>
<p>cat /boot/initrd.img | gzip -dc |  cpio -id</p></blockquote>
<p>This will extract the contents of the initrd into /tmp/initrd.</p>
<p>Now you can edit its contents directly.</p>
<p><span style="text-decoration: underline;">Package</span></p>
<p>To package initrd back in, we will need to perform the following actions.</p>
<p>Warning &#8211; before you do it, make sure you have an available copy of your original initrd file, in case you have created some damage.</p>
<blockquote><p>cd /tmp/initrd</p>
<p>find . | cpio -o -H newc | gzip -9 &gt; /boot/initrd.img</p></blockquote>
<p>This line packages the initrd, and replaces the old one.</p>
<p>That&#8217;s all for today <img src='http://run.tournament.org.il/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>


<p>Related posts:<ol><li><a href='http://run.tournament.org.il/quick-and-dirty-modifying-boel-initrd-files-manually/' rel='bookmark' title='Permanent Link: Quick and dirty &#8211; modifying Boel initrd files manually'>Quick and dirty &#8211; modifying Boel initrd files manually</a> <small>Boel initrd files are actually compressed cramfs files. This is...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://run.tournament.org.il/rapid-guide-updating-redhat-initrd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quickly install Xen Community Linux VM</title>
		<link>http://run.tournament.org.il/quickly-install-xen-community-linux-vm/</link>
		<comments>http://run.tournament.org.il/quickly-install-xen-community-linux-vm/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 21:35:01 +0000</pubDate>
		<dc:creator>ez-aton</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[provisioning]]></category>
		<category><![CDATA[Xen]]></category>

		<guid isPermaLink="false">http://run.tournament.org.il/?p=494</guid>
		<description><![CDATA[On RHEL-type of systems, with virt-manager (libvirt), you can make use of virt-manager to easy your life. I, for myself, prefer to work with &#8216;xm&#8216; tools, but for the initial install, virt-manager is the quickest and most simple available tool.
To install a new Linux VM, all you need to follow this flow
Create an LV for [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>On RHEL-type of systems, with virt-manager (libvirt), you can make use of virt-manager to easy your life. I, for myself, prefer to work with &#8216;<em>xm</em>&#8216; tools, but for the initial install, virt-manager is the quickest and most simple available tool.</p>
<p>To install a new Linux VM, all you need to follow this flow</p>
<p>Create an LV for your VM (I use LVs because it&#8217;s easier to manage). If not LV, use a file. To create an LV, run the following command</p>
<blockquote><p>lvcreate -L 10G -n new_vm1 VolGroup00</p></blockquote>
<p>I assume that the name you wish to grant is &#8216;new_vm1&#8242; (better maintain order there, else you will find yourself with hundreds of small LVs you have no idea what to do with), and that the name of the volume group is &#8216;VolGroup00&#8242;. Change to different values to match your environment.</p>
<p>Next, make sure you have your ISO contents unpacked (you can use loop device) and exported via NFS (my favorite method).</p>
<p>To mount a CD/DVD ISO, you should use &#8216;mount&#8217; command with the &#8216;loop&#8217; options. This would look like this:</p>
<blockquote><p>mount -o loop my_iso.iso /mnt/temp</p></blockquote>
<p>Again, I assume the name of the ISO is my_iso.iso and that the target directory /mnt/temp is available.</p>
<p>Now, export your newly created directory. If you have NFS already running, you can either add to /etc/exports the newly mounted directory /mnt/temp and restart the &#8216;nfs&#8217; service, or you could use &#8216;exportfs&#8217; to add it:</p>
<p>exportfs -o no_root_squash *:/mnt/temp</p>
<p>would probably do the trick. I added &#8216;no_root_squash&#8217; to make sure no permission/access problems present themselves during the installation phase. Test your export to verify it&#8217;s working.</p>
<p>Now you could begin your installation. Run the following command:</p>
<blockquote><p>virt-install -n new_vm1 -r 512 -p -f /dev/VolGroup00/new_vm1 &#8211;nographics nfs://nfs_server:/mnt/temp</p></blockquote>
<p>The name follows the &#8216;-n&#8217; flag. The amount of RAM to give is 512MB. The -p means it&#8217;s paravirtualized. The -f shows which device will be the block device, and the last argument is the source of the installation. Do not use local files, as the VM installer should be able to access the installation source.</p>
<p>Following that, you should have a very nice TUI installation experience.</p>
<p>Now &#8211; let&#8217;s make this machine &#8216;xm&#8217; compatible.</p>
<p>Currently, the VM is virt-manager compatible. It means you need virt-manager to start/stop it correctly. Since I prefer &#8216;xm&#8217; commands, I will show you how to convert this machine to VM.</p>
<p>First &#8211; export its XML file:</p>
<blockquote><p>virsh dumpxml new_vm1 &gt; /tmp/new_vm1.xml</p>
<p>virsh domxml-to-native xen-xm /tmp/new_vm1.xml &gt; /etc/xen/new_vm1</p></blockquote>
<p>This should do the trick.</p>
<p>Now you can turn the newly created VM off, and remove the VM from virt-manager using</p>
<blockquote><p>virsh undefine new_vm1</p></blockquote>
<p>and you&#8217;re back to &#8216;xm&#8217;-only interface.</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://run.tournament.org.il/quickly-install-xen-community-linux-vm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iSCSI persistent configurations agains us all</title>
		<link>http://run.tournament.org.il/iscsi-persistent-configurations-agains-us-all/</link>
		<comments>http://run.tournament.org.il/iscsi-persistent-configurations-agains-us-all/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 08:47:49 +0000</pubDate>
		<dc:creator>ez-aton</dc:creator>
				<category><![CDATA[Disk Storage]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[iSCSI]]></category>
		<category><![CDATA[multipath]]></category>

		<guid isPermaLink="false">http://run.tournament.org.il/?p=492</guid>
		<description><![CDATA[Using iSCSI with dm-multipath is rather common setup. With iSCSI running over Ethernet cables, which are too easy to disconnect (either on purpose or by mistake), being cheap and common technology &#8211; multipath becomes a must. If you have multiple network links, this is only expected that you use multipath for your iSCSI configuration. It&#8217;s [...]


Related posts:<ol><li><a href='http://run.tournament.org.il/persistent-raw-devices-for-oracle-rac-with-iscsi/' rel='bookmark' title='Permanent Link: Persistent raw devices for Oracle RAC with iSCSI'>Persistent raw devices for Oracle RAC with iSCSI</a> <small>Using udev to set persistent raw devices for iscsi in...</small></li>
<li><a href='http://run.tournament.org.il/iscsi-targetclient-for-linux-in-5-whole-minutes/' rel='bookmark' title='Permanent Link: iSCSI target/client for Linux in 5 whole minutes'>iSCSI target/client for Linux in 5 whole minutes</a> <small>I was playing a bit with iSCSI initiator (client) and...</small></li>
<li><a href='http://run.tournament.org.il/oracle-rac-with-emc-iscsi-storage-panics/' rel='bookmark' title='Permanent Link: Oracle RAC with EMC iSCSI Storage Panics'>Oracle RAC with EMC iSCSI Storage Panics</a> <small>I have had a system panicking when running the mentioned...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Using iSCSI with dm-multipath is rather common setup. With iSCSI running over Ethernet cables, which are too easy to disconnect (either on purpose or by <a href="http://run.tournament.org.il/correct-rack-wiring-tips-tricks-with-pictures/" target="_blank">mistake</a>), being cheap and common technology &#8211; multipath becomes a must. If you have multiple network links, this is only expected that you use multipath for your iSCSI configuration. It&#8217;s cheap, it&#8217;s easy and it works.</p>
<p>This, however, comes with a price tag. Not money &#8211; the components are cheap and common, but there are configuration acts which should take place.</p>
<p>It is easy to find info either in the open-iscsi documentations, the Internet, whatever, and I will go over them just below, but there are some catches which one should be aware of.</p>
<p>Per the common documentation, unlike regular iSCSI communication, when dealing with multipath, you would like iSCSI to fail rather quickly and let the SCSI layer handle the errors, thus letting dm-multipath handle the errors and do its work.</p>
<p>The configuration directives are rather simple. In the iscsid.conf file (on RHEL5 located in /etc/iscsi/iscsid.conf ), you need to change the value</p>
<blockquote>
<pre><a id="d0e2106">node.session.timeo.replacement_timeout =</a></pre>
</blockquote>
<p>To a very short period of time. By default, it is set to 120 seconds, which are two minutes before anyone will notify the SCSI subsystem of any disk IO errors. A good value would be 5 seconds, which should allow for very short network disconnection (which could happen) and still &#8211; let the dm-multipath manage errors fast enough so that applications would not fail on disk timeouts.</p>
<p>Another two parameters which should be defined are the following (read the comments above them in the config file):</p>
<blockquote>
<pre><a id="d0e2010">node.conn[0].timeo.noop_out_interval =
<pre>node.conn[0].timeo.noop_out_timeout =</pre>
<p></a></pre>
</blockquote>
<p>These values control the interval in which the iSCSI layer tests communication to the targets.</p>
<p>Also, in multipath.conf you will need to set the following feature, so that IOPs will not be lost:</p>
<blockquote>
<pre><a id="d0e1975">features		"1 queue_if_no_path"</a></pre>
</blockquote>
<p>These configuration directives can be found in these two pages from RedHat:</p>
<p><a href="http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/html/Online_Storage_Reconfiguration_Guide/iscsi-modifying-link-loss-behavior-dmmultipath.html" target="_blank">iscsi-modifying-link-loss-behavior-dmmultipath</a></p>
<p><a href="http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/html/Online_Storage_Reconfiguration_Guide/iscsi-replacements_timeout.html" target="_blank">iscsi-replacements_timeout</a></p>
<p>This is nice and pretty. However, if you have failed to do so at start, and defined your iSCSI targets based on the default configurations, you will notice that it still takes very long for iSCSI to notify the SCSI subsystem of the errors. You could check the values used by iSCSI through running the command:</p>
<blockquote><p>iscsiadm -m node -T &lt;target name&gt;</p></blockquote>
<p>Check out especially the line called <em>node.session.timeo.replacement_timeout</em>. Its value is the one which decides the actual behavior of iSCSI.</p>
<p>To change it, there are several methods. One of them is to clean up the iSCSI persistent configurations, located in /var/lib/iscsi and then re-login to the iSCSI targets. Only then you will have the new target configuration.</p>
<p>Check again with iscsiadm as described above, and check that this value matches.</p>


<p>Related posts:<ol><li><a href='http://run.tournament.org.il/persistent-raw-devices-for-oracle-rac-with-iscsi/' rel='bookmark' title='Permanent Link: Persistent raw devices for Oracle RAC with iSCSI'>Persistent raw devices for Oracle RAC with iSCSI</a> <small>Using udev to set persistent raw devices for iscsi in...</small></li>
<li><a href='http://run.tournament.org.il/iscsi-targetclient-for-linux-in-5-whole-minutes/' rel='bookmark' title='Permanent Link: iSCSI target/client for Linux in 5 whole minutes'>iSCSI target/client for Linux in 5 whole minutes</a> <small>I was playing a bit with iSCSI initiator (client) and...</small></li>
<li><a href='http://run.tournament.org.il/oracle-rac-with-emc-iscsi-storage-panics/' rel='bookmark' title='Permanent Link: Oracle RAC with EMC iSCSI Storage Panics'>Oracle RAC with EMC iSCSI Storage Panics</a> <small>I have had a system panicking when running the mentioned...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://run.tournament.org.il/iscsi-persistent-configurations-agains-us-all/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XenServer &#8220;Internal error: Failure&#8230; no loader found&#8221;</title>
		<link>http://run.tournament.org.il/xenserver-internal-error-failure-no-loader-found/</link>
		<comments>http://run.tournament.org.il/xenserver-internal-error-failure-no-loader-found/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 11:42:13 +0000</pubDate>
		<dc:creator>ez-aton</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[grub]]></category>
		<category><![CDATA[troubleshooting]]></category>
		<category><![CDATA[Xen]]></category>
		<category><![CDATA[XenServer]]></category>

		<guid isPermaLink="false">http://run.tournament.org.il/?p=489</guid>
		<description><![CDATA[It has been long since I had the time to write here. I have recently been involved more and more with XenServer virtualization, as you might see in the blogs, and following a solution to a rather common problem, I have decided to post it here.
The problem: When attempting to boot a Linux VM on [...]


Related posts:<ol><li><a href='http://run.tournament.org.il/xenserver-create-snapshots-for-all-machines/' rel='bookmark' title='Permanent Link: XenServer create snapshots for all machines'>XenServer create snapshots for all machines</a> <small>XenServer is a wonderful tool. One of the better parts...</small></li>
<li><a href='http://run.tournament.org.il/power-supply-failure-the-wrong-type-of-failure/' rel='bookmark' title='Permanent Link: Power Supply failure &#8211; the wrong type of failure'>Power Supply failure &#8211; the wrong type of failure</a> <small>I&#8217;ve lost an external DAS (Direct Attached Storage) today. Not...</small></li>
<li><a href='http://run.tournament.org.il/citrix-xenserver-5-0-cannot-cooperate-with-netapp-snapmirror/' rel='bookmark' title='Permanent Link: Citrix XenServer 5.0 cannot cooperate with NetApp SnapMirror'>Citrix XenServer 5.0 cannot cooperate with NetApp SnapMirror</a> <small>It has been a long while, I know. I was...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>It has been long since I had the time to write here. I have recently been involved more and more with XenServer virtualization, as you might see in the blogs, and following a solution to a rather common problem, I have decided to post it here.</p>
<p>The problem: When attempting to boot a Linux VM on XenServer (5.0 and 5.5), you get the following error message:</p>
<blockquote><p>Error: Starting VM &#8216;Cacti&#8217; &#8211; Internal error: Failure(&#8220;Error from xenguesthelper: caught exception: Failure(\\\&#8221;Subprocess failure: Failure(\\\\\\\&#8221;xc_dom_linux_build: [2] xc_dom_find_loader: no loader found\\\\\\\\n\\\\\\\&#8221;)\\\&#8221;)&#8221;)</p></blockquote>
<p>This is very common with Linux VMs which were converted from physical (or other, non-PV virtualization) to XenServer.</p>
<p>This will probably either happen during the P2V process, or after a successful update to the Linux VM.</p>
<p>The cause is that the original kernel, non PV-aware one, has not been removed, and GRUB likes to load from it. XenServer will use the GRUB menu, but will not display it to us to select our desired kernel.</p>
<p>With no chance to intervene, XenServer will attempt to load a PV-enabled machine using non-PV kernel, and will fail.</p>
<p>Preventing the problem is quite simple &#8211; remove your non-PV kernel (non-xen) so that future updates will not attempt to update it as well and set it to be the default kernel. Very simple.</p>
<p>Solving the problem in less than two minutes is a bit more tricky. Let&#8217;s see how to solve it.</p>
<p>All operations are performed from within the control domain. This guide does not apply to StorageLink or NetApp/Equalogic devices, as they behave differently. This applies only to LVM-over-something, whatever it may be.</p>
<p>First, we will need to find the name of the VDI we are to work on. Use xe in the following manner, using the VM&#8217;s name:</p>
<blockquote><p>xe vbd-list vm-name-label=Cacti</p>
<p>uuid ( RO)             : 128f29dc-4a14-1a2d-75d1-8674d3d2403b<br />
vm-uuid ( RO): eae053de-4a20-28a5-f335-f5a18dd79993<br />
vm-name-label ( RO): Cacti<br />
vdi-uuid ( RO): <strong>90524af4-5b20-4412-9bfe-f1fe27f220b1</strong><br />
empty ( RO): false<br />
device ( RO): xvda</p>
<p>uuid ( RO)             : de177727-b28a-8b79-e73e-d08366d56277<br />
vm-uuid ( RO): eae053de-4a20-28a5-f335-f5a18dd79993<br />
vm-name-label ( RO): Cacti<br />
vdi-uuid ( RO): &lt;not in database&gt;<br />
empty ( RO): true<br />
device ( RO): xvdd</p></blockquote>
<p>It is very common that xvdd is used for CDROM, so we can safely ignore the second section. The first section is the more interesting one. There is a correlation between the name of the VDI and the name of the LVM on the disk. We can find this specific LV using the following command. Notice that the name of the VDI is used here as the argument for the &#8216;grep&#8217; command:</p>
<blockquote><p>lvs | grep <strong>90524af4-5b20-4412-9bfe-f1fe27f220b1 </strong></p>
<p>LV-90524af4-5b20-4412-9bfe-f1fe27f220b1 VG_XenStorage-4aa20fc2-fd92-20c2-c549-bed2597c622b -wi-a-  10.00G</p></blockquote>
<p>We now have our LV path! As you can see, its status is offline. We need to set it to online state. Using both the LV and the VG name, we can do it like that:</p>
<blockquote><p>lvchange -ay /dev/VG_XenStorage-4aa20fc2-fd92-20c2-c549-bed2597c622b/LV-90524af4-5b20-4412-9bfe-f1fe27f220b1</p></blockquote>
<p>Now we can access the volume. We can actually check that the problem is the one we look for, using pygrub:</p>
<blockquote><p>pygrub /dev/VG_XenStorage-4aa20fc2-fd92-20c2-c549-bed2597c622b/LV-90524af4-5b20-4412-9bfe-f1fe27f220b1</p></blockquote>
<p>We should now see the GRUB menu of the VM at question. If you don&#8217;t see any menu, either you have missed a step or used the wrong disk.</p>
<p>The menu should show you all the list of kernels. The default one is the one highlighted, and if it doesn&#8217;t include the word &#8220;xen&#8221; with it, most likely that we have found the problem.</p>
<p>We now need to change to a PV-capable kernel. We will need to access the &#8220;/boot&#8221; partition of the Linux VM, and change GRUB&#8217;s options there.</p>
<p>First we map the disk to a loop device, so we can access its partitions:</p>
<blockquote><p>losetup /dev/loop1 /dev/VG_XenStorage-4aa20fc2-fd92-20c2-c549-bed2597c622b/LV-90524af4-5b20-4412-9bfe-f1fe27f220b1</p></blockquote>
<p>Notice that you need to use the entire path to the LV, that the LV is online, and that loop1 is not in use. If it is, you will have a message saying something like &#8220;LOOP_SET_FD: Device or resource busy&#8221;</p>
<p>Now we need to access its partitions. We will map them using &#8216;kpartx&#8217; to /dev/mapper/ devices. Notice we&#8217;re using the same loop device name:</p>
<blockquote><p>kaprtx -a /dev/loop1</p></blockquote>
<p>Now, new files present themselves in /dev/mapper:</p>
<blockquote><p>ls -la /dev/mapper/<br />
total 0<br />
drwxr-xr-x  2 root root     220 Oct 24 12:39 .<br />
drwxr-xr-x 14 root root   16560 Oct 24 12:31 ..<br />
crw&#8212;&#8212;-  1 root root  10, 62 Sep 29 10:15 control<br />
brw-rw&#8212;-  1 root disk 252,  5 Oct 24 12:39 <strong>loop1p1</strong><br />
brw-rw&#8212;-  1 root disk 252,  6 Oct 24 12:39 <strong>loop1p2</strong><br />
brw-rw&#8212;-  1 root disk 252,  7 Oct 24 12:39 <strong>loop1p3</strong></p></blockquote>
<p>Usually, the first partition represents /boot, so we can now mount it and work on it:</p>
<blockquote><p>mount /dev/mapper/loop1p1 /mnt</p></blockquote>
<p>All we need to do is edit /mnt/grub/menu.lst to match our requirements, and then wrap everything back up:</p>
<blockquote><p>umount /mnt</p>
<p>kpartx -u /dev/loop1</p>
<p>losetup -d /dev/loop1</p></blockquote>
<p>We don&#8217;t have to change the LV to offline, because the XenServer will activate it if it&#8217;s not, however, we could do it, to be on the safe side:</p>
<blockquote><p>lvchange -an /dev/VG_XenStorage-4aa20fc2-fd92-20c2-c549-bed2597c622b/LV-90524af4-5b20-4412-9bfe-f1fe27f220b1</p></blockquote>
<p>Now we can activate the VM, and see it boot successfully.</p>
<p>This whole process takes several minutes the first time, and even less later.</p>
<p>I hope this helps.</p>


<p>Related posts:<ol><li><a href='http://run.tournament.org.il/xenserver-create-snapshots-for-all-machines/' rel='bookmark' title='Permanent Link: XenServer create snapshots for all machines'>XenServer create snapshots for all machines</a> <small>XenServer is a wonderful tool. One of the better parts...</small></li>
<li><a href='http://run.tournament.org.il/power-supply-failure-the-wrong-type-of-failure/' rel='bookmark' title='Permanent Link: Power Supply failure &#8211; the wrong type of failure'>Power Supply failure &#8211; the wrong type of failure</a> <small>I&#8217;ve lost an external DAS (Direct Attached Storage) today. Not...</small></li>
<li><a href='http://run.tournament.org.il/citrix-xenserver-5-0-cannot-cooperate-with-netapp-snapmirror/' rel='bookmark' title='Permanent Link: Citrix XenServer 5.0 cannot cooperate with NetApp SnapMirror'>Citrix XenServer 5.0 cannot cooperate with NetApp SnapMirror</a> <small>It has been a long while, I know. I was...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://run.tournament.org.il/xenserver-internal-error-failure-no-loader-found/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Citrix XenServer 5.0 cannot cooperate with NetApp SnapMirror</title>
		<link>http://run.tournament.org.il/citrix-xenserver-5-0-cannot-cooperate-with-netapp-snapmirror/</link>
		<comments>http://run.tournament.org.il/citrix-xenserver-5-0-cannot-cooperate-with-netapp-snapmirror/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 23:55:48 +0000</pubDate>
		<dc:creator>ez-aton</dc:creator>
				<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[citrix]]></category>
		<category><![CDATA[luns]]></category>
		<category><![CDATA[netapp]]></category>
		<category><![CDATA[snapshot]]></category>
		<category><![CDATA[snapshots]]></category>
		<category><![CDATA[vdi]]></category>
		<category><![CDATA[XenServer]]></category>

		<guid isPermaLink="false">http://run.tournament.org.il/?p=487</guid>
		<description><![CDATA[It has been a long while, I know. I was busy with life, work and everything around it. Not much worth mentioning.
This, however, is something else.
I have discovered an issue with Citrix XenServer 5.0 (probably the case with 5.5, but I have other issues with that release) using NetApp through NetApp API SR &#8211; Any [...]


Related posts:<ol><li><a href='http://run.tournament.org.il/netapp-snapmirror-monitor-script/' rel='bookmark' title='Permanent Link: NetApp SnapMirror monitor script'>NetApp SnapMirror monitor script</a> <small>I have had some work done lately with NetApp SnapMirror....</small></li>
<li><a href='http://run.tournament.org.il/xenserver-create-snapshots-for-all-machines/' rel='bookmark' title='Permanent Link: XenServer create snapshots for all machines'>XenServer create snapshots for all machines</a> <small>XenServer is a wonderful tool. One of the better parts...</small></li>
<li><a href='http://run.tournament.org.il/ontap-simulator-and-some-insights-about-netapp/' rel='bookmark' title='Permanent Link: Ontap Simulator, and some insights about NetApp'>Ontap Simulator, and some insights about NetApp</a> <small>First and foremost &#8211; the Ontap simulator, a great tool...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>It has been a long while, I know. I was busy with life, work and everything around it. Not much worth mentioning.</p>
<p>This, however, is something else.</p>
<p>I have discovered an issue with Citrix XenServer 5.0 (probably the case with 5.5, but I have other issues with that release) using NetApp through NetApp API SR &#8211; Any non XenServer-generated snapshot will be deleted as soon as any snapshot-related action would be performed on that volume. Meaning that if I had manually created a snapshot called &#8220;1111&#8243; (short and easy to recognize, especially with all these UUID-based volumes, LUNs and snapshot names XenServer uses&#8230;), the next time anyone would create a snapshot of a machine which has a disk (VDI) on this specific volume, the snapshot, my snapshot, &#8220;1111&#8243; will be removed under that specific volume. The message seen in /var/log/SMlog would look like this:</p>
<blockquote><p>Removing unused snap (1111)</p></blockquote>
<p>While under normal operation, this does not matter much, as non-XenServer snapshots have little value, when using NetApp SnapMirror technology, the mechanism works a bit differently.</p>
<p>It appears that the SnapMirror system takes snapshots with predefined names (non-XenServer UUID type, luckily for us all). These snapshots include the entire changes performed since the last SnapMirror snapshots, and are used for replication. Unfortunately, XenServer deletes them. No SnapMirror snapshots, well, this is quite obvious, is it not? No SnapMirror&#8230;</p>
<p>We did not detect this problem immediately, and I should take the blame for that. I had to define a set of simple trial and error tests, as described above, instead of battling with a system I did not quite follow at that time &#8211; NetApp SnapMirror. Now I do, however, and I have this wonderful insight which can make your personal life, if you had issues with SnapMirror and XenServer, and did not know how to make it work, better. This solution cannot be an official one, due to its nature, which you will understand shortly. This is a personal patch for your pleasure, based on the hard fact that SnapMirror uses a predefined name for its snapshots. This name, in my case, is the name of the DR storage device. You <strong>must</strong> figure out what name is being used as part of the snapshot naming convention on your own site. Search for my &#8217;storagedr&#8217; phrase, and replace it with yours.</p>
<p>This is the diff file for /opt/xensource/sm/NETAPPSR.py . Of course &#8211; back up your original file. Also &#8211; this is not an official patch. It was tested to function correctly on XenServer 5.0, and it will not work on XenServer 5.5 (since NETAPPSR.py is different). Last warning &#8211; it might break on the next update or upgrade you have for your XenServer environment, and if that happens, you better monitor your SnapMirror status closely then.</p>
<pre filename="NETAPPSR.py.diff" colla="+">
400,403c400,404
<                     util.SMlog("Removing unused snap (%s)" % val)
<                     out = netapplib.fvol_snapdelete_wrapper(self.sv, val, volname)
<                     if not na_test_result(out):
<                         pass
---
> 		    if 'storagedr' not in val:
>                     	util.SMlog("Removing unused snap (%s)" % val)
>                     	out = netapplib.fvol_snapdelete_wrapper(self.sv, val, volname)
>                     	if not na_test_result(out):
>                         	pass
</pre>
<p>Hope it helps!</p>


<p>Related posts:<ol><li><a href='http://run.tournament.org.il/netapp-snapmirror-monitor-script/' rel='bookmark' title='Permanent Link: NetApp SnapMirror monitor script'>NetApp SnapMirror monitor script</a> <small>I have had some work done lately with NetApp SnapMirror....</small></li>
<li><a href='http://run.tournament.org.il/xenserver-create-snapshots-for-all-machines/' rel='bookmark' title='Permanent Link: XenServer create snapshots for all machines'>XenServer create snapshots for all machines</a> <small>XenServer is a wonderful tool. One of the better parts...</small></li>
<li><a href='http://run.tournament.org.il/ontap-simulator-and-some-insights-about-netapp/' rel='bookmark' title='Permanent Link: Ontap Simulator, and some insights about NetApp'>Ontap Simulator, and some insights about NetApp</a> <small>First and foremost &#8211; the Ontap simulator, a great tool...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://run.tournament.org.il/citrix-xenserver-5-0-cannot-cooperate-with-netapp-snapmirror/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>XenServer create snapshots for all machines</title>
		<link>http://run.tournament.org.il/xenserver-create-snapshots-for-all-machines/</link>
		<comments>http://run.tournament.org.il/xenserver-create-snapshots-for-all-machines/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 09:35:03 +0000</pubDate>
		<dc:creator>ez-aton</dc:creator>
				<category><![CDATA[Disk Storage]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting/Programing]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[netapp]]></category>
		<category><![CDATA[shell functions]]></category>
		<category><![CDATA[snapshot]]></category>
		<category><![CDATA[storage]]></category>
		<category><![CDATA[vm]]></category>
		<category><![CDATA[XenServer]]></category>

		<guid isPermaLink="false">http://run.tournament.org.il/?p=483</guid>
		<description><![CDATA[XenServer is a wonderful tool. One of the better parts of it is its powerful scripting language, powered by the &#8216;xe&#8217; command.
In order to capture a mass of snapshots, you can either do it manually from the GUI, or scripted. The script supplied below will include shell functions to capture Quiesce snapshots, and it that [...]


Related posts:<ol><li><a href='http://run.tournament.org.il/quick-provisioning-of-virtual-machines/' rel='bookmark' title='Permanent Link: Quick provisioning of virtual machines'>Quick provisioning of virtual machines</a> <small>When one wants to achieve fast provisioning of virtual machines,...</small></li>
<li><a href='http://run.tournament.org.il/relocating-lvs-with-snapshots/' rel='bookmark' title='Permanent Link: Relocating LVs with snapshots'>Relocating LVs with snapshots</a> <small>Linux LVM is a wonderful thing. It is scalable, flexible,...</small></li>
<li><a href='http://run.tournament.org.il/citrix-xenserver-5-0-cannot-cooperate-with-netapp-snapmirror/' rel='bookmark' title='Permanent Link: Citrix XenServer 5.0 cannot cooperate with NetApp SnapMirror'>Citrix XenServer 5.0 cannot cooperate with NetApp SnapMirror</a> <small>It has been a long while, I know. I was...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>XenServer is a wonderful tool. One of the better parts of it is its powerful scripting language, powered by the &#8216;xe&#8217; command.</p>
<p>In order to capture a mass of snapshots, you can either do it manually from the GUI, or scripted. The script supplied below will include shell functions to capture Quiesce snapshots, and it that fails, normal snapshots of every <strong>running</strong> VM on the system.</p>
<p>Reason: NetApp SnapMirror, or other backup (maybe for later export) scheduled actions.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://run.tournament.org.il/wp-content/plugins/wp-codebox/wp-codebox.php?p=483&amp;download=xen_functions.sh">xen_functions.sh</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p48315"><td class="code" id="p483code15"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># This script will supply functions for snapshotting and snapshot destroy including disks</span>
<span style="color: #666666; font-style: italic;"># Written by Ez-Aton</span>
<span style="color: #666666; font-style: italic;"># Visit my web blog for more stuff, at http://run.tournament.org.il</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Global variables:</span>
<span style="color: #007800;">UUID_LIST_FILE</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>SNAP_UUIDS.txt
&nbsp;
<span style="color: #666666; font-style: italic;"># Function</span>
<span style="color: #000000; font-weight: bold;">function</span> assign_all_uuids <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #666666; font-style: italic;"># Construct artificial non-indexed list with name (removing annoying characters) and UUID</span>
	<span style="color: #007800;">LIST</span>=<span style="color: #ff0000;">&quot;&quot;</span>
	<span style="color: #000000; font-weight: bold;">for</span> UUID <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>xe vm-list power-state=running is-control-domain=<span style="color: #c20cb9; font-weight: bold;">false</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> uuid <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $NF}'</span><span style="color: #000000; font-weight: bold;">`</span>
	<span style="color: #000000; font-weight: bold;">do</span>
		<span style="color: #007800;">NAME</span>=<span style="color: #000000; font-weight: bold;">`</span>xe vm-param-get param-name=name-label <span style="color: #007800;">uuid</span>=<span style="color: #007800;">$UUID</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #ff0000;">' '</span> _ <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">'('</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">')'</span><span style="color: #000000; font-weight: bold;">`</span>
		<span style="color: #007800;">LIST</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$LIST</span> <span style="color: #007800;">$NAME</span>:<span style="color: #007800;">$UUID</span>&quot;</span>
	<span style="color: #000000; font-weight: bold;">done</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$LIST</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> take_snap_quiesce <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #666666; font-style: italic;"># We attempt to take a snapshot with quench</span>
	<span style="color: #666666; font-style: italic;"># Arguments: $1 name ; $2 uuid</span>
	<span style="color: #666666; font-style: italic;"># We attempt to snapshot the machine and set the value of snap_uuid to the snapshot uuid, if successful.</span>
	<span style="color: #666666; font-style: italic;"># Return 1 if failed</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #007800;">SNAP_UUID</span>=<span style="color: #000000; font-weight: bold;">`</span>xe vm-snapshot-with-quiesce <span style="color: #007800;">vm</span>=<span style="color: #007800;">$2</span> new-name-label=<span style="color: #800000;">${1}</span>_snapshot<span style="color: #000000; font-weight: bold;">`</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #666666; font-style: italic;"># echo &quot;Snapshot-with-quiesce for $1 successful&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Snapshot-with-quiesce for $1 failed&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> take_snap <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #666666; font-style: italic;"># We attempt to take a snapshot</span>
	<span style="color: #666666; font-style: italic;"># Arguments: $1 name ; $2 uuid</span>
	<span style="color: #666666; font-style: italic;"># We attempt to snapshot the machine and set the value of snap_uuid to the snapshot uuid, if successful.</span>
	<span style="color: #666666; font-style: italic;"># Return 1 if failed</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #007800;">SNAP_UUID</span>=<span style="color: #000000; font-weight: bold;">`</span>xe vm-snapshot <span style="color: #007800;">vm</span>=<span style="color: #007800;">$2</span> new-name-label=<span style="color: #800000;">${1}</span>_snapshot<span style="color: #000000; font-weight: bold;">`</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #666666; font-style: italic;">#echo &quot;Snapshot for $1 successful&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$SNAP_UUID</span>
		<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Snapshot-with-quiesce for $1 failed&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> stop_ha_template <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #666666; font-style: italic;"># Templates inherit their settings from the origin</span>
	<span style="color: #666666; font-style: italic;"># We need to turn off HA</span>
	<span style="color: #666666; font-style: italic;"># $1 : Template UUID</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Missing template UUID&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	xe template-param-set ha-always-run=<span style="color: #c20cb9; font-weight: bold;">false</span> <span style="color: #007800;">uuid</span>=<span style="color: #007800;">$1</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> get_vdi <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #666666; font-style: italic;"># This function will get a space delimited list of VDI UUIDs of a given snapshot/template UUID</span>
	<span style="color: #666666; font-style: italic;"># Arguments: $1 template UUID</span>
	<span style="color: #666666; font-style: italic;"># It will also verify that each VBD is an actual snapshot</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;No arguments? We need the template UUID&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #007800;">VDIS</span>=<span style="color: #ff0000;">&quot;&quot;</span>
	<span style="color: #000000; font-weight: bold;">for</span> VBD <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>xe vbd-list vm-uuid=<span style="color: #007800;">$1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> ^uuid <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $NF}'</span><span style="color: #000000; font-weight: bold;">`</span>
	<span style="color: #000000; font-weight: bold;">do</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;VBD: <span style="color: #007800;">$VBD</span>&quot;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #000000; font-weight: bold;">`</span>xe vbd-param-get param-name=<span style="color: #7a0874; font-weight: bold;">type</span> <span style="color: #007800;">uuid</span>=<span style="color: #007800;">$VBD</span><span style="color: #000000; font-weight: bold;">`</span> = <span style="color: #ff0000;">&quot;CD&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
		<span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #007800;">CUR_VDI</span>=<span style="color: #000000; font-weight: bold;">`</span>xe vdi-list vbd-uuids=<span style="color: #007800;">$VBD</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> ^uuid <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $NF}'</span><span style="color: #000000; font-weight: bold;">`</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">`</span>xe vdi-param-get <span style="color: #007800;">uuid</span>=<span style="color: #007800;">$CUR_VDI</span> param-name=is-a-snapshot<span style="color: #000000; font-weight: bold;">`</span>
			<span style="color: #000000; font-weight: bold;">then</span>
				<span style="color: #007800;">VDIS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$VDIS</span> <span style="color: #007800;">$CUR_VDI</span>&quot;</span>
			<span style="color: #000000; font-weight: bold;">else</span>
				<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;VDI is not a snapshot!&quot;</span>
				<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
			<span style="color: #000000; font-weight: bold;">fi</span>
			<span style="color: #007800;">CUR_VDI</span>=<span style="color: #ff0000;">&quot;&quot;</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">done</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$VDIS</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> remove_vdi <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #666666; font-style: italic;"># This function will get a list of VDIs and remove them</span>
	<span style="color: #666666; font-style: italic;"># Carefull!</span>
	<span style="color: #000000; font-weight: bold;">for</span> VDI <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #000000; font-weight: bold;">@</span>
	<span style="color: #000000; font-weight: bold;">do</span>
		<span style="color: #000000; font-weight: bold;">if</span> xe vdi-destroy <span style="color: #007800;">uuid</span>=<span style="color: #007800;">$VDI</span>
		<span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Success in removing VDI <span style="color: #007800;">$VDI</span>&quot;</span>
		<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Failure in removing VDI <span style="color: #007800;">$VDI</span>&quot;</span>
			<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> remove_template <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #666666; font-style: italic;"># This funciton will remove a template</span>
	<span style="color: #666666; font-style: italic;"># $1 template UUID</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Required UUID&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	xe template-param-set is-a-template=<span style="color: #c20cb9; font-weight: bold;">false</span> <span style="color: #007800;">uuid</span>=<span style="color: #007800;">$1</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">!</span> xe vm-uninstall <span style="color: #007800;">force</span>=<span style="color: #c20cb9; font-weight: bold;">true</span> <span style="color: #007800;">uuid</span>=<span style="color: #007800;">$1</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Failure to remove VM/Template&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> remove_all_template <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #666666; font-style: italic;"># This function will completely remove a template</span>
	<span style="color: #666666; font-style: italic;"># The steps are as follow:</span>
	<span style="color: #666666; font-style: italic;"># $1 is the UUID of the template</span>
	<span style="color: #666666; font-style: italic;"># Calculate its VDIs</span>
	<span style="color: #666666; font-style: italic;"># Remove the template</span>
	<span style="color: #666666; font-style: italic;"># Remove the VDIs</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;No Template UUID was supplied&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #666666; font-style: italic;"># We now collect the value of $VDIS</span>
	get_vdi <span style="color: #007800;">$1</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$?&quot;</span> <span style="color: #660033;">-ne</span> <span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Failed to get VDIs for Template $1&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">!</span> remove_template <span style="color: #007800;">$1</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Failure to remove template $1&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">!</span> remove_vdi <span style="color: #007800;">$VDIS</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> create_all_snapshots <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #666666; font-style: italic;"># In this function we will run all over $LIST and create snapshots of each machine, keeping the UUID of it inside a file</span>
	<span style="color: #666666; font-style: italic;"># $@ - list of machines in the $LIST format</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$UUID_LIST_FILE</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$UUID_LIST_FILE</span> <span style="color: #007800;">$UUID_LIST_FILE</span>.<span style="color: #007800;">$$</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #000000; font-weight: bold;">@</span>
	<span style="color: #000000; font-weight: bold;">do</span>
		<span style="color: #007800;">SNAP_UUID</span>=<span style="color: #000000; font-weight: bold;">`</span>take_snap_quiesce <span style="color: #800000;">${i%%:*}</span> <span style="color: #800000;">${i##*:}</span><span style="color: #000000; font-weight: bold;">`</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$?&quot;</span> <span style="color: #660033;">-ne</span> <span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
		<span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Problem taking snapshot with quiesce for <span style="color: #007800;">${i%%:*}</span>&quot;</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Attempting normal snapshot&quot;</span>
			<span style="color: #007800;">SNAP_UUID</span>=<span style="color: #000000; font-weight: bold;">`</span>take_snap <span style="color: #800000;">${i%%:*}</span> <span style="color: #800000;">${i##*:}</span><span style="color: #000000; font-weight: bold;">`</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$?&quot;</span> <span style="color: #660033;">-ne</span> <span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
                	<span style="color: #000000; font-weight: bold;">then</span>
                        	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Problem taking snapshot for <span style="color: #007800;">${i%%:*}</span>&quot;</span>
				<span style="color: #007800;">SNAP_UUID</span>=<span style="color: #ff0000;">&quot;&quot;</span>
			<span style="color: #000000; font-weight: bold;">fi</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
		stop_ha_template <span style="color: #007800;">$SNAP_UUID</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$SNAP_UUID</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$UUID_LIST_FILE</span>
	<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></td></tr></table></div>

<p>Possible use will be like this:</p>
<blockquote><p>. /usr/local/bin/xen_functions.sh</p>
<p>create_all_snapshots `assign_all_uuids` &#038;> /tmp/snap_create.log</p></blockquote>


<p>Related posts:<ol><li><a href='http://run.tournament.org.il/quick-provisioning-of-virtual-machines/' rel='bookmark' title='Permanent Link: Quick provisioning of virtual machines'>Quick provisioning of virtual machines</a> <small>When one wants to achieve fast provisioning of virtual machines,...</small></li>
<li><a href='http://run.tournament.org.il/relocating-lvs-with-snapshots/' rel='bookmark' title='Permanent Link: Relocating LVs with snapshots'>Relocating LVs with snapshots</a> <small>Linux LVM is a wonderful thing. It is scalable, flexible,...</small></li>
<li><a href='http://run.tournament.org.il/citrix-xenserver-5-0-cannot-cooperate-with-netapp-snapmirror/' rel='bookmark' title='Permanent Link: Citrix XenServer 5.0 cannot cooperate with NetApp SnapMirror'>Citrix XenServer 5.0 cannot cooperate with NetApp SnapMirror</a> <small>It has been a long while, I know. I was...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://run.tournament.org.il/xenserver-create-snapshots-for-all-machines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ad-hoc remote backups to tape</title>
		<link>http://run.tournament.org.il/ad-hoc-remote-backups-to-tape/</link>
		<comments>http://run.tournament.org.il/ad-hoc-remote-backups-to-tape/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 05:11:08 +0000</pubDate>
		<dc:creator>ez-aton</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting/Programing]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[backup systems]]></category>
		<category><![CDATA[remote tape]]></category>
		<category><![CDATA[scsi tape]]></category>

		<guid isPermaLink="false">http://run.tournament.org.il/?p=480</guid>
		<description><![CDATA[I have a nice SCSI tape connected to a single server. This allows for on-demand backups, with the hope (and seldom, with the established knowledge) that I can recover the data I have there.
Old computers, decommissioned computers and systems I wish to erase and reuse are seldom backed-up, just because of the effort in doing [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I have a nice SCSI tape connected to a single server. This allows for on-demand backups, with the hope (and seldom, with the established knowledge) that I can recover the data I have there.</p>
<p>Old computers, decommissioned computers and systems I wish to erase and reuse are seldom backed-up, just because of the effort in doing it. I will need to manually run something or the other, and who wants this chore?</p>
<p>I know that there are many full-featured backup systems out there, OSS and all, with the capability of doing what I want to do, however, these commonly use backup agents, tape formats and what&#8217;s more, just to make a simple one-time backup (which is what I want) &#8211; it looked too bloated for my needs.</p>
<p>Again &#8211; my needs are: take this machine, run a simple script which can be obtained from an NFS share, wait for X minutes doing something else, and be assured your system is backed up.</p>
<p>I have written the script below to satisfy these requirements. Hope it helps others. Notice the single SSH leading connection and its functionality. It leaves a raw text file on tape with a simple description of the backup process, and the next tracks are the contents of each mount point.</p>
<p>I was a bit spartan with comments, but in general, this script should be quite self-explanatory:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://run.tournament.org.il/wp-content/plugins/wp-codebox/wp-codebox.php?p=480&amp;download=backup_remote.txt">backup_remote.txt</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p48018"><td class="code" id="p480code18"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># This script will backup local disk to remote tape</span>
<span style="color: #666666; font-style: italic;"># Written by Ez-Aton - http://run.tournament.org.il/</span>
&nbsp;
<span style="color: #007800;">SERVER</span>=kruvi <span style="color: #666666; font-style: italic;"># The name of the server with the direct attached tape</span>
<span style="color: #007800;">SRV_USER</span>=root
<span style="color: #007800;">TAPE</span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>nst0 <span style="color: #666666; font-style: italic;"># Non-rewinding tape. We need to be able to add more tracks and not overwrite our own track</span>
<span style="color: #007800;">SSH</span>=<span style="color: #ff0000;">&quot;ssh -o StrictHostKeyChecking=no -o ControlMaster=auto -o ControlPath=~/.ssh/socket-%r@%h:%p&quot;</span>
<span style="color: #007800;">WORK_FILE</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>work.<span style="color: #007800;">$$</span>
<span style="color: #007800;">TAR_LOG</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>backup.log
<span style="color: #007800;">TAR_ARG</span>=<span style="color: #ff0000;">&quot;czf - --one-file-system&quot;</span>
&nbsp;
<span style="color: #007800;">MOUNTS</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">df</span> <span style="color: #660033;">-TlP</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> tmpfs <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-n</span> +<span style="color: #000000;">2</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $7}'</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #666666; font-style: italic;"># Assume nobody is stupid enough to use white spaces in mount paths</span>
<span style="color: #007800;">NUM_MOUNTS</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$MOUNTS</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">wc</span> -w<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">SUM_FILE</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>summery.txt
&nbsp;
clean_log <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        : <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$TAR_LOG</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
first_disk <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #666666; font-style: italic;"># Assume first disk is the first entry in /proc/partitions</span>
        <span style="color: #007800;">DISK</span>=<span style="color: #ff0000;">&quot;/dev/<span style="color: #780078;">`cat /proc/partitions | head -n 3 | tail -n 1 | awk '{print $4}'`</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
create_sum <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Creating summery&quot;</span>
        <span style="color: #666666; font-style: italic;"># Collect information and place it in the file. It will be the first track of the tape</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Hostname: <span style="color: #780078;">`hostname`</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$SUM_FILE</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$SUM_FILE</span>
        <span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$SUM_FILE</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$SUM_FILE</span>
        <span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$MOUNTS</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #c20cb9; font-weight: bold;">df</span> <span style="color: #660033;">-h</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-n</span> +<span style="color: #000000;">2</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$SUM_FILE</span> ; <span style="color: #000000; font-weight: bold;">done</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$SUM_FILE</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;There will be <span style="color: #007800;">$(($NUM_MOUNTS + 1)</span>) tracks in addition to the first one&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$SUM_FILE</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
create_leading_ssh <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #666666; font-style: italic;"># Use a nice trick for giving password only once:</span>
        <span style="color: #007800;">$SSH</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$SRV_USER</span><span style="color: #000000; font-weight: bold;">@</span><span style="color: #007800;">$SERVER</span> <span style="color: #ff0000;">'while true; do sleep 100; done'</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;post leading&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
monitor_proc <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #666666; font-style: italic;"># Monitor SSH process</span>
        <span style="color: #666666; font-style: italic;"># Run in the background</span>
        <span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #007800;">$WORK_FILE</span>
        <span style="color: #007800;">PID</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ps</span> aux <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$SSH</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $2}'</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$PID</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
        <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Done so soon?&quot;</span>
                <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$WORK_FILE</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
        <span style="color: #000000; font-weight: bold;">do</span>
                <span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">10</span>
        <span style="color: #000000; font-weight: bold;">done</span>
        <span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #007800;">$PID</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
test_tape_cmd <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #007800;">CMD</span>=<span style="color: #ff0000;">&quot;mt -f <span style="color: #007800;">$TAPE</span> status&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
remote_tape_append <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #007800;">CMD</span>=<span style="color: #ff0000;">&quot;cat &gt; <span style="color: #007800;">$TAPE</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
test_tape <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        test_tape_cmd
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #007800;">$SSH</span> <span style="color: #007800;">$SRV_USER</span><span style="color: #000000; font-weight: bold;">@</span><span style="color: #007800;">$SERVER</span> <span style="color: #007800;">$CMD</span>
        <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Tape on <span style="color: #007800;">$SERVER</span> is not ready&quot;</span>
                <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
backup_mount <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #666666; font-style: italic;"># Backup the actual mount</span>
        <span style="color: #666666; font-style: italic;"># $1 - the path of the mount</span>
        remote_tape_append
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
        <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Mount path is empty?&quot;</span>
                <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Backing up $1&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #ff0000;">&quot;$1&quot;</span>
        <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #007800;">$TAR_ARG</span> . <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #007800;">$SSH</span> <span style="color: #007800;">$SRV_USER</span><span style="color: #000000; font-weight: bold;">@</span><span style="color: #007800;">$SERVER</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CMD</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$TAR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
append_header <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        remote_tape_append
        <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$SUM_FILE</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #007800;">$SSH</span> <span style="color: #007800;">$SRV_USER</span><span style="color: #000000; font-weight: bold;">@</span><span style="color: #007800;">$SERVER</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CMD</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
add_mbr <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        remote_tape_append
        first_disk
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DISK</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
        <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Can't decide on the first boot disk. Exiting now&quot;</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;No MBR backup exists&quot;</span>
                <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Backing MBR&quot;</span>
        <span style="color: #c20cb9; font-weight: bold;">dd</span> <span style="color: #007800;">if</span>=<span style="color: #007800;">$DISK</span> <span style="color: #007800;">bs</span>=1M <span style="color: #007800;">count</span>=<span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #007800;">$SSH</span> <span style="color: #007800;">$SRV_USER</span><span style="color: #000000; font-weight: bold;">@</span><span style="color: #007800;">$SERVER</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CMD</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
create_sum
create_leading_ssh
monitor_proc <span style="color: #000000; font-weight: bold;">&amp;</span>
test_tape
append_header
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$MOUNTS</span>
<span style="color: #000000; font-weight: bold;">do</span>
        backup_mount <span style="color: #007800;">$i</span>
<span style="color: #000000; font-weight: bold;">done</span>
add_mbr
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #007800;">$WORK_FILE</span></pre></td></tr></table></div>



<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://run.tournament.org.il/ad-hoc-remote-backups-to-tape/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle Clusterware as a 3rd party HA framework</title>
		<link>http://run.tournament.org.il/oracle-clusterware-as-a-3rd-party-ha-framework/</link>
		<comments>http://run.tournament.org.il/oracle-clusterware-as-a-3rd-party-ha-framework/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 23:17:11 +0000</pubDate>
		<dc:creator>ez-aton</dc:creator>
				<category><![CDATA[Clusters]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[cluster]]></category>
		<category><![CDATA[crs]]></category>
		<category><![CDATA[failover]]></category>
		<category><![CDATA[HA]]></category>
		<category><![CDATA[nfs]]></category>
		<category><![CDATA[ocfs]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[storage]]></category>

		<guid isPermaLink="false">http://run.tournament.org.il/?p=477</guid>
		<description><![CDATA[Oracle begin to push their Clusterware as a 3rd party HA framework. In this article we will review a quick example of how to do it. I will refer to this post as a quick-guide, as this is by no means any full-scale guide.
This article assumes you have installed Oracle Clusterware following one of the [...]


Related posts:<ol><li><a href='http://run.tournament.org.il/oracle-rac-with-emc-iscsi-storage-panics/' rel='bookmark' title='Permanent Link: Oracle RAC with EMC iSCSI Storage Panics'>Oracle RAC with EMC iSCSI Storage Panics</a> <small>I have had a system panicking when running the mentioned...</small></li>
<li><a href='http://run.tournament.org.il/persistent-raw-devices-for-oracle-rac-with-iscsi/' rel='bookmark' title='Permanent Link: Persistent raw devices for Oracle RAC with iSCSI'>Persistent raw devices for Oracle RAC with iSCSI</a> <small>Using udev to set persistent raw devices for iscsi in...</small></li>
<li><a href='http://run.tournament.org.il/raw-devices-for-oracle-on-redhat-rhel-5/' rel='bookmark' title='Permanent Link: Raw devices for Oracle on RedHat (RHEL) 5'>Raw devices for Oracle on RedHat (RHEL) 5</a> <small>There is a major confusion among DBAs regarding how to...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Oracle begin to push their Clusterware as a 3rd party HA framework. In this article we will review a quick example of how to do it. I will refer to this post as a quick-guide, as this is by no means any full-scale guide.</p>
<p>This article assumes you have installed <a href="http://www.oracle.com/technology/products/database/clusterware/index.html" target="_blank">Oracle Clusterware</a> following <a href="http://www.oracle.com/technology/pub/articles/smiley_rac10g_install.html" target="_blank">one of the few links</a> <a href="http://youngcow.net/doc/oracle10g/install.102/b14203/crsunix.htm" target="_blank">and guides</a> <a href="http://onlineappsdba.com/index.php/2007/07/22/oracle-rac-part-iv-install-oracle-clusterware-and-cluster-database/" target="_blank">available</a> <a href="http://oracle.su/install.111/b28263/crsunix.htm" target="_blank">on the net</a>. This quick-guide applies to both Clusterware 10 and Clusterware 11.</p>
<p>We will discuss the method of adding an additional NFS service on Linux.</p>
<p>In order to do so, you will need a shared storage &#8211; assuming the goal of the exercise is to supply the clients with a consistent storage services based on NFS. I, for myself, prefer to use OCFS2 as the choice file system for shared disks. This goes well with Oracle Clusterware, as this cluster framework does not handle disk mounts very well, and unless you are to write/search an agent which will make sure that every mount and umount behave correctly (you wouldn&#8217;t want to get a file system corruption, would you?), you will probably prefer to do the same. The lack of need to manage the disk mount actions will both save time on planned failover, and will guarantee storage safety. If you have not placed your CRS and Vote on OCFS2, you will need to install OCFS2 from <a href="http://oss.oracle.com/projects/ocfs2/" target="_blank">here</a> and <a href="http://oss.oracle.com/projects/ocfs2-tools/" target="_blank">here</a>, and then to configure it. We will not discuss OCFS2 configuration in this post.</p>
<p>We will need to assume the following prerequisites:</p>
<ul>
<li>Service-related IP address: 1.2.3.4. Netmask 255.255.255.248. You need this IP to be member of the same class as your public network card is.</li>
<li>Shared Storage: Formatted to OCFS2, and mounted on both nodes on /shared</li>
<li>Oracle Clusterware installed and working</li>
<li>Cluster nodes names are &#8220;node1&#8243; and &#8220;node2&#8243;</li>
<li>Have $CRS_HOME point to your CRS installation</li>
<li>Have $CRS_HOME/bin in your $PATH</li>
</ul>
<p>We need to create the service-related IP resource first. I would recommend to have an entry in /etc/hosts for this IP address on both nodes. Assuming the public NIC is eth0, The command would be</p>
<blockquote><p>crs_profile -create nfs_ip -t application -a $CRS_HOME/bin/usrvip -o oi=eth0,ov=1.2.3.4,on=255.255.255.248</p></blockquote>
<p>Now you will need to set running permissions for the oracle user. In my case, the user name is actually &#8220;oracle&#8221;:</p>
<blockquote><p>crs_setperm nfs_ip -o root<br />
crs_serperm nfs_ip -u user:oracle:r-x</p></blockquote>
<p>Test that you can start the service as the oracle user:</p>
<blockquote><p>crs_start nfs_ip</p></blockquote>
<p>Now we need to setup NFS. For this to work, we need to setup the NFS daemon first. Edit /etc/exports and add a line such as this:</p>
<blockquote><p>/shared *(rw,no_root_sqush,sync)</p></blockquote>
<p>Make sure that nfs service is disabled during startup:</p>
<blockquote><p>chkconfig nfs off<br />
chkconfig nfslock off</p></blockquote>
<p>Now is the time to setup Oracle Clusterware for the task:</p>
<blockquote><p>crs_profile -create share_nfs -t application -B /etc/init.d/nfs -d &#8220;Shared NFS&#8221; -r nfs_ip -a sharenfs.scr -p favored -h &#8220;node1 node2&#8243; -o ci=30,ft=3,fi=12,ra=5<br />
crs_register share_nfs</p></blockquote>
<p>Deal with permissions:</p>
<blockquote><p>crs_setperms share_nfs -o root<br />
crs_setperms share_nfs -u user:oracle:r-x</p></blockquote>
<p>Fix the &#8220;sharenfs.scr&#8221; script. First, find it. It should reside in $CRS_HOME/crs/scripts if everything is OK. If not, you will be able to find it in $CRS_HOME using find.</p>
<p>Edit the &#8220;sharenfs.scr&#8221; script and modify the following variables which are defined relatively in the beginning of the script:</p>
<blockquote><p>PROBE_PROCS=&#8221;nfsd&#8221;<br />
START_APPCMD=&#8221;/etc/init.d/nfs start<br />
START_APPCMD2=&#8221;/etc/init.d/nfslock start&#8221;<br />
STOP_APPCMD=&#8221;/etc/init.d/nfs stop&#8221;<br />
STOP_APPCMD2=&#8221;/etc/init.d/nfslock stop&#8221;</p></blockquote>
<p>Copy the modified script file to the other node. Verify this script has execution permissions on both nodes.</p>
<p>Start the service as the oracle user:</p>
<blockquote><p>crs_start sharenfs</p></blockquote>
<p>Test the service. The following command should return the export path:</p>
<blockquote><p>showmount -e 1.2.3.4</p></blockquote>
<p>Relocate the service and test again:</p>
<blockquote><p>crs_relocate -f sharenfs<br />
showmount -e 1.2.3.4</p></blockquote>
<p>Done. You now have HA NFS service above Oracle Clusterware framework.</p>
<p>I used <a href="http://www.nextre.it/oracledocs/oracleclusterware01.html" target="_blank">this web page</a> as a reference. I thank him for his great work!</p>


<p>Related posts:<ol><li><a href='http://run.tournament.org.il/oracle-rac-with-emc-iscsi-storage-panics/' rel='bookmark' title='Permanent Link: Oracle RAC with EMC iSCSI Storage Panics'>Oracle RAC with EMC iSCSI Storage Panics</a> <small>I have had a system panicking when running the mentioned...</small></li>
<li><a href='http://run.tournament.org.il/persistent-raw-devices-for-oracle-rac-with-iscsi/' rel='bookmark' title='Permanent Link: Persistent raw devices for Oracle RAC with iSCSI'>Persistent raw devices for Oracle RAC with iSCSI</a> <small>Using udev to set persistent raw devices for iscsi in...</small></li>
<li><a href='http://run.tournament.org.il/raw-devices-for-oracle-on-redhat-rhel-5/' rel='bookmark' title='Permanent Link: Raw devices for Oracle on RedHat (RHEL) 5'>Raw devices for Oracle on RedHat (RHEL) 5</a> <small>There is a major confusion among DBAs regarding how to...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://run.tournament.org.il/oracle-clusterware-as-a-3rd-party-ha-framework/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>RHEL5 100% CPU with LDAP client for Active Directory</title>
		<link>http://run.tournament.org.il/rhel5-100-cpu-with-ldap-client-for-active-directory/</link>
		<comments>http://run.tournament.org.il/rhel5-100-cpu-with-ldap-client-for-active-directory/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 18:02:40 +0000</pubDate>
		<dc:creator>ez-aton</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[ldap client]]></category>
		<category><![CDATA[rhel5]]></category>

		<guid isPermaLink="false">http://run.tournament.org.il/?p=471</guid>
		<description><![CDATA[ADS integration has been available natively since Windows 2003 R2, and in heterogeneous sites this has become the preferred method of integrating login information, as well as utilizing the added security of using Kerberos wherever possible.
The following guide is a very good one, and was the source of information I have used throughout my work [...]


Related posts:<ol><li><a href='http://run.tournament.org.il/rhel5-disk-performance-collection-sysstat/' rel='bookmark' title='Permanent Link: RHEL5 disk performance collection (sysstat)'>RHEL5 disk performance collection (sysstat)</a> <small>Sysstat package, for me, is a must on any Linux...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>ADS integration has been available natively since Windows 2003 R2, and in heterogeneous sites this has become the preferred method of integrating login information, as well as utilizing the added security of using Kerberos wherever possible.</p>
<p>The <a href="http://blog.scottlowe.org/2007/01/15/linux-ad-integration-version-4/" target="_blank">following guide</a> is a very good one, and was the source of information I have used throughout my work integrating Linux into ADS. So far it has worked quite well for RHEL4.</p>
<p>RHEL5, on the other hand, is a different story. While it can work, and ldap queries return sensible results, it is too common for a process to utilize 100% CPU while doing absolutely nothing.</p>
<p>My research brought me to the following conclusions:</p>
<ul>
<li>The high CPU utilization is being caused by something RHEL5 specific (tested to work correctly for RHEL4)</li>
<li>High CPU utilization is caused by nss_ldap module.</li>
<li>Yes, it does happen to every nss related service. NSCD does not help, and gets to 100% CPU also.</li>
<li>Tracing to nss_ldap modules return after a very long time (if ever) that the session to the ADS server has somehow hanged.</li>
</ul>
<p>You can see an example of this bug in this specific <a href="https://bugzilla.redhat.com/show_bug.cgi?id=291401" target="_blank">bugzilla entry</a>.</p>
<p>A quick and effective workaround was used after examining the differences between configuration directives for RHEL4 and RHEL5. Forcing LDAP version 2 instead of 3 (which is the default for RHEL5 ldap client, as it attempts the highest version possible) results in a correct behavior.The line in <em>/etc/ldap.conf</em> is:</p>
<blockquote><p>ldap_version 2</p></blockquote>
<p>FYI</p>


<p>Related posts:<ol><li><a href='http://run.tournament.org.il/rhel5-disk-performance-collection-sysstat/' rel='bookmark' title='Permanent Link: RHEL5 disk performance collection (sysstat)'>RHEL5 disk performance collection (sysstat)</a> <small>Sysstat package, for me, is a must on any Linux...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://run.tournament.org.il/rhel5-100-cpu-with-ldap-client-for-active-directory/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
