<?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>blog.jphoude.qc.ca</title>
	<atom:link href="http://blog.jphoude.qc.ca/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jphoude.qc.ca</link>
	<description>Jean-Pascal Houde's blog : webdev, plone, linux sysadmin</description>
	<lastBuildDate>Tue, 12 Jul 2011 15:12:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>Cpanel DNSONLY tailwatchd failed</title>
		<link>http://blog.jphoude.qc.ca/2011/07/12/cpanel-dnsonly-tailwatchd-failed/</link>
		<comments>http://blog.jphoude.qc.ca/2011/07/12/cpanel-dnsonly-tailwatchd-failed/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 15:12:50 +0000</pubDate>
		<dc:creator>jphoude</dc:creator>
				<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://blog.jphoude.qc.ca/?p=40</guid>
		<description><![CDATA[My Cpanel DNSONLY (secondary DNS) server started to send errors by email few days ago. tailwatchd failed @ Tue Jul 12 09:35:01 2011. A restart was attempted automagically. It turns out that I needed to install MySQL for tailwatchd to work properly again (whatever that daemon does). What I need to do : Remove /etc/mysqldisable [...]]]></description>
			<content:encoded><![CDATA[<p>My Cpanel DNSONLY (secondary DNS) server started to send errors by email few days ago.</p>
<pre>tailwatchd failed @ Tue Jul 12 09:35:01 2011. A restart was attempted automagically.</pre>
<p>It turns out that I needed to install MySQL for tailwatchd to work properly again (whatever that daemon does).</p>
<p>What I need to do :</p>
<ol>
<li>Remove /etc/mysqldisable</li>
<li>/scripts/mysqlup &#8211;force</li>
<li>/scripts/checkperlmodules</li>
<li>/etc/init.d/cpanel restart</li>
</ol>
<div>After that, you may check /usr/local/cpanel/logs/tailwatchd_log to be sure that there is no error message.</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.jphoude.qc.ca/2011/07/12/cpanel-dnsonly-tailwatchd-failed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up NTP on RHEL/Centos</title>
		<link>http://blog.jphoude.qc.ca/2009/10/04/setting-up-ntp-on-rhelcentos/</link>
		<comments>http://blog.jphoude.qc.ca/2009/10/04/setting-up-ntp-on-rhelcentos/#comments</comments>
		<pubDate>Sun, 04 Oct 2009 17:39:55 +0000</pubDate>
		<dc:creator>jphoude</dc:creator>
				<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ntp]]></category>
		<category><![CDATA[redhat]]></category>

		<guid isPermaLink="false">http://blog.jphoude.qc.ca/?p=36</guid>
		<description><![CDATA[I may have missed something obvious, but it seems that the default ntp.conf shipped with RHEL 5 is not working&#8230; I just want to configure my servers to sync time with a public NTP server. Using the default configuration (/etc/ntp.conf), ntpd starts correctly but never writes anything to /var/log/messages besides the first lines at startup. [...]]]></description>
			<content:encoded><![CDATA[<p>I may have missed something obvious, but it seems that the default ntp.conf shipped with RHEL 5 is not working&#8230;</p>
<p>I just want to configure my servers to sync time with a public NTP server. Using the default configuration (/etc/ntp.conf), ntpd starts correctly but never writes anything to /var/log/messages besides the first lines at startup.</p>
<p>What I have found is that the &#8220;restrict&#8221; lines in the default ntp.conf file do not seem to allow ntpd to connect to the servers that are listed there (*.centos.pool.ntp.org by default). Adding the following lines fix the problem :</p>
<pre>restrict 0.centos.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
restrict 1.centos.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
restrict 2.centos.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
# the following is in the default ntp.conf file
server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org</pre>
<p>Also (as an alternate fix) I had success with the following servers :</p>
<pre>server ntp.isc.org
server clock.redhat.com</pre>
<p>I&#8217;m not sure why, I suspect that&#8217;s because in the DNS they resolve to a single IP address, but I don&#8217;t really understand what would cause this.</p>
<p>Anyway, with these changes my NTP now sync properly, and I can see the &#8220;synchronized to 206.248.171.198, stratum 1&#8243; lines in the /var/log/messages file.</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">server ntp.isc.org</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">server clock.redhat.com</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.jphoude.qc.ca/2009/10/04/setting-up-ntp-on-rhelcentos/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Plone 3 : Changing the title for custom Zope 3 views</title>
		<link>http://blog.jphoude.qc.ca/2008/09/14/plone-changing-title-zope3-views/</link>
		<comments>http://blog.jphoude.qc.ca/2008/09/14/plone-changing-title-zope3-views/#comments</comments>
		<pubDate>Mon, 15 Sep 2008 00:47:59 +0000</pubDate>
		<dc:creator>jphoude</dc:creator>
				<category><![CDATA[Plone]]></category>
		<category><![CDATA[zcml]]></category>
		<category><![CDATA[zope]]></category>

		<guid isPermaLink="false">http://blog.jphoude.qc.ca/?p=20</guid>
		<description><![CDATA[Recently I needed to change the title for a custom Zope 3 view. The title is displayed in the &#8220;Display&#8221; menu, when you add the view as one of the &#8220;Available view methods&#8221; of the content type. The text shown by default is the view name (usually something like viewname_view), which is not very user-friendly. [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I needed to change the title for a custom Zope 3 view. The title is displayed in the &#8220;Display&#8221; menu, when you add the view as one of the &#8220;Available view methods&#8221; of the content type. The text shown by default is the view name (usually something like viewname_view), which is not very user-friendly.<span id="more-20"></span></p>
<div id="attachment_29" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.jphoude.qc.ca/wp-content/uploads/2008/09/displaymenu.png"><img class="size-medium wp-image-29" title="Plone display menu" src="http://blog.jphoude.qc.ca/wp-content/uploads/2008/09/displaymenu-300x140.png" alt="Plone display menu" width="300" height="140" /></a><p class="wp-caption-text">The Plone display menu</p></div>
<p>With old skin templates, you could change the title just by adding a .metadata file or by editing it directly in the ZMI. With Zope 3 views, however, I had no idea how to do this.</p>
<p>So I searched and did not find much information about it, but thankfully I found <a href="http://n2.nabble.com/Names-for-views-in-the-display-menu-tp345977p345977.html" target="_blank">this thread</a> in the Core Developers mailing list, which is about adding this exact feature to Plone!</p>
<p>Here how it works : </p>
<pre>   &lt;browser:page
        for="OFS.interfaces.IFolder"
        name="myview_view"
        class=".myview.View"
        template="templates/myview.pt"
        permission="zope.Public"
        /&gt;

   &lt;browser:menuItems
        for="*"
        menu="plone_displayviews"&gt;
        &lt;browser:menuItem
            title="<strong>My View Title</strong>"
            action="myview_view"
            description="Display something"
            /&gt;
    &lt;/browser:menuItems&gt;</pre>
<p>Here I&#8217;m changing the title for myview_view to &#8220;My View Title&#8221;. The first XML tag is just the view registration (nothing special here). The browser:menuItems and browser:menuItem is what&#8217;s important. plone_displayviews is the name of the menu you need to change. You can add as much browser:menuItem as you want in the menuItems tag. The action parameter is what is actually making the connection between the view and the menuItem.</p>
<p>Thanks to Martijn Pieters, Martin Aspeli and others involved in adding this feature!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jphoude.qc.ca/2008/09/14/plone-changing-title-zope3-views/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Copying a partition table to another disk</title>
		<link>http://blog.jphoude.qc.ca/2008/09/05/copying-a-partition-table-to-another-disk/</link>
		<comments>http://blog.jphoude.qc.ca/2008/09/05/copying-a-partition-table-to-another-disk/#comments</comments>
		<pubDate>Fri, 05 Sep 2008 19:33:28 +0000</pubDate>
		<dc:creator>jphoude</dc:creator>
				<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mbr]]></category>
		<category><![CDATA[partitions]]></category>

		<guid isPermaLink="false">http://blog.jphoude.qc.ca/?p=16</guid>
		<description><![CDATA[This week I added a new hard drive to a server, meant as a spare drive for the RAID 1 array (linux software RAID). To activate the partitions as spares, I needed to recreate exactly the same partitions as the other disks (same size). I first tried doing that manually with GNU parted, but that [...]]]></description>
			<content:encoded><![CDATA[<p>This week I added a new hard drive to a server, meant as a spare drive for the RAID 1 array (linux software RAID). To activate the partitions as spares, I needed to recreate exactly the same partitions as the other disks (same size).</p>
<p>I first tried doing that manually with GNU parted, but that turned out to be hard to do, it seems I could never get the partitions to have exactly the same size&#8230;</p>
<p>So I searched a bit on Google, and found a way to make a backup of the partition table of one disk, and copy it to another disk very easily. As usual, the dd command is always a great tool for that kind of job.<span id="more-16"></span></p>
<p>First, here what you need to do to create a backup of the MBR (which contains the partition table), and save it to a file.</p>
<pre># dd if=/dev/sda of=mbr.bin bs=512 count=1</pre>
<p>This will copy the first 512 bytes of your disk (/dev/sda), which happen to be where the MBR is located. The &#8220;of=&#8221; (output file) parameter means that the MBR will be saved in the file mbr.bin of the current directory. Then, this is what you need to do to restore it, this time on /dev/sdc : </p>
<pre># dd if=mbr.bin of=/dev/sdc bs=512 count=1</pre>
<p>You can also replace only the partition table, but not the code area, which contains the boot loader such as GRUB. The code area uses the first 446 bytes at most, while the partition table is in the next 66 bytes of the hard disk (64 bytes + 2 bytes signature). So by skipping the first 446 bytes, you will only get the partition table from your backup, and keep the rest intact : </p>
<pre># dd if=mbr.bin of=/dev/sdc bs=1 count=64 skip=446 seek=446</pre>
<p>That&#8217;s all! See the Wikipedia article on <a href="http://en.wikipedia.org/wiki/Master_boot_record" target="_blank">Master boot record</a> for more information about what is in the MBR.</p>
<p><strong>Re-read partition table</strong> </p>
<p>After altering the MBR, you will probably need to tell Linux to reload the partition table in order to see the changes. GNU parted provides a simple tool for that, partprobe. Just execute &#8220;partprobe&#8221; as root and you should be OK.</p>
<p> </p>
<p><strong>Verifying your partition table</strong></p>
<p>To be sure you partition table is OK and exactly the same between /dev/sda and /dev/sdc, just look at the special file /proc/partitions</p>
<pre># cat /proc/partitions</pre>
<pre>major minor  #blocks  name
   8     0  <strong>488386584 </strong>sda
   8     1     <strong>514048 </strong>sda1
   8     2  <strong>487869952 </strong>sda2
   8    16  488386584 sdb
   8    17     514048 sdb1
   8    18  487869952 sdb2
   8    32  <strong>488386584 </strong>sdc
   8    33     <strong>514048 </strong>sdc1
   8    34  <strong>487869952 </strong>sdc2</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.jphoude.qc.ca/2008/09/05/copying-a-partition-table-to-another-disk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to make a safe kernel upgrade by SSH</title>
		<link>http://blog.jphoude.qc.ca/2008/02/15/safe-kernel-upgrade-grub/</link>
		<comments>http://blog.jphoude.qc.ca/2008/02/15/safe-kernel-upgrade-grub/#comments</comments>
		<pubDate>Fri, 15 Feb 2008 21:15:52 +0000</pubDate>
		<dc:creator>jphoude</dc:creator>
				<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[grub]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.jphoude.qc.ca/2008/02/15/safe-kernel-upgrade-grub/</guid>
		<description><![CDATA[There&#8217;s been a local root exploit discovered in the Linux kernel recently, which obliged me to manually compile new kernels on some of my servers. The problem with that : I rarely compile new kernels for these servers, so I&#8217;m not sure it will boot at all. Moreover, the servers are located in a datacenter [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s been a local root exploit discovered in the Linux kernel recently, which obliged me to manually compile new kernels on some of my servers. The problem with that : I rarely compile new kernels for these servers, so I&#8217;m not sure it will boot at all. Moreover, the servers are located in a datacenter I can&#8217;t access easily, so manually choosing the kernel in the grub boot menu is not an option. Fortunately, grub provides a feature to help with that.<span id="more-14"></span></p>
<p>The grub manual provides some information about fallback options : http://www.gnu.org/software/grub/manual/html_node/Booting-fallback-systems.html  . Unfortunately, I didn&#8217;t manage to make this work (one command it refers, <kbd>grub-set-default</kbd>, doesn&#8217;t even exist in Fedora/CentOS). The options described in the manual are also a bit too complicated for my needs.</p>
<p>What I really need is the ability to boot into a new kernel, and in case it&#8217;s doesn&#8217;t boot correctly, I should be able to reset the server (using a remote power switch), and the old (working) kernel should come up instead of the new one. Well, the &#8220;savedefault&#8221; command of grub does just that!</p>
<p>All you have to do is enter the grub console by typing &#8220;grub&#8221; at the command line. Then enter the following command :</p>
<pre>savedefault --default=1 --once
quit</pre>
<p>The default option specify which kernel should be loaded (1 is the second kernel listed in grub.conf). The &#8211;once parameter is important. It tells grub to use this settings just one time (otherwise, it won&#8217;t work, grub will just boot the default kernel from grub.conf).</p>
<p>Be sure to set the &#8220;default=0&#8243; option in /etc/grub.conf to a &#8220;safe&#8221; kernel. (Of course, if your old kernel is not the first entry, change the &#8220;0&#8243; accordingly)</p>
<p>That&#8217;s it! Just reboot the server, it will boot on kernel &#8220;1&#8243; (the one from the savedefault command). If it works, edit grub.conf to set this kernel as the default. If it doesn&#8217;t work, reset the server, and grub will boot on the default kernel.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jphoude.qc.ca/2008/02/15/safe-kernel-upgrade-grub/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Greylisting with Exim, Python and MySQL &#8211; greylisting-py 1.0</title>
		<link>http://blog.jphoude.qc.ca/2008/01/26/greylisting-with-exim-python-mysql/</link>
		<comments>http://blog.jphoude.qc.ca/2008/01/26/greylisting-with-exim-python-mysql/#comments</comments>
		<pubDate>Sat, 26 Jan 2008 22:12:47 +0000</pubDate>
		<dc:creator>jphoude</dc:creator>
				<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[exim]]></category>
		<category><![CDATA[greylisting]]></category>
		<category><![CDATA[mta]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://blog.jphoude.qc.ca/2008/01/26/greylisting-with-exim-python-mysql/</guid>
		<description><![CDATA[I just released a working version of my own greylisting implementation, written in Python and using a MySQL database. I originally wrote this for our mail server at work, as the existing implementations I found online did not satisfy my needs completely. The script was made for a system running Exim, MySQL 4 and Python [...]]]></description>
			<content:encoded><![CDATA[<p>I just released a working version of <a href="http://code.google.com/p/greylisting-py/" target="_blank">my own greylisting implementation</a>, written in Python and using a MySQL database. I originally wrote this for our mail server at work, as the existing implementations I found online did not satisfy my needs completely.<span id="more-10"></span></p>
<p>The script was made for a system running Exim, MySQL 4 and Python 2.3 on Redhat Linux, so it should be easy to install for similar configurations. Of course, it should be possible to run it on any environnement and MTA (if your MTA gives you the possibility of refusing mail based on the result of an external command).</p>
<p>Here is a list of features of my project :</p>
<ul>
<li>Whitelisting of single IP addresses</li>
<li>Whitelisting of IP networks (CIDR)</li>
<li>Support for SPF (if enabled, messages that pass SPF test will not be greylisted)</li>
<li>You can enable greylisting by email adress and/or by domain.</li>
<li>Configurable parameters, such as initial delay and expire delay.</li>
</ul>
<p>You can download greylisting-py (yes, I did not spent much time trying to find a name for it <img src='http://blog.jphoude.qc.ca/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  from the Google code page : <a href="http://code.google.com/p/greylisting-py/" target="_blank">http://code.google.com/p/greylisting-py/</a>.  There&#8217;s also instructions on how to install it and use it with Exim.<br />
I hope it will be useful for some people!</p>
<h3>But what is greylisting?</h3>
<p>Greylisting is a technique to help fight spam, very useful as a complement to other filters like SpamAssassin. Basically, it works this way :</p>
<ol>
<li>MTA 1 receives a message from MTA 2. It dectects a new &#8220;triplet&#8221; [sender ip, sender address, recipient address], and since it&#8217;s the first time it sees that triplet, it refuses the message with a temporary error code (4xx).</li>
<li>Since the error code was temporary, MTA 2 keep the message in queue to try sending it again later (usually after a delay between 1 and 60 minutes)</li>
<li>MTA 1 receives the second delivery attempt. It knows that the same triplet has tried sending a message previously, so it accepts the message.</li>
</ol>
<p>If MTA 2 was a bot sending spam, chances are that it would never bother trying again, so the spam will never come trough. In my experience, greylisting really helps with spam filtering, but of course with the drawback that some messages are delayed for several minutes.</p>
<h4>Greylisting drawbacks</h4>
<p>There are some drawbacks to using greylist :</p>
<ul>
<li>Message will be delayed from about 15 minutes to  1 hour, depending on the greylisting implementation and the sending MTA. This delay will only happen the first time a server with a given IP address send a message with a given sender and recipient address (MAIL FROM/RCPT TO).</li>
<li>Greylisting may cause problem with some big networks (like gmail, hotmail, &#8230;). These networks sometimes send emails from a different IP at each new try, so the greylisting delay will always start back from zero, until the same IP is used again. This may cause messages to be delayed longer than intended, or ultimately fail. This problem can be solved by whitelisting these networks and using SPF to accept message without going trough the greylist (if a server passes SPF test, it will most likely also pass the greylist).</li>
<li>Some non-compliant servers could treat the temporary error as an permanent error and drop the message, but I don&#8217;t think any important MTA have this problem.</li>
</ul>
<p>For more details, look at the <a href="http://en.wikipedia.org/wiki/Greylisting" target="_blank">Wikipedia article</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jphoude.qc.ca/2008/01/26/greylisting-with-exim-python-mysql/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CentOS 4.5 -&gt; 4.6 update on a Virtuozzo VPS</title>
		<link>http://blog.jphoude.qc.ca/2007/12/18/centos-45-46-update-on-a-virtuozzo-vps/</link>
		<comments>http://blog.jphoude.qc.ca/2007/12/18/centos-45-46-update-on-a-virtuozzo-vps/#comments</comments>
		<pubDate>Tue, 18 Dec 2007 18:47:16 +0000</pubDate>
		<dc:creator>jphoude</dc:creator>
				<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[rpm]]></category>
		<category><![CDATA[virtuozzo]]></category>
		<category><![CDATA[vps]]></category>
		<category><![CDATA[yum]]></category>

		<guid isPermaLink="false">http://blog.jphoude.qc.ca/2007/12/18/centos-45-46-update-on-a-virtuozzo-vps/</guid>
		<description><![CDATA[Updating from CentOS 4.5 to 4.6 is very easy. All you have to do is use yum : a simple &#8220;yum update&#8221; is all you need to do. However, when updating CentOS to the new 4.6 version on a Virtuozzo VPS, you may encounter a dependency error. On my VPS, I got the following message [...]]]></description>
			<content:encoded><![CDATA[<p>Updating from CentOS 4.5 to 4.6 is very easy. All you have to do is use yum : a simple &#8220;yum update&#8221; is all you need to do.</p>
<p>However, when updating CentOS to the new 4.6 version on a Virtuozzo VPS, you may encounter a dependency error. On my VPS, I got the following message :<span id="more-11"></span></p>
<pre>Missing Dependency: glibc-common = 2.3.4-2.36 is needed by package glibc-dummy-centos-4</pre>
<p>The problem is with the glibc-dummy-centos-4 package (provided by SWsoft), wich seems to not accept the new glibc-common version.</p>
<p>A solution I have found after searching on the web, is to simply remove the  glibc-dummy-centos-4 package. Apparently, this package doesn&#8217;t do anything (well, the name does say it&#8217;s dummy <img src='http://blog.jphoude.qc.ca/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , so removing it does not harm.</p>
<p>So the solution is :</p>
<pre>rpm -e glibc-dummy-centos-4</pre>
<p>You could also add <strong>exclude=glibc*</strong> to you yum.conf file, which is another solution I have found on the CentOS forum.</p>
<p>After that, you can resume your update with &#8220;yum update&#8221; without any problem!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jphoude.qc.ca/2007/12/18/centos-45-46-update-on-a-virtuozzo-vps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple incremental backup with rsync over SSH</title>
		<link>http://blog.jphoude.qc.ca/2007/12/01/simple-incremental-backup-rsync-ssh/</link>
		<comments>http://blog.jphoude.qc.ca/2007/12/01/simple-incremental-backup-rsync-ssh/#comments</comments>
		<pubDate>Sat, 01 Dec 2007 20:03:19 +0000</pubDate>
		<dc:creator>jphoude</dc:creator>
				<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[incremental]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://blog.jphoude.qc.ca/2007/12/01/simple-incremental-backup-rsync-ssh/</guid>
		<description><![CDATA[SSH and rsync can be used as a powerful backup tool. Together with hard links, it is also possible to use it to make incremental backups using a simple script. Simple rsync/SSH backups rsync is a powerful tool that, combined with SSH, can be used to easily transfer a large number of files over a [...]]]></description>
			<content:encoded><![CDATA[<p>SSH and rsync can be used as a powerful backup tool. Together with hard links, it is also possible to use it to make incremental backups using a simple script. <span id="more-9"></span></p>
<h3>Simple rsync/SSH backups</h3>
<p>rsync is a powerful tool that, combined with SSH, can be used to easily transfer a large number of files over a network connection. What&#8217;s more, it will also save bandwidth and time by only transferring files that have actually changed since the last backup. You can do a backup from one server to another with a command as simple as this one :</p>
<p>rsync -a &#8211;delete user@source.com:/var /destinationdir</p>
<p>Put this command in a crontab, and you have a basic backup system working!</p>
<h3>SSH keys</h3>
<p>A problem you may have with this solution is that the rsync command will ask for a password when run (the password for the remote user, since it uses SSH). This doesn&#8217;t work well with a backup script that you want to run each night at 00:00, for example.</p>
<p>There is a solution to that problem, of course! You can generate an SSH key that will allow you to login to the remote system without any password. I won&#8217;t go into details here (you can search about SSH keys on the web for more information), but here are the basics steps :</p>
<ol>
<li>Generate a private/public keypair on the &#8220;source&#8221; server, using the &#8220;source&#8221; user.</li>
<li>Copy the public key to the &#8220;target&#8221; system, and copy it&#8217;s content in the &#8220;.ssh/authorized_keys&#8221; file of the &#8220;target&#8221; user.</li>
<li>Login from the source server/user, to the target server/user, SSH will login using the private key and won&#8217;t ask any password!</li>
</ol>
<h3>How to make differential backups&#8230;</h3>
<p>It is the power of hard links that enables us to do an incremental backup. The command &#8220;cp -la dir1 dir2&#8243; will create a copy of the dir1 directory to dir2, using hard links for files (it doesn&#8217;t make links for directories, that wouldn&#8217;t make sense if you think about it&#8230;). The copy will take almost no space on disk, and will behave exactly like it was a real copy.</p>
<p>The idea of the rsync incremental backup is that you make a &#8220;cp -la&#8221; copy of your backup (made previously via rsync), which gives you two exactly same directories. Then, you can run rsync again to update one of the backups, which will give you an up-to-date backup, while the previous one stays exactly the same. You now have what seems like two complete backups, but it takes only the space of the full backup plus the changes between the two. The ease of use of the full backup strategy with the benefit of small disk space used by the incremental backup strategy!</p>
<h3>A simple backup script</h3>
<p>Here is a simple shell script that would create backups using this method. It will keep the latest 10 backups in directories from 0 to 9. 0 will always be the latest backup and 9 the oldest. Only the &#8220;0&#8243; backup is updated with rsync, after the rotations and hard-link copy have been made.</p>
<pre>#!/bin/sh
# rotate backups
rm -fr 9
mv 8 9
mv 7 8
mv 6 7
mv 5 6
mv 4 5
mv 3 4
mv 2 1
mv 1 2
# now make a copy using links of the latest backup
cp -la 0 1
# update the "0" backup with fresh files
rsync -av --delete backup@myserver.net:/ /storage/backups</pre>
<p>That&#8217;s all! Of course, this script doesn&#8217;t do any error checking, so I wouldn&#8217;t suggest using it without understanding and modifying it to your needs.</p>
<h3>A Python backup script</h3>
<p>I have written a Python script  that I use on my own servers. You can specify several backups to make, and options for each backup. Two backup modes are supported : rsync and mysql, which uses mysqldump to dump the database, then transfer it with SSH.</p>
<p>You can <a href="http://files.jphoude.qc.ca/backup.py" title="Python backup script" target="_blank">see or download the script here</a>.</p>
<p>Again, I recommend reading the script to understand it before using it. That&#8217;s never good to use something you don&#8217;t understand! Especially in this case as the script may not be full-proof or completely adapted to your situation.</p>
<p>For more information on rsync backups see : <a href="http://www.mikerubel.org/computers/rsync_snapshots/" target="_blank">http://www.mikerubel.org/computers/rsync_snapshots/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jphoude.qc.ca/2007/12/01/simple-incremental-backup-rsync-ssh/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Xen troubleshooting</title>
		<link>http://blog.jphoude.qc.ca/2007/11/17/xen-troubleshooting-centos-5/</link>
		<comments>http://blog.jphoude.qc.ca/2007/11/17/xen-troubleshooting-centos-5/#comments</comments>
		<pubDate>Sat, 17 Nov 2007 17:04:29 +0000</pubDate>
		<dc:creator>jphoude</dc:creator>
				<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[redhat]]></category>
		<category><![CDATA[troubleshooting]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://blog.jphoude.qc.ca/2007/11/17/xen-troubleshooting-centos-5/</guid>
		<description><![CDATA[Some problems you may have with Xen and their possible causes&#8230; These are problems I had with CentOS5 host/guests setup using LVM without a virtual disk, and without using the Redhat&#8217;s virt-manager tool, but of course it may also apply to other kinds of setup. Error: (22, &#8216;Invalid argument&#8217;) Possible causes : There is something [...]]]></description>
			<content:encoded><![CDATA[<p>Some problems you may have with Xen and their possible causes&#8230;</p>
<p>These are problems I had with CentOS5 host/guests setup using LVM without a virtual disk, and without using the Redhat&#8217;s virt-manager tool, but of course it may also apply to other kinds of setup.</p>
<p><span id="more-8"></span></p>
<h3>Error: (22, &#8216;Invalid argument&#8217;)</h3>
<p>Possible causes :</p>
<ul>
<li>There is something wrong with the kernel referenced by the &#8220;kernel&#8221; parameter of the domU configuration file. Perhaps that&#8217;s not a valid kernel, or the file doesn&#8217;t exist.</li>
<li>There is something wrong with the partitions referenced by the &#8220;disk&#8221; parameter of the domU configuration file. Perhaps the device it points to doesn&#8217;t exist, or it is not a valid device.</li>
</ul>
<h3>Error: destroyDevice() takes exactly 3 arguments (2 given)</h3>
<p>Possible cause :</p>
<ul>
<li> The domU root partition is mounted. It must be unmounted before booting the domU.</li>
</ul>
<h3>switchroot: mount failed: No such file or directory</h3>
<p>Possible cause :</p>
<ul>
<li>The kernel you&#8217;re trying to boot does not support booting as a Xen domU. If you try to boot the kernel-xen that comes with CentOS, it will NOT work (at least, it doesn&#8217;t work without using a virtual disk like the virt-manager tool does). You should try using the kernel that comes with the official Xen distribution. You can <a href="http://xen.org/download/dl_31tarballs.html" target="_blank">download the tarball here</a>, and use the kernel located in the dist/install/boot directory.</li>
</ul>
<h3>No console, boot process seems to hang up after &#8220;Starting SSHD&#8221;</h3>
<p>Possible cause :</p>
<ul>
<li>I have noticed that the images from jailtime.org have this problem, and images that you made yourself may also have this problem. You need to configure a console for Xen in the /etc/initab file of the domU. Add this line to the domU&#8217;s inittab file :
<pre><code>co:2345:respawn:/sbin/mingetty console</code></pre>
</li>
</ul>
<h3>Warning: unable to open an initial console.<br />
Restarting system.</h3>
<p>Possible cause :</p>
<ul>
<li>I had this problem when using the kernels from XenSource to boot a CentOS 5 image (this worked previously, but now fails). I fixed the problem by using the kernel that comes with CentOS 5.1 instead, and building an initrd for the Xen guest. For more information, <a href="http://blog.jphoude.qc.ca/2007/11/03/centos-5-xen-images-part-2/#comment-22">see this comment</a>.</li>
</ul>
<h3></h3>
<h3>Yum update problem</h3>
<pre>Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=5&amp;arch=x86_64&amp;repo=os error was
[Errno 4] IOError: &lt;urlopen error (-3, 'Temporary failure in name resolution')&gt;
Error: Cannot find a valid baseurl for repo: base</pre>
<ul>
<li>You problably forgot to configure nameservers. Edit /etc/resolf.conf and add &#8220;nameserver&#8221; lines. For example :<br />
nameserver 4.2.2.1<br />
nameserver 4.2.2.2</li>
</ul>
<h3>Iptables problem</h3>
<p>Trying to start iptables gives :</p>
<pre>iptables v1.3.5: can't initialize iptables table `filter': iptables who? (do you need to insmod?)</pre>
<pre>Perhaps iptables or your kernel needs to be upgraded.</pre>
<p>Trying to &#8220;modprobe iptables&#8221; also gives an error message :</p>
<pre>FATAL: Could not load /lib/modules/2.6.18-53.1.6.el5xen/modules.dep: No such file or directory</pre>
<p>Here what I did to fix the problem:</p>
<ul>
<li>yum install kernel-xen kernel-xen-devel</li>
<li>/sbin/depmod</li>
</ul>
<p>After that, /sbin/iptables -L now works correctly!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jphoude.qc.ca/2007/11/17/xen-troubleshooting-centos-5/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CentOS 5 Xen images &#8211; part 2: installing the Xen guest</title>
		<link>http://blog.jphoude.qc.ca/2007/11/03/centos-5-xen-images-part-2/</link>
		<comments>http://blog.jphoude.qc.ca/2007/11/03/centos-5-xen-images-part-2/#comments</comments>
		<pubDate>Sat, 03 Nov 2007 15:46:59 +0000</pubDate>
		<dc:creator>jphoude</dc:creator>
				<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[lvm]]></category>
		<category><![CDATA[redhat]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://blog.jphoude.qc.ca/2007/11/03/centos-5-xen-images-part-2/</guid>
		<description><![CDATA[OK, so you downloaded an image from jailtime.org or you made your own image as described in my previous post, and now you want to install a Xen guest using it. Here&#8217;s how to do it : Setup the dom0 (host OS) Of course, Xen should be installed on the host OS. I use CentOS [...]]]></description>
			<content:encoded><![CDATA[<p>OK, so you downloaded an image from <a href="http://jailtime.org/" target="_blank">jailtime.org</a> or you made your own image as described in <a href="http://blog.jphoude.qc.ca/2007/10/26/centos-5-xen-images-part-1/">my previous post</a>, and now you want to install a Xen guest using it. Here&#8217;s how to do it :</p>
<h3><span id="more-7"></span></h3>
<h3>Setup the dom0 (host OS)</h3>
<p>Of course, Xen should be installed on the host OS. I use CentOS 5, so I just selected Xen during the installation. It will install a xen kernel that you should use to boot the host OS (dom0). I won&#8217;t go into details here, because that&#8217;s really easy to do with CentOS or Redhat Enterprise Linux. With other distributions, you could have to install distribution-specific packages, or use the official Xen package from <a href="http://xen.org/download/" target="_blank">xen.org</a>.</p>
<h3>Setup the target partition or logical volume</h3>
<p>You should create a filesystem for the &#8220;root&#8221; partition and the swap. You could use simple files, but you will have better performance using real partitions or LVM volumes. LVM volumes also has other advantages, like the ability to create snapshots for backing up data, and easy resizing.</p>
<p>The following commands will create a 5GB root logical volume (LV) and 1GB swap in the /dev/vg0 volume group (VG). For more information about LVM, search for LVM howto in a search engine.</p>
<pre class="code"># root
lvcreate -L 5000M -n mailroot /dev/vg0
mkfs.ext3 /dev/vg0/mailroot
# swap
lvcreate -L 1000M -n mailswap /dev/vg0
mkswap /dev/vg0/mailswap</pre>
<p>You can then mount the root partition and copy the base system (either an image from jailtime or an image you made yourself) on it.</p>
<pre>mkdir /mnt/mailroot
mount /dev/vg0/mailroot /mnt/mailroot
# if you image contents is located in /centos...
cp -R /centos/* /mnt/mailroot/</pre>
<p>Don&#8217;t forget to unmount the root partition when you&#8217;re done! Xen will not boot the domain if the partition is already mounted.</p>
<h3>Download a kernel for the domU</h3>
<p>The kernel that we will need to boot the domU has be to located in the dom0.</p>
<p>You can use the standard xen kernel that comes with CentOS to do that (e.g. vmlinuz-2.6.18-53.1.13.el5xen) , but you&#8217;ll also need an initrd, or the kernel won&#8217;t boot. To make the initrd, use the following command :</p>
<pre>/sbin/mkinitrd --with=xennet --preload=xenblk /boot/initrd-centos5-xen.img 2.6.18-53.1.13.el5xen</pre>
<p>This makes an initrd image with the required modules to boot a domU. The last parameter is the version of your kernel (the one you will use to boot the domU). You can get this number by typing &#8220;uname -r&#8221; on the command line. This will result in a /boot/initrd-centos5-xen.img image file.</p>
<p>Note (2008-02-14) : in a previous version of this blog post, I recommended to use a kernel from the official Xen distribution at xen.org. It worked, but it doesn&#8217;t seem to work anymore.</p>
<h3>Create the configuration file</h3>
<p>The configuration of the Xen guest is controlled by a simple text file. Create it as /etc/xen/<em>yourdomUname</em>, and move (or symlink) it in /etc/xen/auto if you want to start it automatically on boot.</p>
<p>Most basic parameters in this file are easy to understand. You should make sure &#8220;kernel&#8221; points to the kernel you copied from the xen tarball. &#8220;memory&#8221; is the amount of RAM allocated to the guest. &#8220;name&#8221; will be the name of the guest that you will use when connecting to it or shutting it down using the &#8220;xm&#8221; command.</p>
<p>&#8220;vif&#8221; contains information about network interfaces. One important thing in that line is the MAC address. If you don&#8217;t specify it here, a random MAC will be assigned at each boot, and that may not give good results. Edit the last 3 numbers (put anything, it just has to be unique across your network).</p>
<p>Finally, &#8216;disk&#8217; is the parameter that tells Xen what partitions to use and what device name it will assign them. The last line, &#8216;root&#8217;, will tell the kernel what is the root device.</p>
<pre class="code">kernel = "/boot/vmlinuz-2.6.18-53.1.13.el5xen"
ramdisk = "/boot/initrd-centos5-xen.img"
memory = 512
name = "mail"
vif = [ 'mac=00:16:3e:21:f1:31,bridge=xenbr0' ]
dhcp = "dhcp"
disk = ['phy:/dev/vg0/mailroot,sda1,w', 'phy:/dev/vg0/mailswap,sda2,w' ]
# The next line would be useful if you want to use an simple file instead of a partition/LV
#disk = ['file:/root/test.img,sda1,w', 'file:/root/centos.swap,sda2,w' ]
# We don't use pygrub, we boot the kernel directly from dom0
#bootloader="/usr/bin/pygrub"
root = "/dev/sda1 ro"</pre>
<h3>Boot the domain!</h3>
<p>OK, you&#8217;re ready to boot the guest domain! Just issue the following command to &#8220;create&#8221; (which means boot, really) the domU.</p>
<pre>xm create /etc/xen/YOUR_CONFIG_FILE -c</pre>
<p>The  -c parameter tells xm to connect to the domain&#8217;s console. You can disconnect from it by pressing CTRL+], and connect to it again with &#8220;xm connect NAME&#8221;.</p>
<p>If everything works right, you should see the login prompt appearing, and you will be ready to use the new guest domain!</p>
<h4>Fix SSH</h4>
<p>If you made the guest image yourself as I explained in my previous post (part 1), you need to create the random device to fix SSH (and probably other services that requires  generating keys). Issue the following commands on the guest&#8217;s console :</p>
<pre>/sbin/MAKEDEV generic
/etc/init.d/sshd start</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.jphoude.qc.ca/2007/11/03/centos-5-xen-images-part-2/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
