<?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>Admon Home &#187; mysql</title>
	<atom:link href="http://www.admon.org/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.admon.org</link>
	<description>Linux System Administration</description>
	<lastBuildDate>Sat, 19 May 2012 03:36:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>MySQL: How Triggers act in Replication</title>
		<link>http://www.admon.org/mysql-how-triggers-act-in-replication/</link>
		<comments>http://www.admon.org/mysql-how-triggers-act-in-replication/#comments</comments>
		<pubDate>Sat, 18 Feb 2012 13:35:19 +0000</pubDate>
		<dc:creator>joseph</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[replication]]></category>
		<category><![CDATA[row-based replication]]></category>

		<guid isPermaLink="false">http://www.admon.org/?p=1074</guid>
		<description><![CDATA[Supposed you have a table that being updated by MySQL triggers and the DB is a master of replication, how do the triggers act in the environment? Here we might have a list of questions: Q1, Will the definition sql of the triggers be replicated? Q2, Will the data manipulation sqls triggered by triggers be [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-758" title="mysql" src="http://www.admon.org/wp-content/uploads/2010/01/mysql.jpg" alt="MySQL database" width="150" height="150" />Supposed you have a table that being updated by MySQL triggers and the DB is a master of replication, how do the triggers act in the environment? Here we might have a list of questions:</p>
<ul>
<li>Q1, Will the definition sql of the triggers be replicated?</li>
<li>Q2, Will the data manipulation sqls triggered by triggers be replicated?</li>
<li>Q3, Will the data manipulation sqls on this table that issued by applications be replicated?<span id="more-1074"></span></li>
</ul>
<p>It&#8217;s basically not an issue if you have some understandings of MySQL. But sometimes things are a little different in real world, and it may mess you up.<br />
The answers of these questions depend on which version of MySQL you are running.</p>
<p><strong>MySQL 5.0</strong></p>
<p>The answers are as below.</p>
<p>Q1: Triggers that exist on master side must be re-created on the slave server. Once this is done, the replication flow works as any other standard DML statement that participates in replication.<br />
Q2: NO. SQLs generated by Triggers are not replicated.<br />
Q3: Yes. There is no side effect to triggers.<br />
Reference:  <a href="http://dev.mysql.com/doc/refman/5.0/en/faqs-triggers.html" target="_blank">MySQL 5.0 FAQ: Triggers</a></p>
<p><strong>MySQL 5.1, 5.5 and 5.6</strong></p>
<p>Q1: Re-create of the trigger definition is needed.<br />
Q2: YES for row-based replication, but NO for statement-based replication.<br />
Q3: Yes</p>
<p>The answers depend on whether you are using <a title="Difference of statement-based and row-based MySQL Replication" href="http://www.databasejournal.com/features/mysql/article.php/3922266/Comparing-MySQL-Statement-Based-and-Row-Based-Replication.htm" target="_blank">statement-based or row-based replication</a>. For statement-based replication, it works the same MySQL-5.0. While on row-based replication, the answer for Q2 is YES, the changes caused by executing the trigger on master side are applied on the slave.</p>
<p>Mind that <strong>the triggers are not actually executed on slave under row-based replication</strong>, in case of being applied twice. In other words, the outcome is the same for both row-based and statement-based replication.</p>
<p>Accordingly, if you have different triggers defined on master and slave, you cannot use row-based replication.</p>
<p>References:</p>
<ul>
<li><a href="http://dev.mysql.com/doc/refman/5.1/en/faqs-triggers.html" target="_blank">MySQL 5.1 FAQ: Triggers</a></li>
<li><a href="http://dev.mysql.com/doc/refman/5.5/en/faqs-triggers.html" target="_blank">MySQL 5.5 FAQ: Triggers</a></li>
<li><a href="http://dev.mysql.com/doc/refman/5.6/en/faqs-triggers.html" target="_blank">MySQL 5.6 FAQ: Triggers</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.admon.org/mysql-how-triggers-act-in-replication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL 5.5.15 GA Released</title>
		<link>http://www.admon.org/mysql-5-5-15-ga-released/</link>
		<comments>http://www.admon.org/mysql-5-5-15-ga-released/#comments</comments>
		<pubDate>Fri, 29 Jul 2011 04:01:02 +0000</pubDate>
		<dc:creator>joseph</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://www.admon.org/?p=910</guid>
		<description><![CDATA[MySQL 5.5.15 GA has been released in 28 July 2011. Functionality Added or Changed The undocumented &#8211;all option for perror is deprecated and will be removed in MySQL 5.6. Bugs Fixed InnoDB Storage Engine: A failed CREATE INDEX operation for an InnoDB table could result in some memory being allocated and not freed. This memory [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-758" title="mysql" src="http://www.admon.org/wp-content/uploads/2010/01/mysql.jpg" alt="MySQL database" width="150" height="150" />MySQL 5.5.15 GA has been released in 28 July 2011.</p>
<p><strong>Functionality Added or Changed</strong></p>
<div>
<ul>
<li>The undocumented <em>&#8211;all</em> option for <a title="4.8.1. perror — Explain Error Codes" href="http://dev.mysql.com/doc/refman/5.5/en/perror.html"><strong>perror</strong></a> is deprecated and will be removed in MySQL 5.6.</li>
</ul>
</div>
<p><strong>Bugs Fixed</strong></p>
<ul>
<li><strong>InnoDB Storage Engine</strong>: A failed <em>CREATE INDEX</em> operation for an <em>InnoDB</em> table could result in some memory being allocated and not freed. This memory leak could affect tables created with the <em>ROW_FORMAT=DYNAMIC</em> and <em>ROW_FORMAT=COMPRESSED</em> settings. (Bug #12699505)<span id="more-910"></span></li>
<li><strong>Partitioning</strong>: Auto-increment columns of partitioned tables were checked even when they were not being written to. In debug builds, this could lead to a crash of the server. (Bug #11765667, Bug #58655)</li>
<li><strong>Partitioning</strong>: The <a href="http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_unix-timestamp"><em>UNIX_TIMESTAMP()</em></a> function was not treated as a monotonic function for purposes of partition pruning. (Bug #11746819, Bug #28928)</li>
<li><strong>Replication</strong>: If a <a title="12.2.6. LOAD DATA INFILE       Syntax" href="http://dev.mysql.com/doc/refman/5.5/en/load-data.html"><em>LOAD DATA INFILE</em></a> statement—replicated using statement-based replication—featured a <a title="10.4.5. The SET Type" href="http://dev.mysql.com/doc/refman/5.5/en/set.html"><em>SET</em></a> clause, the name-value pairs were regenerated using a method (<em>Item::print()</em>) intended primarily for generating output for statements such as <a title="12.8.2. EXPLAIN Syntax" href="http://dev.mysql.com/doc/refman/5.5/en/explain.html"><em>EXPLAIN EXTENDED</em></a>, and which cannot be relied on to return valid SQL. This could in certain cases lead to a crash on the slave.To fix this problem, we now name each value in its original, user-supplied form, and use that to create <a title="12.2.6. LOAD DATA INFILE       Syntax" href="http://dev.mysql.com/doc/refman/5.5/en/load-data.html"><em>LOAD DATA INFILE</em></a>statements for statement-based replication. (Bug #11902767, Bug #60580)See also Bug #34283, Bug #11752526, Bug #43746.</li>
<li>Compiling the server with maintainer mode enabled failed for <strong>gcc</strong> 4.6 or higher. (Bug #12727287)</li>
<li>The option-parsing code for empty strings leaked memory. (Bug #12589928)</li>
<li>Previously, an inappropriate error message was produced if a multiple-table update for an <em>InnoDB</em> table with a clustered primary key would update a table through multiple aliases, and perform an update that may physically move the row in at least one of these aliases. Now the error message is: <em>Primary key/partition key update is not permitted since the table is updated both as &#8216;<em><em>tbl_name1</em></em>&#8216; and &#8216;<em><em>tbl_name2</em></em>&#8216;</em>(Bug #11882110)See also Bug #11764529.</li>
<li><a title="12.1.6. ALTER TABLE Syntax" href="http://dev.mysql.com/doc/refman/5.5/en/alter-table.html"><em>ALTER TABLE {MODIFY|CHANGE} &#8230; FIRST</em></a> did nothing except rename columns if the old and new versions of the table had exactly the same structure with respect to column data types. As a result, the mapping of column name to column data was incorrect. The same thing happened for <a title="12.1.6. ALTER TABLE Syntax" href="http://dev.mysql.com/doc/refman/5.5/en/alter-table.html"><em>ALTER TABLE DROP COLUMN, ADD COLUMN</em></a> statements intended to produce a new version of table with exactly the same structure as the old version. (Bug #61493, Bug #12652385)</li>
<li>Incorrect handling of metadata locking for <a title="12.4.6.3. FLUSH Syntax" href="http://dev.mysql.com/doc/refman/5.5/en/flush.html"><em>FLUSH TABLES WITH READ LOCK</em></a>for statements requiring prelocking caused two problems:
<div>
<ul>
<li>Execution of any data-changing statement that required prelocking (that is, involved a stored function or trigger) as part of transaction slowed down somewhat all subsequent statements in the transaction. Performance in a transaction that periodically involved such statements gradually degraded over time.</li>
<li>Execution of any data-changing statement that required prelocking as part of transaction prevented a concurrent <a title="12.4.6.3. FLUSH Syntax" href="http://dev.mysql.com/doc/refman/5.5/en/flush.html"><em>FLUSH TABLES WITH READ LOCK</em></a> from proceeding until the end of transaction rather than at the end of the particular statement.</li>
</ul>
</div>
<p>(Bug #61401, Bug #12641342)</li>
<li>The fractional part of the “Queries per second” value in MySQL status output could be displayed incorrectly. (Bug #61205, Bug #12565712)</li>
<li><a title="12.2.6. LOAD DATA INFILE       Syntax" href="http://dev.mysql.com/doc/refman/5.5/en/load-data.html"><em>LOAD DATA INFILE</em></a> incorrectly parsed relative data file path names that ascended more than three levels in the file system and as a consequence was unable to find the file. (Bug #60987, Bug #12403662)</li>
<li>For unknown users, the native password plugin reported incorrectly that no password had been specified even when it had. (Bug #59792, Bug #11766641)</li>
<li>For <a title="13.5. The MyISAM Storage Engine" href="http://dev.mysql.com/doc/refman/5.5/en/myisam-storage-engine.html"><em>MyISAM</em></a> tables, attempts to insert incorrect data into an indexed <em>GEOMETRY</em> column could result in table corruption. (Bug #57323, Bug #11764487)</li>
<li>In debug builds, <em>Field_new_decimal::store_value()</em> was subject to buffer overflows. (Bug #55436, Bug #11762799)</li>
<li>A race condition between loading a stored routine using the name qualified by the database name and dropping that database resulted in a spurious error message: <em>The table mysql.proc is missing, corrupt, or contains bad data</em> (Bug #47870, Bug #11756013)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.admon.org/mysql-5-5-15-ga-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Purge MySQL Binary Logs periodically</title>
		<link>http://www.admon.org/purge-mysql-binary-logs-periodically/</link>
		<comments>http://www.admon.org/purge-mysql-binary-logs-periodically/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 12:22:45 +0000</pubDate>
		<dc:creator>joseph</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[bin-log]]></category>
		<category><![CDATA[logfiles]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[replication]]></category>

		<guid isPermaLink="false">http://planet.admon.org/?p=553</guid>
		<description><![CDATA[If you have binary logging enabled on your MySQL server (i.e. the log-bin parameter is set in the config file), then you may notice a bulk of large files in the MySQL data directory over time. Generally you only need to enable this binary logging if your server is acting as a relication master or [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://planet.admon.org/wp-content/uploads/2010/01/mysql.jpg"><img class="alignleft size-full wp-image-758" title="mysql" src="http://planet.admon.org/wp-content/uploads/2010/01/mysql.jpg" alt="MySQL database" width="150" height="150" /></a>If you have binary logging enabled on your MySQL server (i.e. the <a href="http://dev.mysql.com/doc/refman/5.0/en/binary-log.html">log-bin parameter</a> is set in the config file), then you may notice a bulk of large files in the MySQL data directory over time. Generally you only need to enable this binary logging if your server is acting as a relication master or if you need the ability to do point in time recovery from your latest backup.<span id="more-553"></span></p>
<p>NOTE: On a <a href="http://www.howtoforge.com/mysql_database_replication">MySQL replication</a> environment, users must be careful in deleting binary logs. If slaves are lagging behind the server SOME days, the binary log purge might cause replication to fail. Make sure the logs file are not in use before removing them!</p>
<p>In any case here are some useful examples for purging binary log files easiliy. We&#8217;ll show you two quick ways on deleting the expired bin-log files.</p>
<p>As the purge work here is issued by mysql itself, please make sure you have MySQL-4.1 and later version installed. For version 4.0 and 3.xx, it does not support the following feathers.</p>
<p>1, <strong>Delete MySQL bin-log files by PURGE statement</strong></p>
<p>For example, if you need to delete all binary logs older than 7 days, you just need to run this sql:</p>
<pre>mysql&gt; PURGE BINARY LOGS BEFORE DATE_SUB( NOW( ), INTERVAL 7 DAY);</pre>
<p>To purge all logs before a specific date:</p>
<pre>mysql&gt; PURGE MASTER LOGS BEFORE '2010-03-01 00:00:00';</pre>
<p>To purge logs automatically (every Monday at 3am) you could use a cron job like this:</p>
<pre>0 3 * * mon mysql -uroot -e 'PURGE BINARY LOGS BEFORE DATE_SUB( NOW( ), INTERVAL 7 DAY)'</pre>
<p>2, <strong>Remove bin-log by <a href="http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html">the variable expire_log_days</a></strong></p>
<p>An alternative option is to set &#8220;expire_log_days&#8221; as MySQL server parameter. The default values for expire_log_days is not to purge logs. You can either set it in MySQL&#8217;s configuration file or in a command terminal like below:</p>
<pre>mysql&gt; SET GLOBAL expire_logs_days = 7;
Query OK, 0 rows affected (0.00 sec)

mysql&gt; show variables like 'expire_%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| expire_logs_days |  7    |
+------------------+-------+
1 row in set (0.00 sec)</pre>
<p>When this vavirable takes effect, the log files will be removed automatically on a weekly basis.<br />
For any issues, don&#8217;t forget to raise a thread at our <a href="http://forum.admon.org/databases/">database support forum</a> here.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.admon.org/purge-mysql-binary-logs-periodically/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ways to reset MySQL user password</title>
		<link>http://www.admon.org/ways-to-reset-mysql-user-password/</link>
		<comments>http://www.admon.org/ways-to-reset-mysql-user-password/#comments</comments>
		<pubDate>Fri, 01 Jan 2010 06:10:26 +0000</pubDate>
		<dc:creator>joseph</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[DBA]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[permission]]></category>

		<guid isPermaLink="false">http://planet.admon.org/?p=517</guid>
		<description><![CDATA[How can I change user password under MySQL server when I lost my password? Here&#8217;s I&#8217;ll show two examples. The first example is about how to change password for normal user using Linux command line option, and the second example is on how to reset MySQL DBA password (By default, this user is called root). [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://planet.admon.org/wp-content/uploads/2010/01/mysql.jpg"><img class="alignleft size-full wp-image-758" title="mysql" src="http://planet.admon.org/wp-content/uploads/2010/01/mysql.jpg" alt="MySQL database" width="150" height="150" /></a>How can I change user password under MySQL server when I lost my password?<br />
Here&#8217;s I&#8217;ll show two examples. The first example is about how to change password for normal user using Linux command line option, and the second example is on how to reset MySQL DBA password (By default, this user is called root).<span id="more-517"></span></p>
<p><strong>Reset user password in MySQL</strong><br />
Let&#8217;s assume the normal user&#8217;s name is fatman, follow these steps to start:<br />
1), Login to MySQL server, type following command at shell prompt to login as root</p>
<pre>$ mysql -u root -p</pre>
<p>2), Choose the right database mysql database, it&#8217;s mysql:</p>
<pre>mysql&gt; use mysql;</pre>
<p>3), Change password for user fatman:</p>
<pre>mysql&gt; update user set password=PASSWORD("NEW-PASSWORD-HERE") where User='fatman';</pre>
<p>4), Finally,dont forget to flush privileges:</p>
<pre>mysql&gt; flush privileges;</pre>
<p>You can also use grant to reset a user&#8217;s password, the command is like this:</p>
<pre>mysql&gt; grant select,update,delete,insert on somedb.* to fatman@'somehost' identified by 'NEW-PASSWORD-HERE';</pre>
<p><strong>Reset DBA password in MySQL</strong><br />
When the DBA&#8217;s password lost, things become a little difficult, a restart might needed which is not so good for productive servers. There still have some possibilites to retrieval it without restart mysql service:</p>
<p>1), Is there any user has insert permission on the database &#8220;mysql&#8221;?<br />
If so, he can insert into mysql.user and create another DBA account.</p>
<p>2), Is there any user has super user permissions?<br />
For example, when the user was create like &#8220;<em>GRANT ALL ON *.* TO user@&#8217;localhost&#8217; WITH GRANT OPTION</em>&#8220;, then this use is actually another DBA, you can ask him to reset root&#8217;s password.</p>
<p>If you got no luck till now, we have a common way here to fix the password. We can ask mysql server to bypass its grant tables when starting it. Thus it will not verify user passwords and permissions when they logon. That means all users will have <a href="http://dev.mysql.com/doc/refman/5.1/en/privileges-provided.html">full access to all databases</a> as a database administrator.</p>
<pre>$ /usr/sbin/mysqld --verbose --help | grep skip-grant-tables -A1
  --skip-grant-tables Start without grant tables. This gives all users FULL
                      ACCESS to all tables!
--
skip-grant-tables                 FALSE
skip-slave-start                  FALSE
</pre>
<p>Before making this changes, you need to make sure there&#8217;s no queries running on mysql. Then shutdown mysql instance first (mysql&#8217;s control script will help do that. In RPM based systems, it&#8217;s <em>/etc/init.d/mysql</em>) , and apply this option in the script, and start the service again.</p>
<p>When the DBA password got reset, do forget to remove the changes in mysql&#8217;s control script. If there any issue occures, please dont hesitate to <a href="http://forum.admon.org/linux-databases/">create a topic</a> in our support forum!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.admon.org/ways-to-reset-mysql-user-password/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tips for Rebuilding MySQL Replication</title>
		<link>http://www.admon.org/tips-for-rebuilding-mysql-replication/</link>
		<comments>http://www.admon.org/tips-for-rebuilding-mysql-replication/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 04:42:53 +0000</pubDate>
		<dc:creator>joseph</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[replication]]></category>

		<guid isPermaLink="false">http://planet.admon.org/?p=462</guid>
		<description><![CDATA[Let&#8217;s keep this post smart. It&#8217;s intended to help you rebuild a crashed MySQL replication. We assume that bin-log has been enabled at the master side. Basically what you need to do is to retrival a snapshot of your master database. It covers three types of information, a snapshot of your current mysql database, and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://planet.admon.org/wp-content/uploads/2010/01/mysql.jpg"><img class="alignleft size-full wp-image-758" title="mysql" src="http://planet.admon.org/wp-content/uploads/2010/01/mysql.jpg" alt="MySQL database" width="150" height="150" /></a>Let&#8217;s keep this post smart. It&#8217;s intended to help you rebuild a crashed MySQL replication. We assume that bin-log has been enabled at the master side.</p>
<p>Basically what you need to do is to retrival a snapshot of your master database. It covers three types of information, a snapshot of your current mysql database, and master log file name and its running position when this snapshot created.<span id="more-462"></span></p>
<p>You can achieve these information on a running DB like this:</p>
<p>Firstly, frozen your database, in order to disable any writes/updates on the databases. It affects your service for sure. Run two sql queries on a terminal:</p>
<pre>mysql&gt; FLUSH TABLES WITH READ LOCK;
Query OK, 0 rows affected (0.53 sec)

mysql&gt; SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| binlog-db.000004 |  88689   |              |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.01 sec)
</pre>
<p>Keep this session open.  Note that when this session closes, READ LOCK will vanish, and your database will keep changing again.</p>
<p>Then open another terminal to create a copy of your current database files. There are three common ways to do that depending on your system environment. Either of these methods is okay.</p>
<p>1, Use mysqldump to copy all the data.</p>
<p>The disadvantage for mysqldump is that it uses very long time for dumpping large databases. It&#8217;s really unacceptable on productive servers.</p>
<pre>shell$ mysqldump --database db1 db2 &gt; fullbackup-timestamp.sql</pre>
<p>2, Use a LVM snapshot</p>
<p>It only takes some seconds to create a <a href="http://tldp.org/HOWTO/LVM-HOWTO/snapshots_backup.html">LVM snapshot</a>. When your snapshot created, you can copy the snapshot to the slave server.<br />
As all the database files are exactly the same as master DB, you need to make sure the configuration files are similar as well.</p>
<p>3, Use XFS&#8217; frozen feature to do that</p>
<pre>SYSTEM xfs_freeze -f /var/lib/mysql;
SYSTEM YOUR_SCRIPT_TO_CREATE_SNAPSHOT.sh;
SYSTEM xfs_freeze -u /var/lib/mysql;</pre>
<p>After the snapshot createed, you either leave the first session, or submit this query directly:</p>
<pre>mysql&gt; UNLOCK TABLES;</pre>
<p>Finally you need to restore these databases from mysql dump file or the snapshot at slave side. When recovering a large database, time make lots of sense. it might take you one or more days to finish a recovery.<br />
To speed up a mysql recovery, there&#8217;re always some valuable advises from wise man (The wise man here is &#8230; my friend). for example you can disable binlog when importing large sql files.</p>
<pre>mysql&gt; SET SQL_LOG_BIN=0;
Query OK, 0 rows affected (0.00 sec)

mysql&gt; SOURCE /PATH/TO/MYSQL-BACKUP.SQL</pre>
<p>When the files are importing, you need to make sure there are enough disk space avaiable, otherwise, it would crashed again. After importing all data files at slave side,  you need to tell the slave at which point it should read binlog from master:</p>
<pre>mysql&gt; SLAVE STOP;

mysql&gt; SLAVE RESET;

mysql&gt; CHANGE MASTER TO MASTER_HOST='pub.admon.org',MASTER_LOG_FILE='binlog-db.000004',MASTER_LOG_POS=88689;

myql&gt; SLAVE START;</pre>
<p>If all your recovery work is a remote operation, <a href="http://www.rackaid.com/resources/linux-screen-tutorial-and-how-to/">using Screen</a> is highly suggested.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.admon.org/tips-for-rebuilding-mysql-replication/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Repair MySQL Replication by SQL_SLAVE_SKIP_COUNTER</title>
		<link>http://www.admon.org/repair-mysql-replication-by-sql_slave_skip_counter/</link>
		<comments>http://www.admon.org/repair-mysql-replication-by-sql_slave_skip_counter/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 11:17:47 +0000</pubDate>
		<dc:creator>joseph</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[replication]]></category>

		<guid isPermaLink="false">http://blog.admon.org/?p=169</guid>
		<description><![CDATA[If you set up MySQL replication, you probably have ever faced this problem. there are invalid MySQL queries which cause the replication not to work anymore. Here I&#8217;ll explain how you can repair the replication on MySQL slave without rebuilding the whole repication environment. There are two steps here: 1 &#8211; Identifying The Problem To [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://planet.admon.org/wp-content/uploads/2010/01/mysql.jpg"><img class="alignleft size-full wp-image-758" title="mysql" src="http://planet.admon.org/wp-content/uploads/2010/01/mysql.jpg" alt="MySQL database" width="140" height="140" /></a>If you set up MySQL replication, you probably have ever faced this problem. there are invalid MySQL queries which cause the replication not to work anymore. Here I&#8217;ll explain how you can repair the replication on MySQL slave without <a href="http://www.howtoforge.com/mysql_database_replication">rebuilding the whole repication environment</a>. There are two steps here:<span id="more-169"></span></p>
<p><strong>1 &#8211; Identifying The Problem</strong></p>
<p>To find out whether replication is working or not, and check mysql logs<br />
to make sure what caused it to stop. On Debian, MySQL logs to<br />
/var/log/syslog:</p>
<pre>admon:/home/admin# grep mysql /var/log/syslog
server1:/home/admin# grep mysql /var/log/syslog
Jun 29 09:16:08 http2 mysqld[14380]: 080629 9:16:08 [ERROR] Slave: Error
'Table 'mydb.taggregate_temp_1212347876' doesn't exist' on query. Default database: 'mydb'. Query: 'UPDATE thread AS thread,taggregate_temp_1212347876 AS aggregate
Jun 29 09:16:08 http2 mysqld[14380]: ^ISET thread.views = thread.views + aggregate.views
Jun 29 09:16:08 http2 mysqld[14380]: ^IWHERE thread.threadid = aggregate.threadid', Error_code: 1146
Jun 29 09:16:08 http2 mysqld[14380]: 080629 9:56:08 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-bin.001079' position 203015142
</pre>
<p>Now, you can see the query that caused the error, and the stop position. To determine the exact query:</p>
<pre>mysql&gt; SHOW SLAVE STATUSG
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
....
Last_Errno: 1146
Last_Error: Error 'Table 'mydb.taggregate_temp_1212347876' doesn't exist' on query. Default database: 'mydb'.
Query: 'UPDATE thread AS thread,taggregate_temp_1212347876 AS aggregate
SET thread.views = thread.views + aggregate.views
WHERE thread.threadid = aggregate.threadid'
Skip_Counter: 0
......
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
1 row in set (0.00 sec)
mysql&gt;</pre>
<p>New we are prepare to fix this issue.<br />
<strong>2 &#8211; Repairing The Replication</strong><br />
we need to stop the slave first, by running:</p>
<pre>mysql&gt; STOP SLAVE;</pre>
<p>To Fix the issue is quite easy. We tell the slave to simply skip the invalid SQL query here:</p>
<pre>mysql&gt; SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;</pre>
<p>This tells the slave to skip one query (which is the invalid one that<br />
caused the replication to stop). If you wanna skip two queries, you&#8217;d<br />
use SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 2; instead and so on.</p>
<p>Now the issue has been fixed, we can start the slave again by running:</p>
<pre>mysql&gt; START SLAVE;</pre>
<p>and then,check if replication is working smoothly again.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.admon.org/repair-mysql-replication-by-sql_slave_skip_counter/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MPB: InnoDB vs MyISAM vs Falcon</title>
		<link>http://www.admon.org/mpb-innodb-vs-myisam-vs-falcon/</link>
		<comments>http://www.admon.org/mpb-innodb-vs-myisam-vs-falcon/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 10:43:35 +0000</pubDate>
		<dc:creator>joseph</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[falcon]]></category>
		<category><![CDATA[InnoDB]]></category>
		<category><![CDATA[MyISAM]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://blog.admon.org/?p=146</guid>
		<description><![CDATA[MySQLPerformanceBlog has issue &#8220;Several days ago MySQL AB made new storage engine Falcon available for wide auditory. We cannot miss this event and executed several benchmarks to see how Falcon performs in comparison to InnoDB and MyISAM. The second goal of benchmark was a popular myth that MyISAM is faster than InnoDB in reads, as [...]]]></description>
			<content:encoded><![CDATA[<div>
<p><a href="http://planet.admon.org/wp-content/uploads/2010/01/mysql.jpg"><img class="alignleft size-full wp-image-758" title="mysql" src="http://planet.admon.org/wp-content/uploads/2010/01/mysql.jpg" alt="MySQL database" width="150" height="150" /></a>MySQLPerformanceBlog has issue &#8220;Several days ago <a href="http://www.mysql.com">MySQL AB</a> made new storage engine Falcon available for wide auditory. We cannot miss this event and executed several benchmarks to see how Falcon performs in comparison to InnoDB and MyISAM.<span id="more-146"></span><br />
The second goal of benchmark was a popular myth that MyISAM is faster than InnoDB in reads, as InnoDB is transactional, supports Foreign Key and has an operational overhead. As you will see it is not always true.&#8221;</p>
<p>For benchmarks I used our PHPTestSuite which allows to test wide range tables and queries.<br />
The script and instruction are available here at <a title="http://www.mysqlperformanceblog.com/files/benchmarks/phptestsuite.stable.tar.gz" href="http://www.mysqlperformanceblog.com/files/benchmarks/phptestsuite.stable.tar.gz">mysqlperformanceblog.com</a>, it&#8217;s posted by <strong>Vadim </strong>at January 8, 2007<strong>.<a href="http://www.mysqlperformanceblog.com/2007/01/08/innodb-vs-myisam-vs-falcon-benchmarks-part-1/"></a></strong></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.admon.org/mpb-innodb-vs-myisam-vs-falcon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Falcon Storage Engine Design Review</title>
		<link>http://www.admon.org/falcon-storage-engine-design-review/</link>
		<comments>http://www.admon.org/falcon-storage-engine-design-review/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 07:38:19 +0000</pubDate>
		<dc:creator>joseph</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[falcon]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://blog.admon.org/?p=35</guid>
		<description><![CDATA[Now as new MySQL Storage engine &#8211; Falcon is public I can write down my thought about its design, which I previously should have kept private as I partially got them while working for MySQL. These thought base on my understanding, reading docs, speaking to Jim, Monty, Arjen and other people so I might miss [...]]]></description>
			<content:encoded><![CDATA[<p>Now as new MySQL Storage engine &#8211; Falcon is public I can write down my thought about its design, which I previously should have kept private as I partially got them while working for MySQL.<span id="more-35"></span></p>
<p>These thought base on my understanding, reading docs, speaking to Jim, Monty, Arjen and other people so I might miss something, something might be planned to be changed or not 100% correct but anyway you might find it<br />
interesting.</p>
<p>In many cases what I find good or bad would base of my MySQL use with existing applications &#8211; if you design new<br />
applications which are done specially for Falcon you might find those aspects positive.</p>
<p>[-] No Spinlocks Falcon does not use Spinlocks. It has its own lock implementation which does operation system wait if resource is unavailable. We&#8217;ll see where this leads us but I believe on multiple CPU systems you need some spinning done,at least for some types of locks where conflicts will be frequent. And now even laptops are getting multi cores so we can forget about spinlocks wasting CPU time on single CPU boxes without much of the gain. Spinlocks need to be wise though.</p>
<p>[+] Row Cache The fact Falcon has separate row cache is great as it means it can have much more data cached in the same cache size. You might need only single row from 8-16K page but page cache requires you to cache whole page, so needing<br />
1000 of 100 bytes rows cached, which are all on different pages you need 100K of memory not 8-16M as you need with page cache. There are design techniques though to improve page cache efficiency in this respect, so in practice difference can be less.</p>
<p>[-] Not fixed cache size, but size range This is minor one. Unlike you would typically see Falcon uses minimum and maximum sizes for row cache instead of single size, this is complicated. If I have 8GB of RAM I can assume I want 4GB allocated to row cache and I do not really care about how these 4GB will be managed, to keep it the most efficient. Should I specify min size of 3GB or 3.8GB ? What is the difference ? Will purge run well too frequently if I keep them close. Manual does not say much on this matter at this point.</p>
<p>[-] Few configuration options This one is probably a bit contradicting to previous one but I put on my experimentator Hat here, not one of general user. I would like to see more configuration options to adjust database behavior to match my needs. I love this Zero administration thing and I would like database to manage things for me but it should first prove it can do it better than I do, and this can be only checked by comparing performance with your own optimized settings and one database engine would like to use itself. At this point I have not seen auto-configuration algorithms to be able to cover all kinds of workloads &#8211; they may deal well with something typical but not if you&#8217;re doing something unusual, which people do quite frequently with MySQL.</p>
<p>[+] Compact Indexes Compact Indexes are great. Huge indexes is where large portion of Innodb performance problems come however. We should however see how &#8220;compact&#8221; they would be in real world cases and how much performance it will give. As &#8220;SHOW TABLE STATUS&#8221; is not showing index sized in the release we tested it is hard to see how small indexes really are.</p>
<p>[-] No &#8220;using index&#8221; Falcon always have to check the row data even if you retrieve only columns which are in the index. I think this is big gotcha as having index covered queries is great optimization for wide range of queries.</p>
<p>[+] Ordered data reads Unlike other storage engines which will read row data as they traverse the index Falcon can optimize it by reading index first (possibly many indexes) and only then reading row data in sorted order. This can help a lot if you traverse significant portion of the table (or data which is locally stored but in random order). In my opinion this however should have been implemented outside of MySQL Storage Engine level for MySQL &#8211; reading rows in their physical order can be applied to most storage engines, it certainly can be applied for MyISAM and Innodb. I remember there were plans to implement such handler interface but I&#8217;m not sure there they are now.</p>
<p>[-] No Clustering Index support Unlike Innodb Falcon does not cluster data by Primary Key or any other key.This is good for some applications bad for others. There is large amount of applications out where which are optimized for Innodb which does have clustering, this is why I have it with Minus sign. In my opinion Optional clustering is best, in fact this is what you can get in Innodb (by using its internal hidden primary key) but this functionality is not exported well as it requires you to get rid of primary keys etc. Some presentations say Falcon does not need clustering because of optimized read by the index. This is not the case. If you access small primary key ranges with Innodb you will need to perform just couple of page reads, with Falcon if rows were inserted in different times a lot of scattered reads will be needed. Think about typical use of Innodb clustering &#8211; users mailbox, clustered by (user_id,message_id).</p>
<p>[+] Row compression Falcon uses some nice fast row compression methods, for example using only as many bytes for<br />
integer as it requires, not storing column value if it is default etc. This is nice even though may show strange effects if you do not know about this feature, for example changing default value needs table rebuild even though for other storage engines it often could be done simply by changing meta data (it is not implemented in MySQL anyway<br />
though). Very interesting to see how this one will compare to transparent gzip page compression which is being implemented for Innodb right now.</p>
<p>[-] Tablespace per database You may notice right now each database in Falcon gets its own tablespace and its own set of<br />
logs. With typical for MySQL use of Databases just as directories it can be the problem &#8211; if transaction spawns multiple databases you need multiple log flushes on commit, plus ether you use XA to synchronize these which is expensive or it will be possible for your transaction changes to commit in one database and not in the other. The other issue you will see is having consistent snapshots being consistent for database only, so if you have started transaction accessed table in database A and a while after accessed table in database B, you will see records in B which were modified/inserted after you started transaction.</p>
<p>[-] Isolation Modes So far limited amount of isolation modes is supported, including no support for SELECT FOR UPDATE. This is also why Falcon has Optimistic locking concurrency which can give you problems if you have lock intensive workload so many update queries have to wait for row level locks. With Falcon at this point situation is rather funny, it will still wait for other transaction which updated the row to commit and then fail with ERROR 1020 (HY000): Record has changed since last read in table &#8216;t&#8217; error message. If you find Falcon or Innodb behavior better still prepare for this to be area where things are different and your application may need to be changed. This is also area where detailed documentation is missing so far.</p>
<p>[-] No protection from partial page writes This means if single page write was not atomic, so only part of page was changed while other part remains old your database may end up in non-recoverable stage. This is why Innodb has &#8220;innodb double write buffer&#8221;. Jim does not believe this is the problem but I remember having problem not the once and twice before Innodb Double Write Buffer was implemented and seeing some pages recovered from it after it was implemented. Speaking with Oracle and PostgreSQL developers it looks like they all acknowledge this problem and have techniques to deal with it, so I&#8217;m a bit surprised why Jim does not believe in it.</p>
<p>[+/-] Only committed changes go to the disk Innodb modifies data in the database when you change it, Falcon only<br />
when it is committed. This has some good sides such as no problem with very long rollbacks on recovery but also means you should have enough memory to hold all transaction changes. I agree most transactions are small and should be fine but if you have long running transactions, for example batch jobs you may end up in trouble or be forced to rewrite<br />
them to commit often.</p>
<p>[+] Blob handling optimizations Jim loves BLOBs as his own child, so Falcon is optimized in Blob handling for example having direct blob writes to the database and probably some others. This would be very interesting to see how these optimizations will show themselves in practice.</p>
<p>The other interesting point which I have not found much information about is regarding handling fragmentation &#8211; what happens on row updates, are they stored in the same position or in another location ? Does row ever split into multiple parts like with MyISAM or always stored as single piece ?<br />
These are going to be pretty important for IO bound workloads.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.admon.org/falcon-storage-engine-design-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

