<?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>The Magic Position &#187; Uncategorized</title>
	<atom:link href="http://www.magicposition.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.magicposition.com</link>
	<description>Don't just build websites: develop the web.</description>
	<lastBuildDate>Tue, 17 Jan 2012 02:01:05 +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>Installing Galera MySQL clustering on Ubuntu 10</title>
		<link>http://www.magicposition.com/2012/01/16/installing-galera-mysql-clustering-on-ubuntu-10/</link>
		<comments>http://www.magicposition.com/2012/01/16/installing-galera-mysql-clustering-on-ubuntu-10/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 02:01:05 +0000</pubDate>
		<dc:creator>Laurie</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.magicposition.com/?p=58</guid>
		<description><![CDATA[Galera is a patch and a library for MySQL that work together at the engine level to provide simple, multi-master replication between MySQL instances. It promises to be easier to set up than ordinary MySQL replication, and allow you to write to more than one machine, a feature currently unavailable from vanilla MySQL.
The documentation is [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://codership.com/">Galera</a> is a patch and a library for MySQL that work together at the engine level to provide simple, multi-master replication between MySQL instances. It promises to be easier to set up than ordinary MySQL replication, and allow you to write to more than one machine, a feature currently unavailable from vanilla MySQL.</p>
<p>The <a href="http://www.codership.com/wiki/doku.php">documentation</a> is laughably sparse, but I found a <a href="https://groups.google.com/group/codership-team/browse_thread/thread/ba41ef2fb4f0dfef?pli=1">helpful post on the mailing list</a> which gave me the clues I needed to get it up and running on a trio of local virtual machines. Once I&#8217;ve run some more tests I&#8217;ll give a more thorough review of the tech, but the smoke-test confirms: yes, you can get replication between 3 masters that survives the loss of any one of the machines, and even supports auto-incrementing indexes! If this tech turns out to be stable, it&#8217;s pretty much the holy grail of MySQL.</p>
<h2>Installing Galera</h2>
<p>You need to install both the <a href="https://launchpad.net/codership-mysql/5.1/5.1.59-22.2">mySQL deb with the wsrep patch</a>, and the <a href="https://launchpad.net/galera/1.x/22.1.1">galera library</a> itself:</p>
<p><code>wget http://launchpad.net/codership-mysql/5.1/5.1.59-22.2/+download/mysql-server-wsrep-5.1.59-22.2-i386.deb<br />
wget http://launchpad.net/galera/1.x/22.1.1/+download/galera-22.1.1-i386.deb<br />
</code></p>
<p>Install the packages. dpkg will complain that things are broken, so get apt-get to install the dependencies for you:<br />
<code>dpkg -i galera-22.1.1-i386.deb mysql-server-wsrep-5.1.59-22.2-i386.deb<br />
apt-get -f install<br />
</code></p>
<p>Now you need to temporarily start the server so you can configure it (you&#8217;ve missed the usual mySQL setup wizard):<br />
<code>/usr/bin/mysqld_safe &#038;<br />
</code></p>
<p>Run the secure installation setup to configure your root password, etc.:<br />
<code>/usr/bin/mysql_secure_installation<br />
</code></p>
<p>Now, set MySQL to bind to the external adapter instead of localhost (127.0.0.1), for example:</p>
<p><code>nano /etc/mysql/my.cnf<br />
<b>bind: <i>10.0.1.109</i></b><br />
</code></p>
<p>Now that&#8217;s done, kill your temporary server. I&#8217;m dumb, so I did it this messy way:<br />
<code>ps axf | grep mysqld<br />
kill -9 <i>any pids from above</i><br />
</code></p>
<p>Now start mySQL properly:<br />
<code>service mysql restart</code></p>
<p>Now you need to configure galera itself. Galera config is under mySQL&#8217;s:<br />
<code>nano /etc/mysql/conf.d/wsrep.cnf</code></p>
<p>First, tell it where you&#8217;ve installed the galera lib:<br />
<code>wsrep_provider=/usr/lib/galera/libgalera_smm.so</code></p>
<p>Now give it the cluster address. For the very first node, that address is just:<br />
<code>wsrep_cluster_address="gcomm://"</code></p>
<p>For any subsequent nodes, set it to point at the first node:<br />
<code>wsrep_cluster_address="gcomm://10.0.1.109"</code></p>
<p>At the moment it&#8217;s not clear to me why this works this way, since if the first node falls over the other two nodes seem to remain capable of syncing with each other, i.e. there is no &#8220;master&#8221; node. I&#8217;ll understand better once I&#8217;ve done more reading, I guess.</p>
<p>You will need to provide a replication username/password between the nodes:<br />
<code>wsrep_sst_auth=<b>username</b>:<b>password</b></code></p>
<p>And restart mysql again.</p>
<p>Finally, connect to MySQL and grant permissions to your replication user (NB: you need to run these two commands as a single line &#8212; galera seems to do weird things with connections to clients).</p>
<p><code>set wsrep_on = OFF; grant all on *.* to '<b>username</b>'@'%' identified by '<b>password</b>';</code></p>
<p>Done! Repeat these steps for as many nodes as you want, changing only the gcomm address, and you&#8217;ll get that many replicated nodes. Amazing!</p>
<h2>Fun facts</h2>
<p>I&#8217;m just starting to get to grips with the features of Galera, but so far the cool things I&#8217;ve noticed are:</p>
<ol>
<li>New nodes can sync from empty, i.e. no need to take a mysqldump snapshot beforehand</li>
<li>Database and table creates (and drops!) are respected and synced to all boxes</li>
<li>Tables with auto_increment indexes create non-conflicting IDs (although they are no longer strictly sequential, so you will get gaps in your numerical sequence).
<li>Any of the nodes can drop out temporarily and will catch back up</li>
<li>Restarting MySQL seems to fix most syncing problems</li>
</ol>
<p>I&#8217;ll write more about pros and cons once I&#8217;ve had a chance to play with Galera some more.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.magicposition.com/2012/01/16/installing-galera-mysql-clustering-on-ubuntu-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>You can host static websites on Amazon S3</title>
		<link>http://www.magicposition.com/2011/03/09/you-can-host-static-websites-on-amazon-s3/</link>
		<comments>http://www.magicposition.com/2011/03/09/you-can-host-static-websites-on-amazon-s3/#comments</comments>
		<pubDate>Wed, 09 Mar 2011 18:50:49 +0000</pubDate>
		<dc:creator>Laurie</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.magicposition.com/?p=56</guid>
		<description><![CDATA[Hosting websites on Amazon Simple Storage Service is just a matter of uploading HTML files to an S3 bucket and then pointing a domain at it. Great if you have a static website with enormous traffic, but who has a completely static website?
]]></description>
			<content:encoded><![CDATA[<p><a href='http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?WebsiteHosting.html'>Hosting websites on Amazon Simple Storage Service</a> is just a matter of uploading HTML files to an S3 bucket and then pointing a domain at it. Great if you have a static website with enormous traffic, but who has a completely static website?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.magicposition.com/2011/03/09/you-can-host-static-websites-on-amazon-s3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing PHP 5&#8217;s Standard Library</title>
		<link>http://www.magicposition.com/2011/03/07/introducing-php-5s-standard-library/</link>
		<comments>http://www.magicposition.com/2011/03/07/introducing-php-5s-standard-library/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 20:20:58 +0000</pubDate>
		<dc:creator>Laurie</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.magicposition.com/?p=54</guid>
		<description><![CDATA[Introducing PHP 5&#8217;s Standard Library.
A pretty good overview of how to create iterators, pseudo arrays, etc. in PHP&#8217;s class structures.
]]></description>
			<content:encoded><![CDATA[<p><a href='http://articles.sitepoint.com/article/php5-standard-library'>Introducing PHP 5&#8217;s Standard Library</a>.</p>
<p>A pretty good overview of how to create iterators, pseudo arrays, etc. in PHP&#8217;s class structures.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.magicposition.com/2011/03/07/introducing-php-5s-standard-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Flash.now &#8211; Blog &#8211; Tim Harding &#8211; g0</title>
		<link>http://www.magicposition.com/2011/03/07/rails%c2%a0flash-now-blog-tim-harding-g0/</link>
		<comments>http://www.magicposition.com/2011/03/07/rails%c2%a0flash-now-blog-tim-harding-g0/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 20:04:21 +0000</pubDate>
		<dc:creator>Laurie</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.magicposition.com/?p=52</guid>
		<description><![CDATA[Rails&#8217; flash.now is what to use if you want a flash message to appear only once, on the page you&#8217;re currently rendering.
]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.gatezero.org/blog/2008/10/7/rails-flashnow.html'>Rails&#8217; flash.now</a> is what to use if you want a flash message to appear only once, on the page you&#8217;re currently rendering.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.magicposition.com/2011/03/07/rails%c2%a0flash-now-blog-tim-harding-g0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Before PostgreSQL, Bruce Momjian wrote an SQL in Shell</title>
		<link>http://www.magicposition.com/2011/03/06/before-postgresql-bruce-momjian-wrote-an-sql-in-shell/</link>
		<comments>http://www.magicposition.com/2011/03/06/before-postgresql-bruce-momjian-wrote-an-sql-in-shell/#comments</comments>
		<pubDate>Sun, 06 Mar 2011 09:07:38 +0000</pubDate>
		<dc:creator>Laurie</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.magicposition.com/?p=50</guid>
		<description><![CDATA[Before PostgreSQL, Bruce Momjian wrote an SQL in Shell &#8211; Andrew Cholakian&#8217;s Blog.
]]></description>
			<content:encoded><![CDATA[<p><a href='http://blog.andrewvc.com/before-postgresql-bruce-momjian-wrote-an-sql'>Before PostgreSQL, Bruce Momjian wrote an SQL in Shell &#8211; Andrew Cholakian&#8217;s Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.magicposition.com/2011/03/06/before-postgresql-bruce-momjian-wrote-an-sql-in-shell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generating a UUID in PHP</title>
		<link>http://www.magicposition.com/2010/09/25/generating-a-uuid-in-php/</link>
		<comments>http://www.magicposition.com/2010/09/25/generating-a-uuid-in-php/#comments</comments>
		<pubDate>Sat, 25 Sep 2010 19:49:35 +0000</pubDate>
		<dc:creator>Laurie</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.magicposition.com/?p=38</guid>
		<description><![CDATA[We need to generate UUIDs in PHP. This is actually extremely easy: there is a PHP UUID package in PECL, but you&#8217;d never know, because there&#8217;s no documentation, a problem that&#8217;s apparently been the case forever &#8212; a documentation bug was opened in 2006, but never resolved, even though there is some documentation in the [...]]]></description>
			<content:encoded><![CDATA[<p>We need to generate UUIDs in PHP. This is actually extremely easy: there is a <a href="http://pecl.php.net/package/uuid">PHP UUID package in PECL</a>, but you&#8217;d never know, because there&#8217;s no documentation, a problem that&#8217;s apparently been the case forever &#8212; a <a href="http://pecl.php.net/bugs/bug.php?id=7765&#038;edit=1">documentation bug</a> was opened in 2006, but never resolved, even though there is some <a href="http://svn.php.net/viewvc/pecl/uuid/trunk/manual/uuid/">documentation in the source code</a>.</p>
<p>Even more simply, in ubuntu there is a package called <a href="http://www.ubuntuupdates.org/packages/show/37736">php5-uuid</a>. It can be installed just with</p>
<p><code>apt-get install php5-uuid</code></p>
<p>However, documentation is even more sparse for this one &#8212; the best that exists appears to be a <a href="http://www.php.net/manual/en/function.uniqid.php#88434">comment on the PHP manual page for uniqid()</a> (of course, if all you need is a unique ID, that function is probably easier still, but we needed a UUID specifically). Anyway, the magic code to create a UUID is simply this:</p>
<p><code><br />
uuid_create(&#038;$v4);<br />
uuid_make($v4, UUID_MAKE_V4);<br />
uuid_export($v4, UUID_FMT_STR, &#038;$v4String);<br />
echo "My UUID is now in $v4string";<br />
</code></p>
<p>This is obviously a version 4 UUID; you can trivially make the others just by changing the arguments appropriately. Wikipedia has a good page explaining the <a href="http://en.wikipedia.org/wiki/Universally_unique_identifier#Definition">difference between UUID versions</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.magicposition.com/2010/09/25/generating-a-uuid-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python errors running s3cmd on Amazon AWS</title>
		<link>http://www.magicposition.com/2010/05/14/python-errors-running-s3cmd-on-amazon-aws/</link>
		<comments>http://www.magicposition.com/2010/05/14/python-errors-running-s3cmd-on-amazon-aws/#comments</comments>
		<pubDate>Fri, 14 May 2010 19:28:40 +0000</pubDate>
		<dc:creator>Laurie</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.magicposition.com/?p=30</guid>
		<description><![CDATA[Whenever I ran s3cmd on my AWS instance, I got the following errors:

/usr/lib/python2.6/dist-packages/S3/S3.py:9: DeprecationWarning: the md5 module is deprecated; use hashlib instead
/usr/lib/python2.6/dist-packages/S3/S3.py:10: DeprecationWarning: the sha module is deprecated; use the hashlib module instead

The problem is that this is an old, crappy version of s3cmd, 0.9.8.4. You can get version 0.9.9 using the instructions in the [...]]]></description>
			<content:encoded><![CDATA[<p>Whenever I ran s3cmd on my AWS instance, I got the following errors:</p>
<p><code><br />
/usr/lib/python2.6/dist-packages/S3/S3.py:9: DeprecationWarning: the md5 module is deprecated; use hashlib instead<br />
/usr/lib/python2.6/dist-packages/S3/S3.py:10: DeprecationWarning: the sha module is deprecated; use the hashlib module instead<br />
</code></p>
<p>The problem is that this is an old, crappy version of s3cmd, 0.9.8.4. You can <a href="http://blog.markfeeney.com/2010/01/s3cmd-099-on-ubuntu-904jaunty.html">get version 0.9.9</a> using the instructions in the linked blog post. It&#8217;s just a matter of adding a new source to your apt-get sources list and then running apt-get update.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.magicposition.com/2010/05/14/python-errors-running-s3cmd-on-amazon-aws/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ssh_exchange_identification: read: Connection reset by peer</title>
		<link>http://www.magicposition.com/2010/04/12/ssh_exchange_identification-read-connection-reset-by-peer/</link>
		<comments>http://www.magicposition.com/2010/04/12/ssh_exchange_identification-read-connection-reset-by-peer/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 23:01:48 +0000</pubDate>
		<dc:creator>Laurie</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.magicposition.com/?p=27</guid>
		<description><![CDATA[I got this while attempting to ssh into a VM on ubuntu. When I pinged the box, I got this:

PING 192.168.1.86 (192.168.1.86) 56(84) bytes of data.
64 bytes from 192.168.1.86: icmp_seq=1 ttl=64 time=0.614 ms
64 bytes from 192.168.1.86: icmp_seq=1 ttl=64 time=1.89 ms (DUP!)
64 bytes from 192.168.1.86: icmp_seq=2 ttl=64 time=0.602 ms
64 bytes from 192.168.1.86: icmp_seq=2 ttl=64 time=0.925 ms [...]]]></description>
			<content:encoded><![CDATA[<p>I got this while attempting to ssh into a VM on ubuntu. When I pinged the box, I got this:</p>
<blockquote><p>
PING 192.168.1.86 (192.168.1.86) 56(84) bytes of data.<br />
64 bytes from 192.168.1.86: icmp_seq=1 ttl=64 time=0.614 ms<br />
64 bytes from 192.168.1.86: icmp_seq=1 ttl=64 time=1.89 ms (DUP!)<br />
64 bytes from 192.168.1.86: icmp_seq=2 ttl=64 time=0.602 ms<br />
64 bytes from 192.168.1.86: icmp_seq=2 ttl=64 time=0.925 ms (DUP!)
</p></blockquote>
<p>Whoops! The VM was already running and had been granted the exact same IP. It was responding from two places at the same time, which was confusing the hell out of SSH. Just kill one of the boxes and you&#8217;re fine (DHCP release/refresh doesn&#8217;t work, because both boxes have the same MAC address).</p>
<p>Thanks to <a href="http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1291605&#038;admit=109447626+1271112696910+28353475">this thread</a> for the hint.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.magicposition.com/2010/04/12/ssh_exchange_identification-read-connection-reset-by-peer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>no such file to load &#8212; mkmf</title>
		<link>http://www.magicposition.com/2010/04/03/no-such-file-to-load-mkmf/</link>
		<comments>http://www.magicposition.com/2010/04/03/no-such-file-to-load-mkmf/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 02:42:37 +0000</pubDate>
		<dc:creator>Laurie</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.magicposition.com/?p=21</guid>
		<description><![CDATA[I got this when trying to install the ruby thrift client. It&#8217;s trying to compile a native extension, which needs ruby 1.8 dev version. Simple fix:

sudo apt-get install ruby1.8-dev

]]></description>
			<content:encoded><![CDATA[<p>I got this when trying to install the ruby thrift client. It&#8217;s trying to compile a native extension, which needs ruby 1.8 dev version. Simple fix:</p>
<p><code><br />
sudo apt-get install ruby1.8-dev<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.magicposition.com/2010/04/03/no-such-file-to-load-mkmf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

