<?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>code.openark.org &#187; Configuration</title>
	<atom:link href="http://code.openark.org/blog/tag/configuration/feed" rel="self" type="application/rss+xml" />
	<link>http://code.openark.org/blog</link>
	<description>Blog by Shlomi Noach</description>
	<lastBuildDate>Wed, 01 Feb 2012 08:19:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Useful sed / awk liners for MySQL</title>
		<link>http://code.openark.org/blog/mysql/useful-sed-awk-liners-for-mysql</link>
		<comments>http://code.openark.org/blog/mysql/useful-sed-awk-liners-for-mysql#comments</comments>
		<pubDate>Wed, 06 Jul 2011 06:41:00 +0000</pubDate>
		<dc:creator>shlomi</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[InnoDB]]></category>
		<category><![CDATA[mysqldump]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://code.openark.org/blog/?p=3685</guid>
		<description><![CDATA[Listing some useful sed / awk liners to use with MySQL. I use these on occasion. sed, awk &#38; grep have many overlapping features. Some simple tasks can be performed by either. For example, stripping empty lines can be performed by either: grep '.' awk '/./' sed '/./!d' grep -v '^$' awk '!/^$/' sed '/^$/d' [...]]]></description>
			<content:encoded><![CDATA[<p>Listing some useful <strong>sed</strong> / <strong>awk</strong> liners to use with MySQL. I use these on occasion.</p>
<p><strong>sed</strong>, <strong>awk</strong> &amp; <strong>grep</strong> have many overlapping features. Some simple tasks can be performed by either. For example, stripping empty lines can be performed by either:</p>
<blockquote>
<pre><strong>grep</strong> '.'
<strong>awk</strong> '/./'
<strong>sed</strong> '/./!d'
<strong>grep</strong> -v '^$'
<strong>awk</strong> '!/^$/'
<strong>sed</strong> '/^$/d'</pre>
</blockquote>
<p>It's a matter of taste &amp; convention which tool and variation to use. So for any script I suggest, there may be many variations, possibly cleaner, shorter; feel free to comment.</p>
<h4>mysqldump</h4>
<p>The output of <em>mysqldump</em> is in particular useful when one wishes to make transformation on data or metadata.<span id="more-3685"></span></p>
<ul>
<li>Convert MyISAM tables to InnoDB:</li>
</ul>
<blockquote>
<pre>mysqldump | sed -e 's/^) ENGINE=MyISAM/) ENGINE=InnoDB/'</pre>
</blockquote>
<p>I've had several occasion when people said this type of conversion assumes no <strong>'ENGINE=MyISAM'</strong> snippet exists within row data. This is not so. The <strong>'^) ENGINE=MyISAM/'</strong> pattern strictly requires that this text is outside row data. No row data begins with a <strong>')'</strong>. This is a safe conversion.</p>
<ul>
<li>Convert InnoDB to InnoDB plugin, compressed tables:</li>
</ul>
<blockquote>
<pre>mysqldump | sed -e 's/^) ENGINE=InnoDB/) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8/'</pre>
</blockquote>
<ul>
<li>Slice out a specific database (assumes existence of the <strong>USE</strong> statement):</li>
</ul>
<blockquote>
<pre>sed -n "/^USE \`employees\`/,/^USE \`/p"</pre>
</blockquote>
<ul>
<li>Slice out a specific table:</li>
</ul>
<blockquote>
<pre>sed -n "/^-- Table structure for table \`departments\`/,/^-- Table structure for table/p"</pre>
</blockquote>
<ul>
<li>Combine the above two statements to slice a specific table from a specific database:</li>
</ul>
<blockquote>
<pre>sed -n "/^USE \`employees\`/,/^USE \`/p" | sed -n "/^-- Table structure for table \`departments\`/,/^-- Table structure for table/p"</pre>
</blockquote>
<p>See also <a rel="bookmark" href="http://code.openark.org/blog/mysql/on-restoring-a-single-table-from-mysqldump">On restoring a single table from mysqldump</a>.</p>
<h4>my.cnf</h4>
<p>Some <em>my.cnf</em> files are just a mess to read. Here's some normalizing scripts:</p>
<ul>
<li>Strip a <em>my.cnf</em> file from comments, remove blank lines, normalize spaces:</li>
</ul>
<blockquote>
<pre>cat my.sandbox.cnf | sed '/^#/d' | sed '/^$/d' | sed -e 's/[ \t]\+//g'</pre>
</blockquote>
<ul>
<li>Same, but only present <strong>[mysqld]</strong> section parameters:</li>
</ul>
<blockquote>
<pre>cat my.sandbox.cnf | sed -n '/^\[mysqld\]/,/^\[/p' | sed '/^\[/d' | sed '/^#/d' | sed '/^$/d' | sed -e 's/[ \t]\+//g'</pre>
</blockquote>
<ul>
<li>Only present <strong>[mysqld]</strong> section parameters, tab delimited (this is useful in exporting and comparing instance parameters):</li>
</ul>
<blockquote>
<pre>cat my.sandbox.cnf | sed -n '/^\[mysqld\]/,/^\[/p' | sed '/^\[/d' | sed '/^#/d' | sed '/^$/d' | sed -e 's/[ \t]\+//g' | sed -e 's/=/\t/'</pre>
</blockquote>
<ul>
<li>Multi-word parameters in <em>my.cnf</em> can be written with either hyphens or underscores. <strong>innodb_file_per_</strong>table is the same as <strong>innodb-file-per-table</strong>, as well as <strong>innodb_file-per_table</strong>. The following normalizes the parameter names to using underscores only, keeping from changing values (e.g. <strong>'mysql-bin' </strong>parameter value should not change). It isn't pretty!</li>
</ul>
<blockquote>
<pre>cat my.sandbox.cnf | awk -F "=" 'NF &lt; 2 {print} sub("=", "=~placeholder~=") {print}' | awk -F "=~placeholder~=" 'NF &lt; 2 {gsub("-", "_", $0); print} NF==2 {gsub("-", "_", $1); print $1 "=" $2}'</pre>
</blockquote>
<div id="_mcePaste" class="mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;">grep "."<br />
awk '/./'<br />
sed '/./!d'<br />
grep -v '^$'<br />
awk '!/^$/'<br />
sed '/^$/d'</div>
]]></content:encoded>
			<wfw:commentRss>http://code.openark.org/blog/mysql/useful-sed-awk-liners-for-mysql/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Recovering a MySQL `root` password: the fourth solution</title>
		<link>http://code.openark.org/blog/mysql/recovering-a-mysql-root-password-the-fourth-solution</link>
		<comments>http://code.openark.org/blog/mysql/recovering-a-mysql-root-password-the-fourth-solution#comments</comments>
		<pubDate>Tue, 22 Mar 2011 07:47:46 +0000</pubDate>
		<dc:creator>shlomi</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Replication]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://code.openark.org/blog/?p=3412</guid>
		<description><![CDATA[Have just read Darren Cassar's Recovering a MySQL `root` password – Three solutions. There's a fourth solution: using an init-file, which leads to just one restart of the database instead of two. It also avoids the security issue involved with using skip-grant-tables. I've written all about it before on Dangers of skip-grant-tables. Darren's 1st advice [...]]]></description>
			<content:encoded><![CDATA[<p>Have just read Darren Cassar's <a title="Permanent Link to Recovering a MySQL `root` password – Three solutions" rel="bookmark" href="http://mysqlpreacher.com/wordpress/2011/03/recovering-a-mysql-root-password-three-solutions/">Recovering a MySQL `root` password – Three solutions</a>. There's a fourth solution: using an <strong>init-file</strong>, which leads to just one restart of the database instead of two. It also avoids the security issue involved with using <strong>skip-grant-tables</strong>.</p>
<p>I've written all about it before on <a title="Permanent Link to Dangers of skip-grant-tables" rel="bookmark" href="http://code.openark.org/blog/mysql/dangers-of-skip-grant-tables">Dangers of skip-grant-tables</a>.</p>
<p>Darren's 1st advice (look for password ini files, scripts, etc.) is a very good one. One password that can always be looked up in files is the replication's password.</p>
<p>Replication's password is easily forgotten: you only set it once and never use it again; never script it nor manually login with. When setting up new slaves, though, you suddenly need it.</p>
<p>Apparently not many realize that the replication password is written in plaintext in the <strong>master.info</strong> file. This file tells the slave all about it's master connection: host, port, user &amp; password are all there for you to read.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.openark.org/blog/mysql/recovering-a-mysql-root-password-the-fourth-solution/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Upgrading passwords from old_passwords to &quot;new passwords&quot;</title>
		<link>http://code.openark.org/blog/mysql/upgrading-passwords-from-old_passwords-to-new-passwords</link>
		<comments>http://code.openark.org/blog/mysql/upgrading-passwords-from-old_passwords-to-new-passwords#comments</comments>
		<pubDate>Mon, 28 Feb 2011 13:50:52 +0000</pubDate>
		<dc:creator>shlomi</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://code.openark.org/blog/?p=3297</guid>
		<description><![CDATA[You have old_passwords=1 in your my.cnf. I'm guessing this is because you used one of the my-small.cnf, my-large.cnf etc. templates provided with your MySQL distribution. These files can easily win the "most outdated sample configuration file contest". Usually it's no big deal: if some parameter isn't right, you just go and change it. Some variables, [...]]]></description>
			<content:encoded><![CDATA[<p>You have <strong>old_passwords=1</strong> in your <strong>my.cnf</strong>. I'm guessing this is because you used one of the <strong>my-small.cnf</strong>, <strong>my-large.cnf</strong> etc. templates provided with your MySQL distribution.</p>
<p>These files can easily win the "most outdated sample configuration file contest".</p>
<p>Usually it's no big deal: if some parameter isn't right, you just go and change it. Some variables, though, have a long-lasting effect, and are not easily reversed.</p>
<h4>What's the deal with old_passwords?</h4>
<p>No one should be using these anymore. This variable makes the password hashing algorithm compatible with that of MySQL <strong>4.0</strong>. I'm pretty sure <strong>4.0</strong> was released <strong>9</strong> years ago. I don't know of anyone still using it (or <strong>4.0</strong> client libraries).</p>
<p>The deal is this: with old_passwords you get a <strong>16</strong> hexadecimal digits (<strong>64</strong> bit) hashing of your passwords. With so called <em>"new passwords"</em> you get <strong>40</strong> hexadecimal digits (plus extra "<strong>*</strong>"). So this is about better encryption of your password. Read more on the <a href="http://dev.mysql.com/doc/refman/5.1/en/password-hashing.html">manual</a>.</p>
<h4>How do I upgrade to new password format?</h4>
<p>You can't just put a comment on the "<strong>old_passwords=1</strong>" entry in the configuration file. If you do so, the next client to connect will attempt to match a <strong>41</strong> characters hashed password to your existing <strong>16</strong> characters entry in the <strong>mysql.users</strong> table. So you need to make a simultaneous change: both remove the <strong>old_passwords</strong> entry and set a new password. You must know all accounts' passwords before you begin.</p>
<p><span id="more-3297"></span>Interestingly, <strong>old_passwords</strong> is both a global and a session variable. To work out an example, let's assume the account <strong>'webuser'@'localhost'</strong> enters with '123456'. Take a look at the following:</p>
<blockquote>
<pre>root@mysql-5.1.51&gt; SET SESSION old_passwords=0;
Query OK, 0 rows affected (0.00 sec)

root@mysql-5.1.51&gt; SELECT PASSWORD('123456');
+-------------------------------------------+
| PASSWORD('123456')                        |
+-------------------------------------------+
| *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+-------------------------------------------+
1 row in set (0.00 sec)

root@mysql-5.1.51&gt; SET SESSION old_passwords=1;
Query OK, 0 rows affected (0.00 sec)

root@mysql-5.1.51&gt; SELECT PASSWORD('123456');
+--------------------+
| PASSWORD('123456') |
+--------------------+
| 565491d704013245   |
+--------------------+
1 row in set (0.00 sec</pre>
</blockquote>
<p>So, the <strong>PASSWORD()</strong> function consults the <strong>old_passwords</strong> session variable.</p>
<p>To upgrade <strong>'webuser'@'localhost'</strong>'s password we do:</p>
<blockquote>
<pre>root@mysql-5.1.51&gt; SET SESSION old_passwords=0;
Query OK, 0 rows affected (0.00 sec)

root@mysql-5.1.51&gt; SET PASSWORD FOR 'webuser'@'localhost' = PASSWORD('123456')</pre>
</blockquote>
<p>Go ahead and see the <strong>password</strong> entry on the <strong>mysql.users</strong> table.</p>
<p>What we've just done is to set a <strong>41</strong> characters password hash for that account. Now, the next time the client wishes to connect, it must know in advance it is to expect a new password, otherwise it will encode a <strong>16</strong> characters hash, and try to match it with our new <strong>41</strong> characters hash. It is now time to perform:</p>
<blockquote>
<pre>root@mysql-5.1.51&gt; SET GLOBAL old_passwords=0;
Query OK, 0 rows affected (0.00 sec</pre>
</blockquote>
<p>This will apply to all new connections made from that moment on (not affecting any existing connections). So, make sure you have updated passwords for all accounts.</p>
<p>To wrap it up, don't forget to set <strong>old_passwords=0</strong> in the <strong>my.cnf</strong> file, or, better yet, completely remove the entry.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.openark.org/blog/mysql/upgrading-passwords-from-old_passwords-to-new-passwords/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Upgrading to Barracuda &amp; getting rid of huge ibdata1 file</title>
		<link>http://code.openark.org/blog/mysql/upgrading-to-barracuda-getting-rid-of-huge-ibdata1-file</link>
		<comments>http://code.openark.org/blog/mysql/upgrading-to-barracuda-getting-rid-of-huge-ibdata1-file#comments</comments>
		<pubDate>Tue, 15 Feb 2011 08:01:15 +0000</pubDate>
		<dc:creator>shlomi</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[InnoDB]]></category>
		<category><![CDATA[mysqldump]]></category>
		<category><![CDATA[Replication]]></category>

		<guid isPermaLink="false">http://code.openark.org/blog/?p=3304</guid>
		<description><![CDATA[Some of this is old stuff, but more people are now converting to InnoDB plugin, so as to enjoy table compression, performance boosts. Same holds for people converting to Percona's XtraDB. InnoDB plugin requires innodb_file_per_table. No more shared tablespace file. So your ibdata1 file is some 150GB, and it won't reduce. Really, it won't reduce. [...]]]></description>
			<content:encoded><![CDATA[<p>Some of this is old stuff, but more people are now converting to InnoDB plugin, so as to enjoy table compression, performance boosts. Same holds for people converting to Percona's XtraDB. InnoDB plugin requires <strong>innodb_file_per_table</strong>. No more shared tablespace file.</p>
<p>So your <strong>ibdata1</strong> file is some <strong>150GB</strong>, and it won't reduce. Really, it won't reduce. You set <strong>innodb_file_per_table=1</strong>, do <strong>ALTER TABLE t ENGINE=InnoDB</strong> (optionally <strong>ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8</strong>), and you get all your tables in file-per-table <strong>.ibd</strong> files.</p>
<p>But the original <strong>ibdata1</strong> file is still there. It has to be there, don't delete it! It contains more than your old data.</p>
<p>InnoDB tablespace files never reduce in size, it's an old-time annoyance. The only way to go round it, if you need the space, is to completely drop them and start afresh. That's one of the things so nice about file-per-table: an <strong>ALTER TABLE</strong> actually creates a new tablespace file and drops the original one.</p>
<h4>The procedure</h4>
<p>The procedure is somewhat painful:</p>
<ul>
<li>Dump everything logically (either use <em>mysqldump</em>, <a href="http://www.maatkit.org/doc/mk-parallel-dump.html">mk-parallel-dump</a>, or do it your own way)</li>
<li>Erase your data (literally, delete everything under your <strong>datadir</strong>)</li>
<li>Generate a new empty database</li>
<li>Load your dumped data.<span id="more-3304"></span></li>
</ul>
<h4>Using replication</h4>
<p>Replication makes this less painful. Set up a slave, have it follow up on the master.</p>
<ul>
<li>Stop your slave.</li>
<li>Make sure to backup the replication position (e.g. write <strong>SHOW SLAVE STATUS</strong> on a safe location, or copy <strong>master.info</strong> file).</li>
<li>Work out the dump-erase-generate-load steps on the slave.</li>
<li>Reattach the slave to the master using saved data.</li>
</ul>
<p>For this to succeed you must keep enough binary logs on the master for the entire dump-load period, which could be lengthy.</p>
<h4>Upgrading to barracuda</h4>
<p>If you wish to upgrade your InnoDB tables to <em>Barracuda</em> format, my advice is this:</p>
<ol>
<li>Follow the steps above to generate a file-per-table working slave</li>
<li>Stop the slave</li>
<li>Configure <strong>skip_slave_start</strong></li>
<li>Restart MySQL</li>
<li>One by one do the <strong>ALTER TABLE</strong> into <em>Barracuda</em> format (<strong>ROW_FORMAT=COMPACT</strong> or <strong>ROW_FORMAT=COMPRESSED</strong>)</li>
</ol>
<p>Note that if you're about to do table compression, the <strong>ALTER</strong> statements become <em>considerably</em> slower the better the compression is.</p>
<p>If your dataset is very large, and you can't keep so many binary logs, you may wish to break step <strong>5</strong> above into:</p>
<ul>
<li>ALTER a large table</li>
<li>Restart MySQL</li>
<li>Start slave, wait for it to catch up</li>
<li>Restart MySQL again</li>
</ul>
<p>and do the same for all large tables.</p>
<h4>Why all these restarts?</h4>
<p>I've been upgrading to Barracuda for a long time now. I have clearly noticed that <strong>ALTER</strong> into a <strong>COMPRESSED</strong> format works considerably slower after the slave has done some "real work". This in particular relates to the last "renaming table" stage. There was a bug with earlier InnoDB plugin versions which made this stage hang. It was solved. But it still takes some time for this last, weird stage, where the new replacement table is complete, and it's actually been renamed in place of the old table, and the old table renamed into something like "#sql-12345.ibd", and all that needs to be done is have it dropped, and... Well, it takes time.</p>
<p>My observation is it works faster on a freshly started server. Which is why I take the bother to restart MySQL before each large table conversion.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.openark.org/blog/mysql/upgrading-to-barracuda-getting-rid-of-huge-ibdata1-file/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Where&#039;s my cnf file?</title>
		<link>http://code.openark.org/blog/mysql/wheres-my-cnf-file</link>
		<comments>http://code.openark.org/blog/mysql/wheres-my-cnf-file#comments</comments>
		<pubDate>Tue, 07 Dec 2010 10:24:44 +0000</pubDate>
		<dc:creator>shlomi</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://code.openark.org/blog/?p=2981</guid>
		<description><![CDATA[So you have a running MySQL server, it's working well and everyone's happy. You want to make a minor change to the configuration file, so you edit the file, restart MySQL - but the change doesn't catch! Or maybe you want to check that some global variable has not been dynamically changed without an update [...]]]></description>
			<content:encoded><![CDATA[<p>So you have a running MySQL server, it's working well and everyone's happy. You want to make a minor change to the configuration file, so you edit the file, restart MySQL - but the change doesn't catch!</p>
<p>Or maybe you want to check that some global variable has not been dynamically changed without an update to the configuration file. But the configuration file doesn't make any sense -- it looks like nothing is common between the file and the server.</p>
<p>Wait, which <strong>my.cnf</strong> file does MySQL read? Rather, which <strong>my.cnf</strong> <em>files</em>?</p>
<p>Ever happened to you? If you're well organized, and only keep a single <strong>/etc/my.cnf</strong> file, you know exactly where everything is. But some systems are messier, with <em>lots</em> of configuration files hanging around. Which ones apply?</p>
<p>Let's find out which configuration files apply.</p>
<h4>No direct information</h4>
<p>It would all be easier if we could just <strong>SHOW GLOBAL VARIABLES LIKE 'configuration_files_that_this_server_has_read_list'</strong>. There isn't such an option.</p>
<p><span id="more-2981"></span>The MySQL documentation <a href="http://dev.mysql.com/doc/refman/5.1/en/option-files.html">explains</a> about the configuration files search path, and that's one path you can follow. Also, you can detect another estimated search path by invoking:</p>
<blockquote>
<pre><strong>root@myhost:~# mysqld --verbose --help | head -n 20
</strong>100927 19:53:06 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

mysqld  Ver 5.1.41 for unknown-linux-gnu on x86_64 (MySQL Community Server (GPL))
Copyright (C) 2000-2008 MySQL AB, by Monty and others
Copyright (C) 2008 Sun Microsystems, Inc.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Starts the MySQL database server

Usage: mysqld [OPTIONS]

Default options are read from the following files in the given order:
<strong>/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf</strong>
The following groups are read: mysqld server mysqld-5.1
The following options may be given as the first argument:
...</pre>
</blockquote>
<p>Easy enough, right? Just walk through that search path and you've covered it all. Better yet, see which of these even exist!</p>
<blockquote>
<pre><strong>root@myhost:~# ls -l /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf</strong>
ls: cannot access /etc/my.cnf: No such file or directory
ls: cannot access /etc/mysql/my.cnf: No such file or directory
ls: cannot access /usr/local/mysql/etc/my.cnf: No such file or directory
-rw-r--r-- 1 shlomi shlomi 32 2010-03-03 15:21 <strong>/home/shlomi/.my.cnf</strong></pre>
</blockquote>
<p>Seems like we got it. The <strong>mysqld</strong> process only reads <strong>/home/shlomi/.my.cnf</strong>. Right?</p>
<h4>Wrong!</h4>
<p>There are two running instances of MySQL running on my machine. Neither of the primary <strong>my.cnf</strong> files used by these instances is listed above.</p>
<blockquote>
<pre><strong>root@myhost:~# ps aux | grep mysqld
</strong>shlomi   12092  0.0  0.0   4096   352 pts/1    S    Sep26   0:00 /bin/sh /home/shlomi/sandboxes/5.1/5.1.50/bin/mysqld_safe <strong>--defaults-file=/home/shlomi/sandboxes/msb_5_1_50/my.sandbox.cnf</strong>
shlomi   12167  0.0 14.5 765520 587924 pts/1   Sl   Sep26   1:12 /home/shlomi/sandboxes/5.1/5.1.50/bin/mysqld <strong>--defaults-file=/home/shlomi/sandboxes/msb_5_1_50/my.sandbox.cnf</strong> --basedir=/home/shlomi/sandboxes/5.1/5.1.50 --datadir=/home/shlomi/sandboxes/msb_5_1_50/data --log-error=/home/shlomi/sandboxes/msb_5_1_50/data/msandbox.err --pid-file=/home/shlomi/sandboxes/msb_5_1_50/data/mysql_sandbox5150.pid --socket=/tmp/mysql_sandbox5150.sock --port=5150
root     22827  0.0  0.0   4096   668 pts/3    S    16:50   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/eeyore.pid
mysql    22960  0.1  2.2 274584 90188 pts/3    Sl   16:50   0:18 /usr/local/mysql/bin/mysqld <strong>--defaults-extra-file=/usr/local/mysql/data/my.cnf</strong> --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --log-error=/usr/local/mysql/data/eeyore.err --pid-file=/usr/local/mysql/data/eeyore.pid --socket=/tmp/mysql.sock --port=3306</pre>
</blockquote>
<p>Can you see the mess above?</p>
<p>The first two lines refer to a MySQL instance running under <a href="http://mysqlsandbox.net/">mysqlsandbox</a>. The <em>mysqld_safe</em> script is passed the defaults-file parameter, and passes it on to the <em>mysqld</em> service.</p>
<p>However the next couple of lines refer to a MySQL server installed as a service; installed from a binary tarball, this instance reads configuration from the <strong>datadir</strong>. This time the <em>mysqld_safe</em> instance is passed nothing, but invokes <em>mysqld</em> with <strong>default-extra-file</strong>.</p>
<p>To be fair, I wasn't expecting the <strong>"mysqld --verbose --help"</strong> invocation to find the <em>mysqlsandbox</em> configuration files. I did expect it to find the <strong>/usr/local/mysql/data/my.cnf</strong> file which it eventually used.</p>
<p>That's nice &amp; ugly. I can see the <strong>my.cnf</strong> file used by peeking at <em>ps</em>. A bit overkill.</p>
<h4>Not quite there yet...</h4>
<p>Because there's still my private configuration file (resides on <strong>/home/shlomi/.my.cnf</strong> on my account). Now I do not expect this file to be read by my standard MySQL server, since it does not run as user "shlomi". However my command line clients do actually read this file, and so I am affected by its settings.</p>
<p>I can verify whether such files have been used on a file system which is configured to support the <strong>atime</strong> option:</p>
<blockquote>
<pre><strong>root@myhost:~# ls -lt --time=atime $(locate *my.cnf)
</strong></pre>
</blockquote>
<p>I usually keep the <strong>atime</strong> option enabled for my <em>"/"</em> and <em>"/home"</em> partitions, but disable it on data partitions.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.openark.org/blog/mysql/wheres-my-cnf-file/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MySQL terminology: processes, threads &amp; connections</title>
		<link>http://code.openark.org/blog/mysql/mysql-terminology-processes-threads-connections</link>
		<comments>http://code.openark.org/blog/mysql/mysql-terminology-processes-threads-connections#comments</comments>
		<pubDate>Wed, 03 Nov 2010 06:38:03 +0000</pubDate>
		<dc:creator>shlomi</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Syntax]]></category>

		<guid isPermaLink="false">http://code.openark.org/blog/?p=2465</guid>
		<description><![CDATA[There's some confusion in the MySQL terminology for processes, threads &#38; connections, which I will try to resolve. I can't explain the full nature of what processes and threads are; please see Wikipedia [1] [2] for that. But here's some basics with regard to MySQL: MySQL server is a single process application. It is multithreaded. [...]]]></description>
			<content:encoded><![CDATA[<p>There's some confusion in the MySQL terminology for processes, threads &amp; connections, which I will try to resolve. I can't explain the full nature of what processes and threads are; please see Wikipedia <a href="http://en.wikipedia.org/wiki/Process_%28computing%29">[1]</a> <a href="http://en.wikipedia.org/wiki/Thread_%28computer_science%29">[2]</a> for that. But here's some basics with regard to MySQL:</p>
<ul>
<li>MySQL server is a single process application.</li>
<li>It is multithreaded.</li>
<li>It (usually) acts as a TCP/IP server, accepting connections.</li>
<li>Each connection gets a dedicated thread.</li>
<li>These threads are sometimes named processes, and sometimes they're referred to as connections.</li>
</ul>
<p>The last part is where confusion arises, so let me discuss again the use of threads and connections in MySQL.</p>
<p><span id="more-2465"></span>MySQL truly is a single process server. It is multi threaded, in that there are many obvious and less obvious threads comprising the server. Such threads are the InnoDB I/O threads, the DELAYED INSERT thread, etc. Oh, and of course: the connection threads. More on this in a short while.</p>
<p>On older Linux versions or on glibc-static versions, one may view MySQL as a multi-process server. This is not so: it is merely because threads are mapped to OS processes. For the sake of this discussion this is irrelevant. mysqld is a single process.</p>
<p>So, every new connection gets its own thread. Assuming no thread pool is in use, every new connection makes for the creation of a new thread, and a disconnect causes for that thread's destruction. Hence, there is a 1-1 mapping between connections and active threads. But then, there <em>is</em> a thread pool, which means there can be threads which are not associated with any connection. So, the number of threads is greater than or equal to the number of connections.</p>
<p>Here's where terminology gets confusing. When you want to see what's executing on the server, you issue <strong>SHOW PROCESSLIST</strong>:</p>
<blockquote>
<pre>mysql&gt; SHOW PROCESSLIST\G
*************************** 1. row ***************************
     Id: 4
   User: root
   Host: localhost
     db: mycheckpoint
Command: Query
   Time: 0
  State: NULL
   Info: SHOW PROCESSLIST
1 row in set (0.02 sec)</pre>
</blockquote>
<p>Perhaps this should have been called SHOW THREADLIST; the acting queries are not really processes.</p>
<p>OK, so there's process #4 which is executing a query. What's <em>my</em> process id? Turns out I don't have a process id. I do get to have a <strong>CONNECTION_ID()</strong>:</p>
<blockquote>
<pre>mysql&gt; SELECT CONNECTION_ID();
+-----------------+
| CONNECTION_ID() |
+-----------------+
|               4 |
+-----------------+</pre>
</blockquote>
<p>So how many processes or connections are now actually doing anything? We now must check for <strong>'Threads_running'</strong>.</p>
<blockquote>
<pre>mysql&gt; SHOW GLOBAL STATUS LIKE 'Threads_running';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| Threads_running | 1     |
+-----------------+-------+</pre>
</blockquote>
<p>And so we have <strong>'Threads_cached'</strong>, <strong>'Threads_connected'</strong> &amp; <strong>'Max_used_connections'</strong>.</p>
<p>Confusing?</p>
<p>Most of the time one can simply think of processes, threads and connections as 1-1-1 mapped, and not bother with it.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.openark.org/blog/mysql/mysql-terminology-processes-threads-connections/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MMM for MySQL single reader role</title>
		<link>http://code.openark.org/blog/mysql/mmm-for-mysql-single-reader-role</link>
		<comments>http://code.openark.org/blog/mysql/mmm-for-mysql-single-reader-role#comments</comments>
		<pubDate>Thu, 12 Aug 2010 12:12:16 +0000</pubDate>
		<dc:creator>shlomi</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[High availability]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Replication]]></category>

		<guid isPermaLink="false">http://code.openark.org/blog/?p=2824</guid>
		<description><![CDATA[The standard documentation and tutorials on MMM for MySQL, for master-master replication setup, suggest one Virtual IP for the writer role, and two Virtual IPs for the reader role. It can be desired to only have a single virtual IP for the reader role, as explained below. The two IPs for the reader role A [...]]]></description>
			<content:encoded><![CDATA[<p>The standard documentation and tutorials on <a href="http://mysql-mmm.org/">MMM for MySQL</a>, for master-master replication setup, suggest one Virtual IP for the <em>writer</em> role, and two Virtual IPs for the <em>reader</em> role. It can be desired to only have a single virtual IP for the reader role, as explained below.</p>
<h4>The two IPs for the reader role</h4>
<p>A simplified excerpt from the <strong>mmm_common.conf</strong> sample configuration file, as can be found on the project's site and which is most quoted:<span id="more-2824"></span></p>
<blockquote>
<pre>...
&lt;host db1&gt;
  ip                      192.168.0.11
  mode                    master
  peer                    db2
&lt;/host&gt;

&lt;host db2&gt;
  ip                      192.168.0.12
  mode                    master
  peer                    db1
&lt;/host&gt;
...
&lt;role writer&gt;
  hosts                   db1, db2
  ips                     192.168.0.100
  mode                    exclusive
&lt;/role&gt;

&lt;role reader&gt;
  hosts                   db1, db2
  ips                     192.168.0.101, 192.168.0.102
  mode                    balanced
&lt;/role&gt;
</pre>
</blockquote>
<p>In the above setup <strong>db1</strong> &amp; <strong>db2</strong> participate in master-master active-passive replication. Whenever you need to write something, you use <strong>192.18.0.100</strong>, which is the virtual IP for the writer role. Whenever you need to read something, you use either <strong>192.168.0.101</strong> or <strong>192.168.0.102</strong>, which are the virtual IPs of the two machines, this time in read role. Logic says one wishes to distribute reads between the two machines.</p>
<h4>One IP for reader role</h4>
<p>I have a few cases where the above setup is not satisfactory: there is a requirement to know the IP of the passive (read-only) master. Reason? There are queries which we only want to execute on the slave (reporting, long analysis), and only execute on the active master when this isn't possible. Sometimes we might even prefer waiting for a slave to come back up rather than execute a query on the master.</p>
<p>This may involve an application level solution, or a connection-pool level solution ("get me a slave's connection, or, if that's not possible, get me the master's").</p>
<p>Anyway, neither <strong>192.168.0.101</strong> nor <strong>192.168.0.102</strong> relate to a particular machine's role status. That is, the fact that one of the machines is in <em>writer</em> mode or not does not affect these virtual IPs.</p>
<p>The solution is a minor change to the configuration file. Real minor:</p>
<blockquote>
<pre>&lt;role reader&gt;
  hosts                   db1, db2
  ips                     192.168.0.101
  mode                    balanced
&lt;/role&gt;
</pre>
</blockquote>
<p>In this new setup the two nodes compete for a single <em>reader</em> role virtual IP. There is no <strong>192.168.0.102</strong> anymore. Although it does not reflect from the configuration file, it turns out MMM acts in a smart way; the way you would expect it to run.</p>
<p>There is nothing to suggest in the above that the IPs <strong>192.168.0.100</strong> &amp; <strong>192.168.0.101</strong> will be distributed between the two machines. But you would <em>like</em> them to. And MMM does that. It makes sure that, if possible, one of the machines (say <strong>db1</strong>) gets the <em>writer</em> role, hence <strong>192.168.0.100</strong>, and the other (<strong>db2</strong>) the <em>reader</em> role, hence <strong>192.168.0.101</strong>.</p>
<p>Moreover, it prefers that situation over a current known situation: say <strong>db1</strong> went down. The <em>writer</em> role moves to <strong>db2</strong>. When <strong>db1</strong> is up again, MMM acts smartly: it does <em>not</em> give it back the <em>writer</em> role (since moving the active master around is costly, after all), but <em>does</em> give it the <em>reader</em> role, along with the <strong>192.168.2.101</strong> IP. So it takes care not to leave a server without a role, while preferring to move the <em>writer</em> role as little as possible.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.openark.org/blog/mysql/mmm-for-mysql-single-reader-role/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Verifying GROUP_CONCAT limit without using variables</title>
		<link>http://code.openark.org/blog/mysql/verifying-group_concat-limit-without-using-variables</link>
		<comments>http://code.openark.org/blog/mysql/verifying-group_concat-limit-without-using-variables#comments</comments>
		<pubDate>Thu, 10 Jun 2010 07:16:14 +0000</pubDate>
		<dc:creator>shlomi</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[INFORMATION_SCHEMA]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://code.openark.org/blog/?p=2534</guid>
		<description><![CDATA[I have a case where I must know if group_concat_max_len is at its default value (1024), which means there are some operation I cannot work out. I've ranted on this here. Normally, I would simply: However, I am using views, where session variables are not allowed. Using a stored function can do the trick, but [...]]]></description>
			<content:encoded><![CDATA[<p>I have a case where I must know if <strong>group_concat_max_len</strong> is at its default value (<strong>1024</strong>), which means there are some operation I cannot work out. I've ranted on this <a href="http://code.openark.org/blog/mysql/those-oversized-undersized-variables-defaults">here</a>.</p>
<p>Normally, I would simply:</p>
<blockquote><pre class="brush: sql; title: ; notranslate">
SELECT @@group_concat_max_len
</pre>
</blockquote>
<p>However, I am using views, where session variables are not allowed. Using a stored function can <a href="http://code.openark.org/blog/mysql/views-better-performance-with-condition-pushdown">do the trick</a>, but I wanted to avoid stored routines. So here's a very simple test case: is the current <strong>group_concat_max_len</strong> long enough or not? I'll present the long version and the short version.</p>
<h4>The long version</h4>
<blockquote><pre class="brush: sql; title: ; notranslate">
SELECT
  CHAR_LENGTH(
    GROUP_CONCAT(
      COLLATION_NAME SEPARATOR ''
    )
  )
FROM
  INFORMATION_SCHEMA.COLLATIONS;
</pre>
</blockquote>
<p>If the result is <strong>1024</strong>, we are in a bad shape. I happen to know that the total length of collation names is above <strong>1800</strong>, and so it is trimmed down. Another variance of the above query would be:<span id="more-2534"></span></p>
<blockquote><pre class="brush: sql; title: ; notranslate">
SELECT
  CHAR_LENGTH(
    GROUP_CONCAT(
      COLLATION_NAME SEPARATOR ''
    )
  ) = SUM(CHAR_LENGTH(COLLATION_NAME))
    AS group_concat_max_len_is_long_enough
FROM
  INFORMATION_SCHEMA.COLLATIONS;

+-------------------------------------+
| group_concat_max_len_is_long_enough |
+-------------------------------------+
|                                   0 |
+-------------------------------------+
</pre>
</blockquote>
<p>The <strong>COLLATIONS</strong>, <strong>CHARACTER_SETS</strong> or <strong>COLLATION_CHARACTER_SET_APPLICABILITY</strong> tables provide with known to exist variables (assuming you did not compile MySQL with particular charsets). It's possible to <strong>CONCAT</strong>, <strong>UNION</strong> or <strong>JOIN</strong> columns and tables to detect longer than <strong>1800</strong> characters in <strong>group_concat_max_len</strong>. I admit this is becoming ugly, so let's move on.</p>
<h4>The short version</h4>
<p>Don't want to rely on existing tables? Not sure what values to expect? Look at this:</p>
<blockquote><pre class="brush: sql; title: ; notranslate">
SELECT CHAR_LENGTH(GROUP_CONCAT(REPEAT('0', 1025))) FROM DUAL
</pre>
</blockquote>
<p><strong>GROUP_CONCAT</strong> doesn't really care about the number of rows. In the above example, I'm using a single row (retrieved from the <strong>DUAL</strong> virtual table), making sure it is long enough. Type in any number in place of <strong>1025</strong>, and you have a metric for your <strong>group_concat_max_len</strong>.</p>
<blockquote><pre class="brush: sql; title: ; notranslate">
SELECT
  CHAR_LENGTH(GROUP_CONCAT(REPEAT('0', 32768))) &gt;= 32768 As group_concat_max_len_is_long_enough
FROM
  DUAL;
+-------------------------------------+
| group_concat_max_len_is_long_enough |
+-------------------------------------+
|                                   0 |
+-------------------------------------+
</pre>
</blockquote>
<p>The above makes a computation with <strong>REPEAT</strong>. One can replace this with a big constant.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.openark.org/blog/mysql/verifying-group_concat-limit-without-using-variables/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Those oversized, undersized variables defaults</title>
		<link>http://code.openark.org/blog/mysql/those-oversized-undersized-variables-defaults</link>
		<comments>http://code.openark.org/blog/mysql/those-oversized-undersized-variables-defaults#comments</comments>
		<pubDate>Wed, 09 Jun 2010 04:35:08 +0000</pubDate>
		<dc:creator>shlomi</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[sql_mode]]></category>

		<guid isPermaLink="false">http://code.openark.org/blog/?p=1997</guid>
		<description><![CDATA[Some mysqld parameters are far from having reasonable defaults. Most notable are the engine-specific values, and in particular the InnoDB parameters. Some of these variables have different defaults as of MySQL 5.4. innodb_buffer_pool_size, for example, is 128M on 5.4. innodb_log_file_size, however, has changed back and forth, as far as I understand, and is down to [...]]]></description>
			<content:encoded><![CDATA[<p>Some <strong>mysqld</strong> parameters are far from having reasonable defaults. Most notable are the engine-specific values, and in particular the InnoDB parameters.</p>
<p>Some of these variables have different defaults as of MySQL 5.4. <strong>innodb_buffer_pool_size</strong>, for example, is <strong>128M</strong> on 5.4. <strong>innodb_log_file_size</strong>, however, has changed back and forth, as far as I understand, and is down to <strong>5M</strong> again. These settings are still the same on 5.5.</p>
<p>I wish to present some not-so-obvious parameters which, in my opinion, have poor defaults, for reasons I will explain.</p>
<ul>
<li><strong>group_concat_max_len</strong>: This parameter limits the maximum text length of a <strong>GROUP_CONCAT</strong> concatenation result. It defaults to <strong>1024</strong>. I think this is a very low value. I have been using <strong>GROUP_CONCAT</strong> more and more, recently, to solve otherwise difficult problems. And in most cases, <strong>1024</strong> was just too low, resulting in <a href="http://code.openark.org/blog/mysql/but-i-do-want-mysql-to-say-error">silent</a> (<em>Argh!</em>) truncating of the result, thus returning incorrect results. It is interesting to learn that the maximum value for this parameter is limited by <strong>max_packet_size</strong>. I would suggest, then, that this parameter should be altogether removed, and have the <strong>max_packet_size</strong> limitation as the only limitation. Otherwise, I'd like it to have a very large default value, in the order of a few MB.</li>
<li><strong>wait_timeout</strong>: Here's a parameter whose default value is over permissive. <strong>wait_timeout</strong> enjoys an <strong>8 hour</strong> default. I usually go for <strong>5-10 minutes</strong>. I don't see a point in letting idle connections waste resources for 8 hours. Applications which hold up such connections should be aware that they're doing something wrong, in the form of a forced disconnection. Connection pools work beautifully with low settings, and can themselves do keepalives, if they choose to.</li>
<li><strong>sql_mode</strong>: I've <a href="http://code.openark.org/blog/mysql/do-we-need-sql_mode">discussed this</a> in length before. My opinion unchanged.</li>
<li><strong>open_files_limit</strong>: What with the fact connections, threads, table descriptors, table file descriptors (depending on how you use InnoDB), temporary file tables -- all are files on unix-like systems, and considering this is an inexpensive payment, I think <strong>open_files_limit</strong> should default to a few thousands. Why risk the crash of "too many open files"?</li>
</ul>
<p><span id="more-1997"></span>No setting will ever be perfect for everyone, I know. But there are those parameters which you automatically set values for when you do a new install. These should be at focus and their defaults change.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.openark.org/blog/mysql/those-oversized-undersized-variables-defaults/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Replication configuration checklist</title>
		<link>http://code.openark.org/blog/mysql/replication-configuration-checklist</link>
		<comments>http://code.openark.org/blog/mysql/replication-configuration-checklist#comments</comments>
		<pubDate>Tue, 18 May 2010 07:27:06 +0000</pubDate>
		<dc:creator>shlomi</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Replication]]></category>

		<guid isPermaLink="false">http://code.openark.org/blog/?p=2357</guid>
		<description><![CDATA[This post lists the essential and optional settings for a replication environment. It does not explain how to create replicating slaves. See How To Setup Replication for that. However, not all configuration options are well understood, and their roles in varying architectures can change. Here are the settings for a basic Master/Slave(s) replication architecturee. Essential [...]]]></description>
			<content:encoded><![CDATA[<p>This post lists the essential and optional settings for a replication environment.</p>
<p>It does not explain how to create replicating slaves. See <a href="http://dev.mysql.com/doc/refman/5.1/en/replication-howto.html">How To Setup Replication</a> for that. However, not all configuration options are well understood, and their roles in varying architectures can change.</p>
<p>Here are the settings for a basic Master/Slave(s) replication architecturee.</p>
<h4>Essential</h4>
<ul>
<li><strong>log-bin</strong>: enable binary logs on the master. Replication is based on the master logging all modifying queries (<strong>INSERT</strong>/<strong>CREATE</strong>/<strong>ALTER</strong>/<strong>GRANT</strong> etc.), and the slaves being able to replicate them.</li>
<li><strong>server-id</strong>: each machine must have a <em>unique</em> <strong>server-id</strong>. A slave will not replay queries originating from a server with the same <strong>server-id</strong> as its own.</li>
<li><strong>GRANT</strong>: grant a user with <strong>REPLICATION SLAVE</strong>. The host list must include all replication slave hosts.</li>
<li><strong>expire-logs-days</strong>: automatically clean up master's binary logs older than given value. By default, binary logs are never removed.</li>
</ul>
<p>When working with Master/Slaves replication, one should be prepared to master failure and slave promotion to master. It may be desirable to identify a particular slave as primary candidate for promotion.</p>
<p><span id="more-2357"></span>Just setting up the <strong>log-bin</strong> will yield with warnings in the MySQL's error log. The binary logs are named, by default, after the host's name. If that should change - MySQL will not be able to find the binary logs anymore (expecting a name which does previous logs did not use). It is therefore recommended to use:</p>
<blockquote>
<pre>log-bin=mychachine-bin</pre>
</blockquote>
<p>or</p>
<blockquote>
<pre>log-bin=mysql-bin</pre>
</blockquote>
<h4>Essential/Optional</h4>
<ul>
<li><strong>log-bin</strong>: enable on a slave, so that in case it is promoted to master, the rest of the slaves can replicate using its binary logs. Enabling binary logging cannot be done on a live server: this parameter requires MySQL restart.</li>
<li><strong>GRANT</strong>: include the master's host, so that when a slave promotes to master, the master can become a slave and continue replicating.</li>
<li><strong>log-slave-updates</strong>: together with <strong>log-bin</strong>, enable on slave so that master's binary logs are propagated and logged by the slave. This is required if the slave takes the role of a master in a chained replication setup.</li>
<li><strong>expire-logs-days</strong>: set this flag on slave as well [tnx Sheeri].</li>
<li><strong>read-only</strong>: set on slave(s). Refuses any modifying query (INSERT, DELETE, ALTER, DROP etc.) for non-<strong>SUPER</strong> privileged users [tnx Ryan].</li>
<li><strong>sync-binlog</strong>: flush binary log to disk per transaction commit. Use this on master for safer replication; however note that increased I/O is expected [tnx Harrison].</li>
</ul>
<h4>Extra</h4>
<ul>
<li><strong>report-host</strong>, <strong>report-port</strong>: the host and port identifying the slave when looking at SHOW SLAVE HOSTS on master. Set this up on all hosts. See <a href="http://code.openark.org/blog/mysql/the-importance-of-report_host-report_port">further discussion here</a>.</li>
<li><strong>max-binlog-size</strong>: the maximum size for a binary log / relay log file, after which it is rotated.</li>
</ul>
<h4>Expert</h4>
<ul>
<li><strong>binlog-do-db</strong>, <strong>binlog-do-table</strong>, <strong>replicate-do-db</strong>, <strong>...</strong>: filter queries by either not writing them to binary log, or not reading them from the logs.</li>
</ul>
<p>The reason I list the above as "Expert" is not because one must have a super-brain to set them up. That part is easy enough. But they lead to some dangerous situations, sometimes seemingly harmless. It takes great care to control the application and developers from creating those situations. See <a href="http://dev.mysql.com/doc/refman/5.1/en/replication-rules.html">documentation here</a>. See also discussion <a href="http://code.openark.org/blog/mysql/quick-reminder-avoid-using-binlog-do-db">here</a> and <a href="http://www.mysqlperformanceblog.com/2009/05/14/why-mysqls-binlog-do-db-option-is-dangerous/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.openark.org/blog/mysql/replication-configuration-checklist/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

