<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Further Thoughts on MySQL Upgrades</title>
	<atom:link href="http://blog.wl0.org/2010/01/further-thoughts-on-mysql-upgrades/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.wl0.org/2010/01/further-thoughts-on-mysql-upgrades/</link>
	<description>Random thoughts on different topics</description>
	<lastBuildDate>Fri, 27 Jan 2012 06:02:03 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
	<item>
		<title>By: Simon J Mudd</title>
		<link>http://blog.wl0.org/2010/01/further-thoughts-on-mysql-upgrades/comment-page-1/#comment-1804</link>
		<dc:creator>Simon J Mudd</dc:creator>
		<pubDate>Sat, 06 Mar 2010 15:27:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.wl0.org/2010/01/further-thoughts-on-mysql-upgrades/#comment-1804</guid>
		<description>After writing this article I got caught out precisely by the problems I had mentioned. In order to avoid writing 5.0 to 5.1 upgrade information to the binlogs, I had disabled them during the upgrade procedure. However, I had forgotten that the master (that had just been upgraded to 5.1 from 5.0) was also a slave and had forgotten to disable starting the slave thread. As such the replication thread started (collecting changes from the upstream master) and they were NOT written to the binlog and thus never reached the downstream slaves. I had to rebuild 30 slaves because of this mistake. Costly!

So below is my current check list of what to do when upgrading a master which is itself a slave, especially if the upgrade is a major version change.

&lt;strong&gt;Intermediate Master server upgrade procedure&lt;/strong&gt;

In the situation below the upstream master was running 5.0, the server being upgraded was being upgraded frmo 5.0 to 5.1, and the downstream slaves were already running 5.1.

&lt;strong&gt;Problems&lt;/strong&gt;

I replicate the mysql database to ensure grants are replicated.
When using rpms you can only have one a single MySQL rpm installed at once.
When performing an install or upgrade the MySQL rpm tries to reinitialise the &lt;code&gt;/var/lib/mysql&lt;/code&gt; based db.

The intermediate master has its binlogs enabled so these commands get written to the binlog and therefore picked up by any downstream slave. If it&#039;s already running the upgraded version of mysql these replication commands will fail.

&lt;strong&gt;Part&lt;/strong&gt; of the 5.0 to 5.1 upgrade process involves running the script &lt;code&gt;mysql_upgrade&lt;/code&gt; which checks all tables and updates those that need updating, though some may need to be done by hand. (These are mainly Innodb tables and &lt;code&gt;ALTER TABLE xxxxx ENGINE = InnoDB;&lt;/code&gt; is sufficient.  The script also makes changes to the &lt;code&gt;mysql&lt;/code&gt; database, as this is necessary for the major version upgrade. As we replicate the &lt;code&gt;mysql&lt;/code&gt; database these changes would also get written to the binlog.

So to avoid these &lt;em&gt;local upgrade&lt;/em&gt; statements being written to the binlog you must temporarily disable this on the master.

This can be done by commenting out the following entries which on the intermediate master are likely to be set.
&lt;code&gt;
log-bin=../log/binlog
log-slave-updates
&lt;/code&gt;

Additionally to prevent any clients connecting to the server during the upgrade process it is convenient to disable access to the server. This can be done by *enabling* the following option:

&lt;code&gt;
bind-address = 127.0.0.1
&lt;/code&gt;

Finally which is what I forgot, the intermediate master is itself a slave. To avoid the replication threads starting and processing changes from the upstream master which would NOT be written to the binlog during the upgrade, you must ensure the slave threads &lt;strong&gt;DO NOT START&lt;/strong&gt;. This is done with:

&lt;code&gt;
skip-slave-start
&lt;/code&gt;

So to actually do the upgrade perform the following steps:

* Note: This does not take into account any procedures that may be needed if you have stored procedures or triggers configured on the server. If you have these please consult the MySQL documentation and update this page accordingly.
* Adjust &lt;code&gt;/etc/my.cnf&lt;/code&gt; as indicated above.
* Stop MySQL with &lt;code&gt;/etc/init.d/mysql stop&lt;/code&gt;
* Remove the 5.0 rpms with rpm -e XXX
* Adjust for configuration for differences between 5.0 and 5.1 which currently means changing the line &lt;code&gt;log-slow-queries = ../log/slowlog&lt;/code&gt; to &lt;code&gt;slow_query_log_file = ../log/slowlog&lt;/code&gt; and adding the line &lt;code&gt;slow_query_log = ON&lt;/code&gt;. The 5.1 server will start even if you don&#039;t make this change.
* Install the 5.1 rpms with rpm -ivh ...
* Check that the server has started and that the replication threads are &lt;strong&gt;NOT&lt;/strong&gt; running.
* Run &lt;code&gt;mysql_upgrade --skip-write-binlog&lt;/code&gt; to perform the basic upgrade. Check the output, which is probably in &lt;code&gt;/var/log/mysqld.log&lt;/code&gt;.
* For those tables that &lt;code&gt;mysql_upgrade&lt;/code&gt; could not upgrade, probably InnoDB tables, do &lt;code&gt;ALTER TABLE xxxxx ENGINE=InnoDB;&lt;/code&gt;
* Your server should now be upgraded and the binlog should be untouched.
* Stop the server &lt;code&gt;/etc/init.d/mysql stop&lt;/code&gt;
* Restore the server&#039;s original configuration by:
** Adding back &lt;code&gt;log-bin=../log/binlog&lt;/code&gt;
** Adding back &lt;code&gt;log-slave-updates&lt;/code&gt; if necessary
** Removing &lt;code&gt;bind-address = 127.0.0.1&lt;/code&gt;
** Removing &lt;code&gt;skip-slave-start&lt;/code&gt;
* Restart the server with &lt;code&gt;/etc/init.d/mysql start&lt;/code&gt; and check it starts and replicates normally.

This is a relatively slow process, and while not difficult, is rather time consuming.</description>
		<content:encoded><![CDATA[<p>After writing this article I got caught out precisely by the problems I had mentioned. In order to avoid writing 5.0 to 5.1 upgrade information to the binlogs, I had disabled them during the upgrade procedure. However, I had forgotten that the master (that had just been upgraded to 5.1 from 5.0) was also a slave and had forgotten to disable starting the slave thread. As such the replication thread started (collecting changes from the upstream master) and they were NOT written to the binlog and thus never reached the downstream slaves. I had to rebuild 30 slaves because of this mistake. Costly!</p>
<p>So below is my current check list of what to do when upgrading a master which is itself a slave, especially if the upgrade is a major version change.</p>
<p><strong>Intermediate Master server upgrade procedure</strong></p>
<p>In the situation below the upstream master was running 5.0, the server being upgraded was being upgraded frmo 5.0 to 5.1, and the downstream slaves were already running 5.1.</p>
<p><strong>Problems</strong></p>
<p>I replicate the mysql database to ensure grants are replicated.<br />
When using rpms you can only have one a single MySQL rpm installed at once.<br />
When performing an install or upgrade the MySQL rpm tries to reinitialise the <code>/var/lib/mysql</code> based db.</p>
<p>The intermediate master has its binlogs enabled so these commands get written to the binlog and therefore picked up by any downstream slave. If it&#8217;s already running the upgraded version of mysql these replication commands will fail.</p>
<p><strong>Part</strong> of the 5.0 to 5.1 upgrade process involves running the script <code>mysql_upgrade</code> which checks all tables and updates those that need updating, though some may need to be done by hand. (These are mainly Innodb tables and <code>ALTER TABLE xxxxx ENGINE = InnoDB;</code> is sufficient.  The script also makes changes to the <code>mysql</code> database, as this is necessary for the major version upgrade. As we replicate the <code>mysql</code> database these changes would also get written to the binlog.</p>
<p>So to avoid these <em>local upgrade</em> statements being written to the binlog you must temporarily disable this on the master.</p>
<p>This can be done by commenting out the following entries which on the intermediate master are likely to be set.<br />
<code><br />
log-bin=../log/binlog<br />
log-slave-updates<br />
</code></p>
<p>Additionally to prevent any clients connecting to the server during the upgrade process it is convenient to disable access to the server. This can be done by *enabling* the following option:</p>
<p><code><br />
bind-address = 127.0.0.1<br />
</code></p>
<p>Finally which is what I forgot, the intermediate master is itself a slave. To avoid the replication threads starting and processing changes from the upstream master which would NOT be written to the binlog during the upgrade, you must ensure the slave threads <strong>DO NOT START</strong>. This is done with:</p>
<p><code><br />
skip-slave-start<br />
</code></p>
<p>So to actually do the upgrade perform the following steps:</p>
<p>* Note: This does not take into account any procedures that may be needed if you have stored procedures or triggers configured on the server. If you have these please consult the MySQL documentation and update this page accordingly.<br />
* Adjust <code>/etc/my.cnf</code> as indicated above.<br />
* Stop MySQL with <code>/etc/init.d/mysql stop</code><br />
* Remove the 5.0 rpms with rpm -e XXX<br />
* Adjust for configuration for differences between 5.0 and 5.1 which currently means changing the line <code>log-slow-queries = ../log/slowlog</code> to <code>slow_query_log_file = ../log/slowlog</code> and adding the line <code>slow_query_log = ON</code>. The 5.1 server will start even if you don&#8217;t make this change.<br />
* Install the 5.1 rpms with rpm -ivh &#8230;<br />
* Check that the server has started and that the replication threads are <strong>NOT</strong> running.<br />
* Run <code>mysql_upgrade --skip-write-binlog</code> to perform the basic upgrade. Check the output, which is probably in <code>/var/log/mysqld.log</code>.<br />
* For those tables that <code>mysql_upgrade</code> could not upgrade, probably InnoDB tables, do <code>ALTER TABLE xxxxx ENGINE=InnoDB;</code><br />
* Your server should now be upgraded and the binlog should be untouched.<br />
* Stop the server <code>/etc/init.d/mysql stop</code><br />
* Restore the server&#8217;s original configuration by:<br />
** Adding back <code>log-bin=../log/binlog</code><br />
** Adding back <code>log-slave-updates</code> if necessary<br />
** Removing <code>bind-address = 127.0.0.1</code><br />
** Removing <code>skip-slave-start</code><br />
* Restart the server with <code>/etc/init.d/mysql start</code> and check it starts and replicates normally.</p>
<p>This is a relatively slow process, and while not difficult, is rather time consuming.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Log Buffer #177: a Carnival of the Vanities for DBAs &#124; The Pythian Blog</title>
		<link>http://blog.wl0.org/2010/01/further-thoughts-on-mysql-upgrades/comment-page-1/#comment-1668</link>
		<dc:creator>Log Buffer #177: a Carnival of the Vanities for DBAs &#124; The Pythian Blog</dc:creator>
		<pubDate>Fri, 05 Feb 2010 18:24:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.wl0.org/2010/01/further-thoughts-on-mysql-upgrades/#comment-1668</guid>
		<description>[...] Simon Mudd has some further thoughts on mysql upgrades. [...]</description>
		<content:encoded><![CDATA[<p>[...] Simon Mudd has some further thoughts on mysql upgrades. [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

