<?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>Web Stew &#187; Uncategorized</title>
	<atom:link href="http://www.gavey.ca/blog/index.php/topics/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gavey.ca/blog</link>
	<description>Web development trends, techniques and demos</description>
	<lastBuildDate>Thu, 12 May 2011 02:41:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>A Guide to Mysql Master to Master (Circular Replication)</title>
		<link>http://www.gavey.ca/blog/index.php/2011/05/11/a-guide-to-mysql-master-to-master-circular-replication/</link>
		<comments>http://www.gavey.ca/blog/index.php/2011/05/11/a-guide-to-mysql-master-to-master-circular-replication/#comments</comments>
		<pubDate>Thu, 12 May 2011 02:35:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.gavey.ca/blog/?p=33</guid>
		<description><![CDATA[In this guide I will give you a step by step process for setting up Circular replication with MySQL. But first perhaps I should explain what it is. Normal MySQL replication is simple enough.  You have a master database that sends all the SQL queries it executes to a slave database so that the servers [...]]]></description>
			<content:encoded><![CDATA[<p>In this guide I will give you a step by step process for setting up Circular replication with MySQL. But first perhaps I should explain what it is.</p>
<p>Normal MySQL replication is simple enough.  You have a <strong>master</strong> database that sends all the SQL queries it executes to a<strong> slave</strong> database so that the servers will always maintain the same set of data . In a Circular or (Master to Master) replication,  when a database entry is inserted to or updated on the <strong>"Slave" </strong>database that record is also updated on the<strong> Master</strong> server.  So essentially you would have two database servers that would theoretically have exactly the same data in nearly real time. Hopefully that makes sense.</p>
<p>Now why would you want this kind of a database set up?  Well there are a few reasons, but let me give you the reason we are doing this.</p>
<p>In our scenario we have 2 servers running at 2 different data servers in 2 different cities. The first server <strong>"Water"</strong> is currently the Master server.  All our web traffic is run through it.  The second server <strong>"Fire"</strong> is a fail-over server.  It maintains a constant up to date copy of all the code, files and database that exists on the main server.</p>
<p>If <strong>Water</strong> were to fail for some reason we switch to <strong>Fire</strong> which is already synced and ready to go. As a side note we accomplish this through the use of Global DNS Load Balancing but that is information for another post.  Now at this point <strong>Fire</strong> has been running for a day while <strong>Water</strong> is now prepped, fixed and ready to go back online.  The problem is that now all the data on <strong>Fire</strong> needs to be synced back to <strong>Water</strong>.  You could do this from a export and import but that would be costly time wise.  If out databases where synced in a circular replication scenario, then as soon as <strong>Water</strong> is back up, it would simply  be update itself from the point where <strong>Fire</strong> took over. A few minutes (or hours) later and the databases are in sync again.</p>
<p>In a separate but similar scenario you could use this same method to keep both <strong>Fire</strong> and <strong>Water</strong> in a load balanced scenario where each one gets half the traffic as well. A circular replication scheme would keep all the data in sync.</p>
<p><strong>So how do I do it?</strong></p>
<p>In this example I'm going to make a few assumptions.</p>
<ol>
<li>You don't currently have a secondary slave server setup yet.</li>
<li>That you are running version 5.5+ of MySQL. (These instructions may work with version 5.0 and up as well)</li>
<li>Your MySQL setup is using InnoDB as the default storage engine (It has to be for any replication to work) default-storage-engine = INNODB in the my.ini</li>
<li>Your MySQL is setup to be accessible through a network connection and that the servers can talk to each other through port 3306 (We currently do this through a VPN for extra security, however there is a way of using an SSL connection in MySQL as well)</li>
</ol>
<p>Ok lets get our hands dirty.</p>
<p>To try and keep things clear I will refer to the existing server as <strong>"Water"</strong> and the new server you will set up as <strong>"Fire"</strong>. Before we get <strong>Fire</strong> set up we need to update the my.ini on <strong>Water</strong>.</p>
<p>You will need to add these options to <strong>Water's</strong> my.ini on Windows or my.cnf on Linux:</p>
<p><strong><code>server-id = 10<br />
auto-increment-increment = 2<br />
auto-increment-offset=1<br />
log-bin = binarylog<br />
log-error = replErrorLog</code></strong></p>
<p>The server-id is the id of each replication server and needs to be unique for each.</p>
<p>The auto-increment takes more explaining.  In the case where both servers are writing data at the same time, the potential for the servers to create a different record in a table with the same ID exists.  These two config variables tell the server to auto increment table id's 2 at a time. One server will create odd id's and the other even that way the index values never collide. If they did, it would break replication.</p>
<p>Log-bin is the name of the binary log that the servers read from each other so they get the updates.  It can be called whatever you like as long as you reference it properly later. Log-error is the name of the replication error file you will have to read if something goes wrong.</p>
<p>We need to create a new user for MySQL that<strong> Fire</strong> will connect with that has replication privileges. To do this you will have to enter the next command into your MySQL console on <strong>Water</strong>.<br />
<code>CREATE USER 'repluser'@'%' IDENTIFIED BY 'replpass';<br />
GRANT REPLICATION SLAVE ON *.* TO 'repluser'@'%';<br />
</code><br />
Now that the replication user is ready to go on <strong>Water</strong> we need get some information ready for <strong>Fire</strong>. You need to make a backup of your data now so when <strong>Fire</strong> is up and running you have a copy of your data before replication was ready to start. It's very important that no data is written to the database while the backup is being run or you may not have a complete copy on <strong>Fire</strong>.  For more information on how to get an export of your data see <a href="http://dev.mysql.com/doc/refman/5.0/en/replication-howto-mysqldump.html">http://dev.mysql.com/doc/refman/5.0/en/replication-howto-mysqldump.html</a> .</p>
<p>Now that you have a copy of your data exported you need to enter this command into your MySQL console on <strong>Water</strong>.<br />
<code><br />
<strong>reset master;<br />
show master status;</strong></code></p>
<p>After you run the show master status you will get a listing that contains two items that you need to write down.  The file name which will look something like "binarylog.000001" and the position which will be a number like 107. Mark these down under the title <strong>Water</strong> replication reference. Now that you have this information <strong>Water</strong> can go back to it's regular database duties and <strong>Fire</strong> will know where to start it's replication when it's ready for it.</p>
<p>Great, now we are finally ready to get <strong>Fire</strong> up and running. After you have installed the MySQL software on <strong>Fire</strong> you should import the databases from the backup you made. Now we need to configure <strong>Fire</strong> in a similar matter to <strong>Water</strong>. Make these changes to the my.ini on <strong>Fire</strong>.</p>
<p><strong><code>server-id = 20 #different than Water's<br />
auto-increment-increment = 2<br />
auto-increment-offset=2 #also different than Water<br />
log-bin = binarylog<br />
log-error = replErrorLog</code></strong></p>
<p>As always with my.ini changes make sure to restart MySQL to ensure they take affect. Now login to the MySQL console again and add the slave user as we did before.</p>
<p><code><strong>CREATE USER 'repluser'@'%' IDENTIFIED BY 'replpass';</strong><br />
<strong> GRANT REPLICATION SLAVE ON *.* TO 'repluser'@'%';</strong><br />
</code></p>
<p>Now get the master position information.</p>
<p><strong><code>show master status;</code></strong></p>
<p>Again write down the log file name and the position as <strong>Fire</strong> replication reference (It may very well be different than the <strong>Water</strong> one). On<strong> Fire</strong> we now need to set the slave replication information so again in the console type the following command changing master_log_file and master_log_pos to the information you had written down as "Water Replication Information".</p>
<p><code><br />
<strong>change master to</strong><br />
<strong> master_host='waterIPaddress',</strong><br />
<strong> master_user='repluser',</strong><br />
<strong> master_password='replpass',</strong><br />
<strong> master_port=3306,</strong><br />
<strong> master_log_file='binarylog.000001',</strong><br />
<strong> master_log_pos=107;</strong><br />
</code></p>
<p>Now Fire is configured to receive replication information from Water. Now we need to start the slave and hope it works.</p>
<p><code><br />
<strong>slave start;</strong><br />
<strong> show slave status;</strong><br />
</code></p>
<p>Show slave status should printout a fair bit of information, near then end of it you should have a status line saying something like "Waiting for Master to send event" this means it's done replicating for now and waiting for an update to be pushed. Congratulations, but were not done yet.</p>
<p>Now back on <strong>Water</strong> we need to start the replication from the <strong>Fire</strong> server so again start up your MySQL console and type this in changing master_log_file and master_log_pos to the information you had written down as "Fire Replication Information".</p>
<p><code><br />
<strong>change master to</strong><br />
<strong> master_host='fireIPpaddress',</strong><br />
<strong> master_user='repluser',</strong><br />
<strong> master_password='replpass',</strong><br />
<strong> master_port=3306,</strong><br />
<strong> master_log_file='binarylog.000001',</strong><br />
<strong> master_log_pos=107;</strong><br />
</code></p>
<p>Great and start the slave on Water now.</p>
<p><strong><code> slave start show slave status; </code></strong></p>
<p>Again the slave status show show "Waiting for Master to send Event" if it does great you did it. If it throws an error though, your going to have to look into that.  Find the replErrorLog.err (or whatever you called it) file in the MySQL data directory and hopefully that will help you track down the problem.  For a more complete reference on MySQL replication, see <a href="http://dev.mysql.com/doc/refman/5.0/en/replication-howto.html">http://dev.mysql.com/doc/refman/5.0/en/replication-howto.html</a></p>
<p>Hope this post helped you out. Happy Queries.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gavey.ca/blog/index.php/2011/05/11/a-guide-to-mysql-master-to-master-circular-replication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Side project</title>
		<link>http://www.gavey.ca/blog/index.php/2010/03/19/new-side-project/</link>
		<comments>http://www.gavey.ca/blog/index.php/2010/03/19/new-side-project/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 14:56:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.gavey.ca/?p=28</guid>
		<description><![CDATA[My wife and I have wanted to work together on a project for a long time. It took as a while to figure out just what that project might be.  Well after many evenings of conversations over some great Cabernet's we came up with the idea of publishing some of her short stories she was [...]]]></description>
			<content:encoded><![CDATA[<p>My wife and I have wanted to work together on a project for a long time. It took as a while to figure out just what that project might be.  Well after many evenings of conversations over some great Cabernet's we came up with the idea of publishing some of her short stories she was working on as a hobby.</p>
<p>We thought the idea of publishing it in serial fashion in weekly installments was a rather "novel" idea. (Pun intended) A lot of the web based fiction or weblit seemed to be very scifi/fantasy/horror based.  My wife writes in closer to a chicklit or literature based style so we are trying to build a readership of people who may not be aware they can read fiction online. This will likely be the biggest problem for the website, attracting the kind of audience that would enjoy her fiction.  Therein lies my challenge, and so far it's one I've been enjoying.</p>
<p style="text-align: center;"><a href="http://secretloft.ca"><img class="aligncenter size-full wp-image-29" title="The Secret Loft" src="http://www.gavey.ca/wp-content/uploads/2010/03/sl-logo.png" alt="The Secret Loft" width="473" height="155" /></a></p>
<p>So please if you enjoy fiction or simply want to peek at what where up to.  Please check out <a href="http://secretloft.ca">The Secret Loft</a>.</p>
<p>I will be hopefully updating later on some of the marekting techniques, programming tricks another bits of information I glean from this project.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gavey.ca/blog/index.php/2010/03/19/new-side-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How not to buy a computer</title>
		<link>http://www.gavey.ca/blog/index.php/2009/04/17/how-not-to-buy-a-computer/</link>
		<comments>http://www.gavey.ca/blog/index.php/2009/04/17/how-not-to-buy-a-computer/#comments</comments>
		<pubDate>Sat, 18 Apr 2009 03:42:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[laptops]]></category>

		<guid isPermaLink="false">http://www.gavey.ca/?p=16</guid>
		<description><![CDATA[I'm not going to tell you what to buy, and I'm not going to tell you how to buy it.  But I am going to tell you where most people make some very bad decisions about computer purchases. Recently I was in the Market for a laptop.  My son is now 5 years old and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gavey.ca/wp-content/uploads/2009/04/2234160851_034e51725a.jpg"><img class="size-medium wp-image-20 alignleft" title="2234160851_034e51725a" src="http://www.gavey.ca/wp-content/uploads/2009/04/2234160851_034e51725a-300x199.jpg" alt="" width="300" height="199" /></a>I'm not going to tell you what to buy, and I'm not going to tell you how to buy it.  But I am going to tell you where most people make some very bad decisions about computer purchases.</p>
<p>Recently I was in the Market for a laptop.  My son is now 5 years old and he tends to be on the computer a fair bit.  My wife who had little experience with computers before I met her really enjoys her time on the computer now.  It was starting to become a bit of a conflict between them.  So I decided a laptop would probably be the best solution to the problem.<span id="more-16"></span></p>
<p>Now this is where many people go wrong.  They think they are going to use the computer for so much more than they really will.  I almost got caught in that trap.  The following is our situation.</p>
<p>I really wanted to buy a Dell Mini 9 and hack it to run OS X.  Now I had decided some time ago that the next computer I bought was going to run OS X.  Now the reason for this is 2 fold.</p>
<p>1.  I use OS X for work and it has a lot going for it.<br />
2.  I bought a car with a manual transmission for my wife early in our relationship for the same reason we purchased a laptop with OS X.  I wanted her to know how to drive it.</p>
<p>So with that in mind I started looking at the Dell Mini 9.  It's quite an impressive little netbook, decent processor, RAM, and so on.  I thought "this is perfect" I can hack a copy of OS X on it and then she will have a perfect little machine for her purposes.</p>
<p>Then I started to think about reality.  Well what is she going to do with this computer?  Well I thought, surf the Internet and practice her hobby of writing.  Well is the Mini 9 the best computer for this purpose?</p>
<p>After a lot of thought on the matter I decided that the Mini 9 had one major problem.  It's Size.  Why is this a problem? Netbooks are so small and portable, they are perfect.  Well that might be true for a student who needs to pack a computer around with them to class to take notes, but for our purposes, the typing on the laptop would have been too difficult.  The keyboard and screensize on a more full featured computer would definetly suit us beter.</p>
<p>And this is where beleive so many people go wrong with their computer purchases.  They are looking too much and the great next technology and little on how they are going to use the computer.  My father purchased a $400 compaq laptop a couple years ago and it's still perfect to his needs, all he has ever done is read his email and use ebay.ca.  Simple needs simple computer.</p>
<p>I have seen far too many people purchase the fastest video card and only play WoW.  I've seen people purchase a quad core desktop and never encode a video.  I've seen people with 1 TB harddrives and only surf the Internet.  Well, before you make your next decision to purchase your next computer take a minute to think about what are you really going to use it for.</p>
<p>A side note on our purchase.  I did end up purchasing a Macbook Air for my wife.  Now everyone calls them overpriced and under powered, which I would agree with.  But I ended up purchasing a refurbished last generation one from the Apple Store Canada for 1099.99 and it was in incredible shape.  Not one scratch, and hasn't had a hiccup since we first started it up.</p>
<p>My wife finds it easy to type on, long battery life and generally a great computer.  For her purposes it more than fits her needs. Perhaps I bought above her needs, but I would prefer a reliable machine over dealing with second rate technical support.  And the lack of ports on the machine is only a bonus, becuase she would never use them anyway.</p>
<p>Why purchase something just becuase you <strong>might</strong> use it.  Purchase based on your <strong>real</strong> needs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gavey.ca/blog/index.php/2009/04/17/how-not-to-buy-a-computer/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

