<?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>MySQL Preacher &#187; Intermediate</title>
	<atom:link href="http://mysqlpreacher.com/wordpress/category/databases/mysql/intermediate/feed/" rel="self" type="application/rss+xml" />
	<link>http://mysqlpreacher.com/wordpress</link>
	<description>A MySQL blog, from a MySQL DBA</description>
	<lastBuildDate>Wed, 16 Jun 2010 13:13:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Datetime &amp; Timestamp manipulation / migration explained</title>
		<link>http://mysqlpreacher.com/wordpress/2010/06/datetime-timestamp-manipulation-migration-explained/</link>
		<comments>http://mysqlpreacher.com/wordpress/2010/06/datetime-timestamp-manipulation-migration-explained/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 16:47:16 +0000</pubDate>
		<dc:creator>Darren Cassar</dc:creator>
				<category><![CDATA[Advanced]]></category>
		<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[date_format]]></category>
		<category><![CDATA[microsecond]]></category>
		<category><![CDATA[migrating to mysql]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[millisecond]]></category>
		<category><![CDATA[mysql millisecond]]></category>
		<category><![CDATA[str_to_date]]></category>
		<category><![CDATA[timstamp]]></category>

		<guid isPermaLink="false">http://mysqlpreacher.com/wordpress/?p=351</guid>
		<description><![CDATA[Are you doing some datetime manipulation or maybe you are migrating from some database technology to MySQL or possibly using milliseconds?
Here is an example on how to go about it:
Say you have the following date: MAR 16 2008 09:12:51:893AM
SELECT DATE_FORMAT(STR_TO_DATE('MAR 16 2008 09:12:51:893AM','%M %d %Y %h:%i:%s:%f%p'),'%Y%m%d%k%i%s.%f'); --&#62; 2008031691251.893000

What if its PM rather than AM
SELECT DATE_FORMAT(STR_TO_DATE('MAR [...]]]></description>
			<content:encoded><![CDATA[<p>Are you doing some datetime manipulation or maybe you are migrating from some database technology to MySQL or possibly using milliseconds?<br />
Here is an example on how to go about it:</p>
<p>Say you have the following date: MAR 16 2008 09:12:51:893AM<br />
<code>SELECT DATE_FORMAT(STR_TO_DATE('MAR 16 2008 09:12:51:893AM','%M %d %Y %h:%i:%s:%f%p'),'%Y%m%d%k%i%s.%f'); --&gt; 2008031691251.893000<br />
</code></p>
<p>What if its PM rather than AM<br />
<code>SELECT DATE_FORMAT(STR_TO_DATE('MAR 16 2008 09:12:51:893PM','%M %d %Y %h:%i:%s:%f%p'),'%Y%m%d%k%i%s.%f'); --&gt; 20080316211251.893000<br />
</code></p>
<p>Ok so this is just simple string manipulation where:<br />
<code>%M is the month name<br />
%d is day number<br />
%Y is the year<br />
%h is the hour<br />
%i is the minute<br />
%s is the second<br />
%f is the microsecond<br />
%p is the period: ante or post meridiem</code><br />
In the DATE_FORMAT part we se a %k which is in 24hr format in order to loose the period.</p>
<p>A more detailed list is found <a href="http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format" target="_blank">here</a></p>
<p>Here is a demo:</p>
<p><code>mysql Tue Jun 15 12:32:37 2010 &gt; CREATE TABLE test.abc(a DECIMAL(17,3)) ENGINE=MYISAM;<br />
Query OK, 0 rows affected (0.03 sec)</code></p>
<p><code>mysql Tue Jun 15 12:32:45 2010 &gt; INSERT INTO abc VALUES ( DATE_FORMAT(STR_TO_DATE('MAR 16 2008 09:12:51:893PM','%M %d %Y %h:%i:%s:%f%p'),'%Y%m%d%k%i%s.%f') );<br />
Query OK, 1 row affected (0.01 sec)</code></p>
<p><code>mysql Tue Jun 15 12:32:51 2010 &gt; SELECT * FROM abc;<br />
+--------------------+<br />
| a                  |<br />
+--------------------+<br />
| 20080316211251.893 |<br />
+--------------------+<br />
1 row in set (0.00 sec)</p>
<p></code></p>
<p><code>mysql Tue Jun 15 12:32:56 2010 &gt; SELECT TIMESTAMP(a) FROM abc;<br />
+----------------------------+<br />
| TIMESTAMP(a)               |<br />
+----------------------------+<br />
| 2008-03-16 21:12:51.893000 |<br />
+----------------------------+<br />
1 row in set (0.00 sec)</code></p>
]]></content:encoded>
			<wfw:commentRss>http://mysqlpreacher.com/wordpress/2010/06/datetime-timestamp-manipulation-migration-explained/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automating MySQL access with expect and bash scripting</title>
		<link>http://mysqlpreacher.com/wordpress/2010/02/automating-mysql-access-with-expect-and-bash-scripting/</link>
		<comments>http://mysqlpreacher.com/wordpress/2010/02/automating-mysql-access-with-expect-and-bash-scripting/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 17:08:26 +0000</pubDate>
		<dc:creator>Darren Cassar</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[expect]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://mysqlpreacher.com/wordpress/?p=327</guid>
		<description><![CDATA[If you have multiple database servers with strange names, or if you have to hop over multiple machines to connect to any mysql database server, then you know what a pain it can be to administer such a setup. Thanks to some scripting, you can automate such tasks as follows:
Create an expect script:
/path/to/sshmysql.exp
#!/usr/bin/expect -f
#script by [...]]]></description>
			<content:encoded><![CDATA[<p>If you have multiple database servers with strange names, or if you have to hop over multiple machines to connect to any mysql database server, then you know what a pain it can be to administer such a setup. Thanks to some scripting, you can automate such tasks as follows:</p>
<p>Create an expect script:<br />
/path/to/sshmysql.exp</p>
<blockquote><p>#!/usr/bin/expect -f<br />
#script by darren cassar<br />
#mysqlpreacher.com</p>
<p>set machine  [lindex $argv 0]</p>
<p>set timeout -1</p>
<p>spawn ssh username@$machine<br />
match_max 100000<br />
expect -exact &#8220;assword: &#8221;<br />
send &#8212; &#8220;password\r&#8221;<br />
send &#8212; &#8220;sudo -k; sudo su &#8211; mysql\r&#8221;<br />
expect -exact &#8220;sudo -k; sudo su &#8211; mysql&#8221;<br />
expect -exact &#8220;assword:&#8221;<br />
send &#8212; &#8220;password\r&#8221;<br />
interact</p></blockquote>
<p># you should change the word password in &#8217;send &#8212; &#8220;password\r&#8221;&#8216; to your login password<br />
# if you have the same password for each environment you could also script logging into mysql directly from the same expect script BUT that is not recommended.</p>
<p>Create a bash script:<br />
/path/to/login.sh</p>
<blockquote><p>#!/bin/bash<br />
#script by darren cassar<br />
#mysqlpreacher.com</p>
<p>sm=&#8217;/path/to/sshmysql.exp&#8217;</p>
<p>menu() {<br />
  echo &#8221; 101 &#8211; dev.databaseserver1 &#8221;<br />
  echo &#8221; 102 &#8211; dev.databaseserver2 &#8221;<br />
  echo &#8221; 103 &#8211; dev.databaseserver3 &#8221;<br />
  echo &#8221; 201 &#8211; qa.databaseserver1 &#8221;<br />
  echo &#8221; 301 &#8211; uat.databaseserver1 &#8221;<br />
  echo &#8221; 302 &#8211; uat.databaseserver2 &#8221;<br />
  echo &#8221; 401 &#8211; prod.databaseserver1 &#8221;<br />
  echo &#8221; &#8221;<br />
}</p>
<p>ARGUMENT=notmenu</p>
<p>if [ -z "$1" ]<br />
  then<br />
    ARGUMENT=menu<br />
else<br />
  choice=$1<br />
fi</p>
<p>if [ $ARGUMENT = "menu" ]<br />
  then<br />
    menu<br />
else<br />
  case &#8220;$choice&#8221; in<br />
  101|dev.databaseserver1   ) $sm dev.databaseserver1;;<br />
  102|dev.databaseserver2   ) $sm dev.databaseserver2;;<br />
  103|dev.databaseserver3   ) $sm dev.databaseserver3;;<br />
  201|qa.databaseserver1   ) $sm qa.databaseserver1;;<br />
  301|uat.databaseserver1   ) $sm uat.databaseserver1;;<br />
  302|uat.databaseserver2   ) $sm uat.databaseserver2;;<br />
  401|prod.databaseserver1   ) $sm prod.databaseserver1;;<br />
  *        ) echo &#8220;Wrong value passed to script&#8221;<br />
             menu ;;<br />
  esac<br />
fi</p></blockquote>
<blockquote><p>alias l=&#8217;/path/to/login.sh&#8217;</p></blockquote>
<p>Output: </p>
<blockquote><p>[darrencassar@mymachine ~ ]$ l<br />
 101 &#8211; dev.databaseserver1<br />
 102 &#8211; dev.databaseserver2<br />
 103 &#8211; dev.databaseserver3<br />
 201 &#8211; qa.databaseserver1<br />
 301 &#8211; uat.databaseserver1<br />
 302 &#8211; uat.databaseserver2<br />
 401 &#8211; prod.databaseserver1</p></blockquote>
<p>Output:<br />
The below command would log you into the first development database server as mysql user.</p>
<blockquote><p>[darrencassar@mymachine ~ ]$ l 101 </p></blockquote>
<p>On each machine place aliases for each instance in the .profile</p>
<blockquote><p>alias use3306=&#8217;mysql -u root -p -h 127.0.0.1 -P 3306 &#8211;prompt=&#8221;mysql \D> &#8220;&#8216;</p></blockquote>
<p>The above setup can be used using any client/server OS: Linux, Solaris, MAC OS or Windows(running Cygwin)</p>
<p><strong>NOTE: If you store the password in clear text inside the expect script, you should at least save the scripts inside an encrypted partition on your machine and make sure that folder is not shared or accessible by anyone. Another way of doing it would be to use either SSHKeys OR save the password inside a file and encrypt it using <a href="http://www.madboa.com/geek/openssl/#encrypt-simple" target="_blank">OpenSSL</a></strong></p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://mysqlpreacher.com/wordpress/2010/02/automating-mysql-access-with-expect-and-bash-scripting/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MySQL vs InfoBright optimizer battle</title>
		<link>http://mysqlpreacher.com/wordpress/2009/12/mysql-vs-infobright-optimizer-battle/</link>
		<comments>http://mysqlpreacher.com/wordpress/2009/12/mysql-vs-infobright-optimizer-battle/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 17:33:36 +0000</pubDate>
		<dc:creator>Darren Cassar</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[infobright]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[optimiser]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://mysqlpreacher.com/wordpress/?p=302</guid>
		<description><![CDATA[MySQL instance running an Infobright engine

mysql> explain SELECT COUNT(ac.UID) FROM ACTIVE ac JOIN ALL a;
+----+-------------+-------+------+---------------+------+---------+------+---------+-------+
&#124; id &#124; select_type &#124; table &#124; type &#124; possible_keys &#124; key  &#124; key_len &#124; ref  &#124; rows    &#124; Extra &#124;
+----+-------------+-------+------+---------------+------+---------+------+---------+-------+
&#124;  1 &#124; SIMPLE      &#124; ac    &#124; [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL instance running an Infobright engine</p>
<blockquote><p><code lang="sql"><br />
mysql> explain SELECT COUNT(ac.UID) FROM ACTIVE ac JOIN ALL a;<br />
+----+-------------+-------+------+---------------+------+---------+------+---------+-------+<br />
| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows    | Extra |<br />
+----+-------------+-------+------+---------------+------+---------+------+---------+-------+<br />
|  1 | SIMPLE      | ac    | ALL  | NULL          | NULL | NULL    | NULL |  124426 |       |<br />
|  1 | SIMPLE      | a     | ALL  | NULL          | NULL | NULL    | NULL | 7594256 |       |<br />
+----+-------------+-------+------+---------------+------+---------+------+---------+-------+<br />
2 rows in set (0.01 sec)</p>
<p>mysql> SELECT COUNT(ac.UID) FROM ACTIVE ac JOIN ALL a ON ac.UID=a.UID;<br />
+---------------+<br />
| COUNT(ac.UID) |<br />
+---------------+<br />
|         17466 |<br />
+---------------+<br />
1 row in set (0.23 sec)</p>
<p>mysql> set @tot = (SELECT COUNT(ac.UID) FROM ACTIVE ac JOIN ALL a ON ac.UID=a.UID); </p>
<p>^CQuery aborted by Ctrl+C<br />
</code></p></blockquote>
<p>Took more than 60seconds &#8212;- what the &#8230;..<br />
Why did it take a long?</p>
<blockquote><p><code lang="sql"><br />
mysql> set @a=2;<br />
Query OK, 0 rows affected (0.00 sec)</p>
<p>mysql> select @a;<br />
+------+<br />
| @a   |<br />
+------+<br />
| 2    |<br />
+------+<br />
1 row in set (0.00 sec)</p>
<p>mysql> set @tot = (SELECT COUNT(*) FROM ACTIVE);<br />
Query OK, 0 rows affected (0.13 sec)</p>
<p>mysql> select @tot;<br />
+--------+<br />
| @tot   |<br />
+--------+<br />
| 124426 |<br />
+--------+<br />
1 row in set (0.00 sec)</p>
<p>mysql> set @tot = (SELECT COUNT(ac.UID) FROM ACTIVE ac);<br />
Query OK, 0 rows affected (0.22 sec)</p>
<p>mysql> select @tot;<br />
+--------+<br />
| @tot   |<br />
+--------+<br />
| 124426 |<br />
+--------+<br />
1 row in set (0.00 sec)</p>
<p>mysql> SELECT COUNT(ac.UID) FROM ACTIVE ac, ALL a;<br />
+---------------+<br />
| COUNT(ac.UID) |<br />
+---------------+<br />
|  944922897056 |<br />
+---------------+<br />
1 row in set (0.05 sec)</p>
<p>mysql> set @tot=(SELECT COUNT(ac.UID) FROM ACTIVE ac JOIN ALL a);<br />
^CQuery aborted by Ctrl+C<br />
ERROR 1317 (70100): Query execution was interrupted<br />
</code></p></blockquote>
<p>Reason? &#8230;. the query is using the MySQL optimiser rather than the IB one! Why? good question (will have to ask IB devs though).</p>
<p>Work around, use ac temporary table to store the result and setting the variable to the result field, but it&#8217;s really ugly isn&#8217;t it?</p>
]]></content:encoded>
			<wfw:commentRss>http://mysqlpreacher.com/wordpress/2009/12/mysql-vs-infobright-optimizer-battle/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Once upon a timestamp(milliseconds)&#8230;.</title>
		<link>http://mysqlpreacher.com/wordpress/2009/08/once-upon-a-timestampmilliseconds/</link>
		<comments>http://mysqlpreacher.com/wordpress/2009/08/once-upon-a-timestampmilliseconds/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 12:53:49 +0000</pubDate>
		<dc:creator>Darren Cassar</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[microsecond]]></category>
		<category><![CDATA[millisecond]]></category>
		<category><![CDATA[timestamp]]></category>

		<guid isPermaLink="false">http://mysqlpreacher.com/wordpress/?p=234</guid>
		<description><![CDATA[Once upon a time`stamp`, in a `data`base far far away, someone filed a bug named: `Microseconds precision is not retained by TIME, DATETIME, and TIMESTAMP field types.` - Bug Number 8523. This was the beginning of 2005, yet now that we are approaching the end of 2009, after 4.5 years, many (including myself) are still asking for this.]]></description>
			<content:encoded><![CDATA[<p>Once upon a time`stamp`, in a `data`base far far away, someone filed a bug named: `Microseconds precision is not retained by TIME, DATETIME, and TIMESTAMP field types.` &#8211; Bug Number 8523. This was the beginning of 2005, yet now that we are approaching the end of 2009, after 4.5 years, many (including myself) are still asking for this.</p>
<p>In fairness sake, MySQL have indeed supplied a way to retain milli and micro seconds in a decimal field `DECIMAL(17,3)`, and it is also queryable as if it were a timestamp BUT why isn&#8217;t it possible to store in a `DATETIME` or `TIMESTAMP` field? Why can&#8217;t we run a &#8217;select now()&#8217; or &#8217;select curtime()&#8217; etc and get a full timestamp including milli / micro seconds?</p>
<p>I have counted 37 different usernames asking for this feature, spanning from 15th Feb 2005 to recently. (list found below)</p>
<p>Some have suggested UDFs, others suggested using log4j while others, pretty annoyed, allegedly went to MS SQL and some to Postgres :). The comments were varied but one thing was quite common &#8230; a feeling of frustration and or disappointment, probably because despite all the requests for the feature in question to be implemented, it is still missing.</p>
<p>Back in 2007, <a href="http://feedblog.org" target="_blank"> Kevin Burton </a> also tried to understand why MySQL doesn&#8217;t support milliseconds <a href="http://feedblog.org/2007/05/26/why-doesnt-mysql-support-millisecond-datetime-resolution/" target="_blank">here</a>. <a href="http://krow.net/" target="_blank">Brian Aker </a>gave his view on the matter (back in 2007) in the first comment on the same blog post.</p>
<p>My point is (yeah about time :)) &#8230;. this is quite an important feature!! and I&#8217;m hoping a few MySQL developers / project managers / community people might read this blog post and maybe give it some more importance.</p>
<p>Now from the technical side, I am going to describing a way, `someone from MySQL has suggested it to me this week` to store milli and micro seconds. Maybe it&#8217;ll help you work your milliseconds requirement out (or maybe not). As to the way to generate milli and micro seconds, there is a UDF written by Mr Wadimoff <a href="http://bugs.mysql.com/bug.php?id=8523" target="_blank">here</a> which you might use.</p>
<p>Storing:</p>
<blockquote><p><code lang="sql"><br />
mysql> create table ttable<br />
    -> (<br />
    ->    timecol decimal(17,3)<br />
    -> ) Engine=MyISAM;<br />
Query OK, 0 rows affected (0.04 sec)</p>
<p>mysql> insert into ttable (timecol) values( 20081223094234.572);<br />
Query OK, 1 row affected (0.00 sec)</p>
<p>mysql> insert into ttable (timecol) values( 20090806133004.132);<br />
Query OK, 1 row affected (0.00 sec)</p>
<p>mysql> insert into ttable (timecol) values( 20100411011258.985);<br />
Query OK, 1 row affected (0.00 sec)</p>
<p>mysql> insert into ttable (timecol) values( 20110411011258.985);<br />
Query OK, 1 row affected (0.00 sec)</p>
<p>mysql> select timestamp(timecol) from ttable;<br />
+----------------------------+<br />
| timestamp(timecol)         |<br />
+----------------------------+<br />
| 2008-12-23 09:42:34.572000 |<br />
| 2009-08-06 13:30:04.132000 |<br />
| 2010-04-11 01:12:58.985000 |<br />
| 2011-04-11 01:12:58.985000 |<br />
+----------------------------+<br />
4 rows in set (0.00 sec)</p>
<p>mysql> select timecol from ttable where timecol < "20090901000000";<br />
+--------------------+<br />
| timecol            |<br />
+--------------------+<br />
| 20081223094234.572 |<br />
| 20090806133004.132 |<br />
+--------------------+<br />
2 rows in set (0.00 sec)</p>
<p>mysql> select timecol from ttable where timecol > "20090901000000";<br />
+--------------------+<br />
| timecol            |<br />
+--------------------+<br />
| 20100411011258.985 |<br />
| 20110411011258.985 |<br />
+--------------------+<br />
2 rows in set (0.00 sec)</p>
<p>mysql> select timecol from ttable where timecol > now();<br />
+--------------------+<br />
| timecol            |<br />
+--------------------+<br />
| 20100411011258.985 |<br />
| 20110411011258.985 |<br />
+--------------------+<br />
2 rows in set (0.00 sec)</p>
<p>mysql> select datediff(20110411011258.985,20100411011258.985);<br />
+-------------------------------------------------+<br />
| datediff(20110411011258.985,20100411011258.985) |<br />
+-------------------------------------------------+<br />
|                                             365 |<br />
+-------------------------------------------------+<br />
1 row in set (0.00 sec)</p>
<p>mysql> select timecol, timestamp(timecol) as timestamp ,year(timecol) as year, month(timecol) as month, day(timecol) as day,quarter(timecol) as quarter from ttable;<br />
+--------------------+----------------------------+------+-------+------+---------+<br />
| timecol            | timestamp                  | year | month | day  | quarter |<br />
+--------------------+----------------------------+------+-------+------+---------+<br />
| 20081223094234.572 | 2008-12-23 09:42:34.572000 | 2008 |    12 |   23 |       4 |<br />
| 20090806133004.132 | 2009-08-06 13:30:04.132000 | 2009 |     8 |    6 |       3 |<br />
| 20100411011258.985 | 2010-04-11 01:12:58.985000 | 2010 |     4 |   11 |       2 |<br />
| 20110411011258.985 | 2011-04-11 01:12:58.985000 | 2011 |     4 |   11 |       2 |<br />
+--------------------+----------------------------+------+-------+------+---------+<br />
4 rows in set (0.00 sec)</p>
<p></code></p></blockquote>
<p>Bug link: <a href="http://bugs.mysql.com/bug.php?id=8523" target="_blank">http://bugs.mysql.com/bug.php?id=8523<br />
</a></p>
<blockquote><p>
<strong>List of people asking for this feature:</strong></p>
<p>[15 Feb 2005 21:47] Christopher Miller<br />
[03 May 2005 19:46] Boris Burtin<br />
[30 Jun 2005 10:52] Yoshiaki Tajika<br />
[06 Mar 2006 22:14] Tim Sheehy<br />
[14 Mar 2006 21:50] Oriol Garrote<br />
[17 Aug 2006 22:15] Sami Shalabi<br />
[01 Apr 2007 05:22] Ben Valentine<br />
[02 Apr 2007 23:25] Eric George<br />
[27 Apr 2007 06:10] Verghese Mappillai<br />
[23 May 2007 20:47] Andrew McLaughlin<br />
[25 May 2007 18:24] Stephen Pietrowicz<br />
[31 May 2007 10:51] harjeev chug<br />
[22 Jun 2007 01:17] Peter McCulloch<br />
[20 Jul 2007 16:42] Daren Schwenke<br />
[03 Aug 2007 04:45] Jean-Guy Mossu<br />
[20 Feb 2008 09:32] bodri bodri<br />
[11 Mar 2008 20:12] Nathan Atkinson<br />
[24 Mar 2008 08:35] Sourav Sipani<br />
[02 Jul 2008 05:03] Michael Haselton<br />
[22 Aug 2008 10:32] Aniruddha Shival<br />
[28 Aug 2008 17:37] Jorge Urdaneta<br />
[29 Aug 2008 22:19] Ben Wern<br />
[05 Sep 2008 10:41] Pavel Alexeev<br />
[19 Dec 2008 14:31] Felix Dierich<br />
[09 Feb 2009 07:58] Gabriele Tozzi<br />
[17 Feb 2009 23:20] Paul Craven<br />
[21 Feb 2009 12:55] Thomas Ene<br />
[27 Feb 2009 12:13] Pascal Calovini<br />
[09 Mar 2009 09:03] Siu Ching Pong (Asuka Kenji)<br />
[12 Mar 2009 19:41] Yu Chen<br />
[02 Apr 2009 02:35] Noel Akins<br />
[02 Apr 2009 13:09] Lars Monsees<br />
[19 Apr 2009 17:30] Ryan Shillington<br />
[22 Apr 2009 09:00] Jeff Peff<br />
[04 May 2009 09:30] alastair knowles<br />
[28 May 2009 11:42] Yuri Kirilin<br />
[31 May 2009 04:37] Peter Thairu
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://mysqlpreacher.com/wordpress/2009/08/once-upon-a-timestampmilliseconds/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Security &#8211; Roles and Password Expiry on MySQL using SECURICH</title>
		<link>http://mysqlpreacher.com/wordpress/2009/06/security-roles-and-password-expiry-on-mysql-using-securich/</link>
		<comments>http://mysqlpreacher.com/wordpress/2009/06/security-roles-and-password-expiry-on-mysql-using-securich/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 09:23:56 +0000</pubDate>
		<dc:creator>Darren Cassar</dc:creator>
				<category><![CDATA[Advanced]]></category>
		<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[groups]]></category>
		<category><![CDATA[password expiry]]></category>
		<category><![CDATA[password history]]></category>
		<category><![CDATA[roles]]></category>
		<category><![CDATA[securich]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://mysqlpreacher.com/wordpress/?p=182</guid>
		<description><![CDATA[Lately there has been quite some talk about security on MySQL, and I've decided to GPL a package I wrote, implmenting Roles on MySQL.
This technology has been available on other databases for quite some time, but hasn't quite yet made it to MySQL's feature list and apart from this tool, the only solution I know of is google's patches for MySQL 5.0.
]]></description>
			<content:encoded><![CDATA[<p>Lately there has been quite some talk about security on MySQL, and I&#8217;ve decided to GPL a package I wrote, implmenting Roles on MySQL.<br />
This technology has been available on other databases for quite some time, but hasn&#8217;t quite yet made it to MySQL&#8217;s feature list and apart from this tool, the only solution I know of is google&#8217;s patches for MySQL 5.0.</p>
<p>The name is SECURICH and downloads as well as documentation are available at <a href="http://www.securich.com/">http://www.securich.com/</a>. The bug list is available at <a href="http://www.securich.com/mantis/">http://www.securich.com/mantis/</a> (you&#8217;ll have to register and log in first). Privileges can be granted on a database or table level with a few combinations like:<br />
	1. database as one,<br />
	2. all tables in database (useful when you need to grant a bunch of privileges to all tables but a few thus revoking the few later),<br />
	3. single tables,<br />
	4. stored procedure or<br />
	5. tables through the use of regular expression.</p>
<p>The user has the facility to create a role and update it on the fly thus propagating the changes onto already existing users having the role in question. There are also loads of other functionalities available and I urge you to check the documentation on <a href="http://www.securich.com/">http://www.securich.com/</a>.</p>
<p>A cool feature I like is password history which enables dbas to enforce changing of passwords after a certain period of time. </p>
<p>#################################################################################################################################################<br />
## PLEASE NOTE THAT:<br />
## 1. THIS IS AN ALPHA VERSION,<br />
## 2. YOU SHOULD NOT INSTALL THIS PACKAGE ON A PRE-EXISTING MYSQL WHICH ALREADY HAS PRIVILEGES SET UP.<br />
#################################################################################################################################################<br />
##<br />
## This tool will modify current privileges on the &#8220;mysql&#8221; database tables and should only be used with freshly installed mysqls.<br />
##<br />
##################################################################################################################################################</p>
<p>Features like block user and unblock user as well as many other functionalities are being developed and more features will be added as time goes by.</p>
<p>I would greatly appreciate your feedback about what you think of the package, features you might wish to include etc (feature requests should be done through <a href="http://www.securich.com/mantis/">http://www.securich.com/mantis/</a> as well.)</p>
]]></content:encoded>
			<wfw:commentRss>http://mysqlpreacher.com/wordpress/2009/06/security-roles-and-password-expiry-on-mysql-using-securich/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Replicating from MySQL to *</title>
		<link>http://mysqlpreacher.com/wordpress/2009/05/replicating-from-mysql-to/</link>
		<comments>http://mysqlpreacher.com/wordpress/2009/05/replicating-from-mysql-to/#comments</comments>
		<pubDate>Fri, 29 May 2009 16:28:28 +0000</pubDate>
		<dc:creator>Darren Cassar</dc:creator>
				<category><![CDATA[Advanced]]></category>
		<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[mysqlbinlog]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[replication]]></category>
		<category><![CDATA[row based replication]]></category>
		<category><![CDATA[statement based replication]]></category>

		<guid isPermaLink="false">http://mysqlpreacher.com/wordpress/?p=175</guid>
		<description><![CDATA[Recently I needed to replicate between MySQL and another database technology. You might say, why on earth would you want to do something like that, but believe me there are reasons and definitely not (to go away from MySQL to some other DB technology like Oracle or SQL server). Unsurprisingly there are quite a few different tools to do it from any platform towards MySQL but very few which do it the other way round, just to name a couple: Golden Gate and DSCallards.]]></description>
			<content:encoded><![CDATA[<p><strong>Obtaining ansi SQL from RBR.</strong></p>
<p>Recently I needed to replicate between MySQL and another database technology. You might say, why on earth would you want to do something like that, but believe me there are reasons and definitely not (to go away from MySQL to some other DB technology like Oracle or SQL server). Unsurprisingly there are quite a few different tools to do it from any platform towards MySQL but very few which do it the other way round, just to name a couple: Golden Gate and DSCallards.</p>
<p>Whilst not going into their tools (you can find more information on their websites), HIT from DSCallards needs its software to run on Windows and Golden Gate is an expensive beast which was too much for what I needed, thus I decided to have a look at doing the job myself. Although it might look an overkill to do so, it took me a few hours to find a solution and implement it and a couple more to test it and here is a simple description.</p>
<p>MySQL replication can be SBR (statement based), RBR (row based) or a mixture of both. Now despite the fact that the mixture provides the best performance, it would be the most complicated in order to achieve a home made solution, and SBR in my opinion would have also been a bit of a headache to make sure queries didn&#8217;t contain non ansi sql through the use of functions like now(), sysdate() and many others. I therefore decided that RBR would be the option of choice.</p>
<p>Although I wonder how many of you ever read an RBR binlog using `mysqlbinlog mysql-bin.000004`, it would be something like:</p>
<blockquote><p>
#090526 14:09:13 server id 1  end_log_pos 1420  Query   thread_id=192   exec_time=0     error_code=0<br />
SET TIMESTAMP=1243343353/*!*/;<br />
BEGIN<br />
/*!*/;<br />
# at 1420<br />
# at 1464<br />
#090526 14:09:13 server id 1  end_log_pos 1464  Table_map: `test`.`t2` mapped to number 21<br />
#090526 14:09:13 server id 1  end_log_pos 1498  Write_rows: table id 21 flags: STMT_END_F</p>
<p>BINLOG &#8216;<br />
+ekbShMBAAAALAAAALgFAAAAABUAAAAAAAAABHRlc3QAAnQyAAID/gL+AQM=<br />
+ekbShcBAAAAIgAAANoFAAAQABUAAAAAAAEAAv/+AQAAAA==<br />
&#8216;/*!*/;<br />
# at 1498<br />
#090526 14:09:13 server id 1  end_log_pos 1567  Query   thread_id=192   exec_time=0     error_code=0<br />
SET TIMESTAMP=1243343353/*!*/;<br />
COMMIT<br />
/*!*/;<br />
# at 1567<br />
#090526 14:09:38 server id 1  end_log_pos 1635  Query   thread_id=192   exec_time=0     error_code=0<br />
SET TIMESTAMP=1243343378/*!*/;<br />
BEGIN<br />
/*!*/;<br />
# at 1635<br />
# at 1679<br />
#090526 14:09:38 server id 1  end_log_pos 1679  Table_map: `test`.`t2` mapped to number 21<br />
#090526 14:09:38 server id 1  end_log_pos 1733  Update_rows: table id 21 flags: STMT_END_F</p>
<p>BINLOG &#8216;<br />
EuobShMBAAAALAAAAI8GAAAAABUAAAAAAAAABHRlc3QAAnQyAAID/gL+AQM=<br />
EuobShgBAAAANgAAAMUGAAAQABUAAAAAAAEAAv///AQAAAABZPwCAAAAAWT+AQAAAP4CAAAA<br />
&#8216;/*!*/;<br />
# at 1733<br />
#090526 14:09:38 server id 1  end_log_pos 1802  Query   thread_id=192   exec_time=0     error_code=0<br />
SET TIMESTAMP=1243343378/*!*/;<br />
COMMIT
</p></blockquote>
<p>Now that isn&#8217;t the most readable text you ever seen right? As Giuseppe said &#8220;This is more difficult to read than ancient Etruscan. If you are a DBA, you curse and look for help.&#8221; But the replication guys at mysql created a nice -v for us to add to mysqlbinlog thus issuing `mysqlbinlog -v mysql-bin.000004` would result in the following:</p>
<blockquote><p>
#090526 14:09:13 server id 1  end_log_pos 1420  Query   thread_id=192   exec_time=0     error_code=0<br />
SET TIMESTAMP=1243343353/*!*/;<br />
BEGIN<br />
/*!*/;<br />
# at 1420<br />
# at 1464<br />
#090526 14:09:13 server id 1  end_log_pos 1464  Table_map: `test`.`t2` mapped to number 21<br />
#090526 14:09:13 server id 1  end_log_pos 1498  Write_rows: table id 21 flags: STMT_END_F</p>
<p>BINLOG &#8216;<br />
+ekbShMBAAAALAAAALgFAAAAABUAAAAAAAAABHRlc3QAAnQyAAID/gL+AQM=<br />
+ekbShcBAAAAIgAAANoFAAAQABUAAAAAAAEAAv/+AQAAAA==<br />
&#8216;/*!*/;<br />
### INSERT INTO test.t2<br />
### SET<br />
###   @1=1<br />
###   @2=NULL<br />
# at 1498<br />
#090526 14:09:13 server id 1  end_log_pos 1567  Query   thread_id=192   exec_time=0     error_code=0<br />
SET TIMESTAMP=1243343353/*!*/;<br />
COMMIT<br />
/*!*/;<br />
# at 1567<br />
#090526 14:09:38 server id 1  end_log_pos 1635  Query   thread_id=192   exec_time=0     error_code=0<br />
SET TIMESTAMP=1243343378/*!*/;<br />
BEGIN<br />
/*!*/;<br />
# at 1635<br />
# at 1679<br />
#090526 14:09:38 server id 1  end_log_pos 1679  Table_map: `test`.`t2` mapped to number 21<br />
#090526 14:09:38 server id 1  end_log_pos 1733  Update_rows: table id 21 flags: STMT_END_F</p>
<p>BINLOG &#8216;<br />
EuobShMBAAAALAAAAI8GAAAAABUAAAAAAAAABHRlc3QAAnQyAAID/gL+AQM=<br />
EuobShgBAAAANgAAAMUGAAAQABUAAAAAAAEAAv///AQAAAABZPwCAAAAAWT+AQAAAP4CAAAA<br />
&#8216;/*!*/;<br />
### UPDATE test.t2<br />
### WHERE<br />
###   @1=4<br />
###   @2=&#8217;d&#8217;<br />
### SET<br />
###   @1=2<br />
###   @2=&#8217;d&#8217;<br />
### UPDATE test.t2<br />
### WHERE<br />
###   @1=1<br />
###   @2=NULL<br />
### SET<br />
###   @1=2<br />
###   @2=NULL<br />
# at 1733<br />
#090526 14:09:38 server id 1  end_log_pos 1802  Query   thread_id=192   exec_time=0     error_code=0<br />
SET TIMESTAMP=1243343378/*!*/;<br />
COMMIT
</p></blockquote>
<p>The exact same output with some decently readable output. The problem at this point is that the output is not really something any other technology would undestand (not even feeding it to MySQL would work! &#8230;.</p>
<p>At this point I needed to do some compromises in order to reduce the complexity of this job, i.e. I will not be creating and altering tables / databases or indexes during runtime (this I can do without as I can do the same things on the slave manually when I need to do anything like that on the master) and the replication won&#8217;t be in real time i.e. the slave will be fed the sql periodically through a script. The last compromise wasn&#8217;t actually a compromise but a decision based on speed of coding as I&#8217;m more proficient in bash than perl and as such I decided to go with bash as a proof of concept that this thing can be done. This would never happen in reality as it would be much slower as compared to coding the same thing in perl or C / C++ (choice is up to you).</p>
<p>Now parsing the binary logs is not rocket science is it? As you can see there are three hashes &#8216;###&#8217; in front of the readable query so a simple grep is fine. A few subsitutions and text processing and you&#8217;ll end up with:</p>
<blockquote><p>
darrencassar@mysqlpreacher $ /home/dcassar/sandbox/5.1.30/bin/mysqlbinlog  | sed &#8217;s/^ *//g&#8217; | tr &#8216;\015\012&#8242; &#8216;\020 &#8216; | sed &#8217;s/ INSERT/;\nINSERT/g&#8217; | sed &#8217;s/ DELETE/;\nDELETE/g&#8217; | sed &#8217;s/ UPDATE/;\nUPDATE/g&#8217; | sed &#8216;${/^$/!s/$/;\<br />
&gt; /;}&#8217;<br />
INSERT INTO test.t1 SET @1=1 @2=&#8217;a';<br />
DELETE FROM test.t1 WHERE @1=1 @2=&#8217;a';<br />
INSERT INTO test.t2 SET @1=2 @2=&#8217;d';<br />
UPDATE test.t2 WHERE @1=2 @2=&#8217;d&#8217; SET @1=4 @2=&#8217;d';<br />
INSERT INTO test.t2 SET @1=1 @2=NULL;<br />
UPDATE test.t2 WHERE @1=4 @2=&#8217;d&#8217; SET @1=2 @2=&#8217;d';<br />
UPDATE test.t2 WHERE @1=1 @2=NULL SET @1=2 @2=NULL ;<br />
darrencassar@mysqlpreacher $
</p></blockquote>
<p>That is more readable but still not correctly formatted for our ANSI SQL slave.</p>
<blockquote><p>
`INSERT INTO test.t1 SET @1=1 @2=&#8217;a';` would need to be replaced with `INSERT INTO test.t1 (cola, colb) values(1,&#8217;a');` or `INSERT INTO test.t1 values(1,&#8217;a');`,<br />
`DELETE FROM test.t1 WHERE @1=1 @2=&#8217;a';` would need to be replaced with `DELETE FROM test.t1 WHERE cola=1 AND colb=&#8217;a';` and<br />
`UPDATE test.t2 WHERE @1=2 @2=&#8217;d&#8217; SET @1=4 @2=&#8217;d';` would have to become `UPDATE test.t2 SET cola=4 , colb=&#8217;d&#8217; WHERE cola=2 AND colb=&#8217;d';`
</p></blockquote>
<p>The above means we need to replace @1 and @2 with the appropriate column names done using a lookup table in my case by placing a files in data/dbname each bearing names of the different tables and listing each column in order:<br />
I.E. for a database named test and table named table1 having columns cola and colb I used the database folder named test in the mysql data folder and placed a file named table1, the contents of which were:</p>
<blockquote><p>cola<br />
colb</p></blockquote>
<p>The following piece of code does the job of replacing those dreadful @1, @2 etc with proper table names:</p>
<blockquote><p>
for (( i=1; i&lt;=`wc -l $dbname/$tbname | cut -d &#8221; &#8221; -f 1`; i++ ))<br />
do<br />
columnname=`awk &#8216;NR==a&#8217; a=$i $dbname/$tbname`<br />
LINE_TEMP=`echo $LINE_TEMP | sed &#8217;s/@&#8217;$i&#8217;=/AND &#8216;$columnname&#8217;=/g&#8217; | sed &#8217;s/SET AND/SET/g&#8217; | sed &#8217;s/WHERE AND/WHERE/g&#8217;`<br />
done
</p></blockquote>
<p>If you were thinking how I extracted dbname and tbname, here it is:</p>
<blockquote><p>
dbname=`echo $LINE | cut -d &#8221; &#8221; -f$col | cut -d &#8220;.&#8221; -f 1`<br />
tbname=`echo $LINE | cut -d &#8221; &#8221; -f$col | cut -d &#8220;.&#8221; -f 2`
</p></blockquote>
<p>where $LINE is each line extracted using the first command parsing mysqlbinary output and the variable col is 3 for delete and 2 for update which reflects the positioning of the database name and table name inside the extracted lines.</p>
<p>A rather ugly way of re-ordering the update command yet functional is:</p>
<blockquote><p>
echo $LINE_TEMP | cut -d &#8220;.&#8221; -f2 | sed &#8217;s/&#8217;$tbname&#8217; //&#8217; | sed &#8217;s/;//&#8217; &gt; templinefile<br />
cat templinefile | sed &#8217;s/ SET /\nSET /g&#8217; &gt; templinefile2<br />
LINE_TEMP=&#8221;UPDATE $dbname.$tbname `tail -1 templinefile2  | sed &#8217;s/ is NULL/=NULL/g&#8217; | sed &#8217;s/AND/,/g&#8217;` `head -1 templinefile2`;&#8221;
</p></blockquote>
<p>The last thing to remember is taking care of `=NULL` and replace it by `is NULL`.</p>
<blockquote><p>
LINE_TEMP=`echo $LINE_TEMP | sed &#8217;s/=NULL/ is NULL/g&#8217;`
</p></blockquote>
<p>As I said this was a fast proof of concept rather than a full fledged optimized script doing the job! The total length of code is 37 lines (excluding comments but with correct and nead formatting).</p>
<p>Enjoy<br />
Darren</p>
]]></content:encoded>
			<wfw:commentRss>http://mysqlpreacher.com/wordpress/2009/05/replicating-from-mysql-to/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MCDBA Certification &#8211; KPIs</title>
		<link>http://mysqlpreacher.com/wordpress/2009/03/mcdba-certification-kpis/</link>
		<comments>http://mysqlpreacher.com/wordpress/2009/03/mcdba-certification-kpis/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 16:15:58 +0000</pubDate>
		<dc:creator>Darren Cassar</dc:creator>
				<category><![CDATA[Advanced]]></category>
		<category><![CDATA[Beginner]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[certification]]></category>
		<category><![CDATA[exam]]></category>
		<category><![CDATA[kpis]]></category>
		<category><![CDATA[MCDBA]]></category>
		<category><![CDATA[MySQL certified dba]]></category>
		<category><![CDATA[statistics]]></category>

		<guid isPermaLink="false">http://mysqlpreacher.com/wordpress/?p=128</guid>
		<description><![CDATA[A few interesting KPIs about certified people and their current location (the fact that many people travel from one country to the other for work is very popular these days especially in the IT sector):
Before starting to read, I am hereby assuming the MySQL list of MCDBAs is on a residence basis not citizenship.
There are [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">A few interesting KPIs about certified people and their current location (the fact that many people travel from one country to the other for work is very popular these days especially in the IT sector):</p>
<p style="text-align: left;">Before starting to read, I am hereby assuming the MySQL list of MCDBAs is on a residence basis not citizenship.</p>
<p style="text-align: left;">There are at the time of this writing a total of 796 MCDBAs in the world, living in 57 countries.</p>
<p style="text-align: left;">When analyzing the number of MCDBAs / country, it is pretty obvious the scene is totally dominated by the US:</p>
<p style="text-align: left;"><a href="http://mysqlpreacher.com/wordpress/wp-content/uploads/2009/03/no_country1.jpg"><img class="size-full wp-image-138 aligncenter" title="MCDBA Certification KPIs / Country" src="http://mysqlpreacher.com/wordpress/wp-content/uploads/2009/03/no_country1.jpg" alt="" width="500" height="414" /></a></p>
<p><code>+----------------------+-------------+</code><br />
<code>| Country              | No of Certs |</code><br />
<code>+----------------------+-------------+</code><br />
<code>| UnitedStates         |         346 | </code><br />
<code>| Unitedkingdom        |          47 | </code><br />
<code>| Germany              |          46 | </code><br />
<code>| India                |          34 | <br />
| Italy                |          28 | <br />
| Japan                |          26 | <br />
| Canada               |          23 | <br />
| China                |          20 | <br />
| Brazil               |          18 | <br />
| Australia            |          16 | <br />
| France               |          16 | <br />
| Netherlands          |          13 | <br />
| Switzerland          |          13 | <br />
| SouthKorea           |          12 | <br />
| Spain                |          11 | <br />
| HongKong             |          10 | <br />
| Sweden               |          10 | <br />
| SouthAfrica          |          10 | <br />
| Singapore            |           9 | <br />
| Taiwan               |           8 | <br />
| Poland               |           7 | <br />
| Philippines          |           6 | <br />
| Norway               |           5 | <br />
| Russia               |           5 | <br />
| Finland              |           5 | <br />
| Ireland              |           4 | <br />
| Israel               |           3 | <br />
| Srilanka             |           3 | <br />
| Ukraine              |           3 | <br />
| Austria              |           3 | <br />
| Belgium              |           3 | <br />
| Denmark              |           2 | <br />
| Egypt                |           2 | <br />
| Mexico               |           2 | <br />
| Malta                |           2 | <br />
| Thailand             |           2 | <br />
| Unitedarabemirates   |           2 | <br />
| Latvia               |           2 | <br />
| Bangladesh           |           1 | <br />
| Croatia              |           1 | <br />
| TrinidadandTobago    |           1 | <br />
| BosniaandHerzegovina |           1 | <br />
| Malaysia             |           1 | <br />
| Slovenia             |           1 | <br />
| SaudiArabia          |           1 | <br />
| Indonesia            |           1 | <br />
| Jordan               |           1 | <br />
| Kenya                |           1 | <br />
| Lithuania            |           1 | <br />
| Luxembourg           |           1 | <br />
| Guatemala            |           1 | <br />
| Nepal                |           1 | <br />
| Gibraltar            |           1 | <br />
| Newzealand           |           1 | <br />
| Pakistan             |           1 | <br />
| Portugal             |           1 | <br />
| Virginislands        |           1 | <br />
<code>+----------------------+-------------+ <br />
</code></code></p>
<p><code> </code></p>
<p><code></p>
<p style="text-align: left;">But what happens when we look at the number of MCDBAS in respect to population / area?</p>
<p style="text-align: left;">The country with largest certs / capita is Gibralter with a MySQL Certified DBA in 31k population, followed by Virgin Islands at 1 for 110k and Malta at 2 / 412.6k.</p>
<p style="text-align: left;">The country with least certs / capita is Indonesia with a single MySQL Certified DBA out of almost 230M people.</p>
<p style="text-align: left;"><span style="text-decoration: underline;"><a href="http://mysqlpreacher.com/wordpress/wp-content/uploads/2009/03/no_population1.jpg"><img class="aligncenter size-full wp-image-139" title="MCDBA Certification KPIs / population" src="http://mysqlpreacher.com/wordpress/wp-content/uploads/2009/03/no_population1.jpg" alt="" width="500" height="607" /></a><br />
</span><br />
<code>+----------------------+------------+-------------+---------+</code><br />
<code>| Country              | Population | No of Certs | PPM     |</code><br />
<code>+----------------------+------------+-------------+---------+</code><br />
<code>| Gibraltar            |      31000 |           1 | 32.2580 | </code><br />
<code>| Virgin Islands       |     110000 |           1 |  9.0900 | </code><br />
<code>| Malta                |     412600 |           2 |  4.8470 | </code><br />
<code>| Luxembourg           |     491700 |           1 |  2.0330 | </code><br />
<code>| Singapore            |    4839400 |           9 |  1.8590 | <br />
| Switzerland          |    7700200 |          13 |  1.6880 | <br />
| Hong Kong            |    6985200 |          10 |  1.4310 | <br />
| United States        |  306088000 |         346 |  1.1300 | <br />
| Sweden               |    9259828 |          10 |  1.0790 | <br />
| Norway               |    4810122 |           5 |  1.0390 | <br />
| Finland              |    5331096 |           5 |  0.9370 | <br />
| Ireland              |    4517800 |           4 |  0.8850 | <br />
| Latvia               |    2260000 |           2 |  0.8840 | <br />
| Netherlands          |   16492476 |          13 |  0.7880 | <br />
| United Kingdom       |   61612300 |          47 |  0.7620 | <br />
| Trinidad and Tobago  |    1339000 |           1 |  0.7460 | <br />
| Australia            |   21707964 |          16 |  0.7370 | <br />
| Canada               |   33596000 |          23 |  0.6840 | <br />
| Germany              |   82062200 |          46 |  0.5600 | <br />
| Slovenia             |    2053355 |           1 |  0.4870 | <br />
| Italy                |   60090400 |          28 |  0.4650 | <br />
| United Arab Emirates |    4599000 |           2 |  0.4340 | <br />
| Israel               |    7382200 |           3 |  0.4060 | <br />
| Denmark              |    5511451 |           2 |  0.3620 | <br />
| Austria              |    8356700 |           3 |  0.3580 | <br />
| Taiwan               |   23027672 |           8 |  0.3470 | <br />
| Lithuania            |    3350400 |           1 |  0.2980 | <br />
| Belgium              |   10741000 |           3 |  0.2790 | <br />
| Bosnia Herzegovina   |    3767000 |           1 |  0.2650 | <br />
| South Korea          |   48333000 |          12 |  0.2480 | <br />
| France               |   65073482 |          16 |  0.2450 | <br />
| Spain                |   45853000 |          11 |  0.2390 | <br />
| New Zealand          |    4302010 |           1 |  0.2320 | <br />
| Croatia              |    4432000 |           1 |  0.2250 | <br />
| South Africa         |   48697000 |          10 |  0.2050 | <br />
| Japan                |  127630000 |          26 |  0.2030 | <br />
| Poland               |   38130300 |           7 |  0.1830 | <br />
| Jordan               |    6316000 |           1 |  0.1580 | <br />
| Sri Lanka            |   20238000 |           3 |  0.1480 | <br />
| Brazil               |  190902000 |          18 |  0.0940 | <br />
| Portugal             |   10631800 |           1 |  0.0940 | <br />
| Guatemala            |   14027000 |           1 |  0.0710 | <br />
| Philippines          |   92226600 |           6 |  0.0650 | <br />
| Ukraine              |   46143700 |           3 |  0.0650 | <br />
| Saudi Arabia         |   25721000 |           1 |  0.0380 | <br />
| Russia               |  141850000 |           5 |  0.0350 | <br />
| Malaysia             |   28067000 |           1 |  0.0350 | <br />
| Nepal                |   29331000 |           1 |  0.0340 | <br />
| Thailand             |   63389730 |           2 |  0.0310 | <br />
| India                | 1161120000 |          34 |  0.0290 | <br />
| Egypt                |   76030000 |           2 |  0.0260 | <br />
| Kenya                |   39802000 |           1 |  0.0250 | <br />
| Mexico               |  109610000 |           2 |  0.0180 | <br />
| China                | 1335962133 |          20 |  0.0140 | <br />
| Bangladesh           |  162221000 |           1 |  0.0060 | <br />
| Pakistan             |  165899500 |           1 |  0.0060 | <br />
| Indonesia            |  229850000 |           1 |  0.0040 | <br />
+----------------------+------------+-------------+---------+<br />
</code></p>
<p style="text-align: left;">On a per area basis, the country with most certified MySQL DBAs is again Gibralter given its 6Km squared of area, followed by Singapore, Hong Kong and Malta.</p>
<p style="text-align: left;">The least being Pakistan, Russia and Indonesia in order.</p>
<p style="text-align: left;"><a href="http://mysqlpreacher.com/wordpress/wp-content/uploads/2009/03/no_km1.jpg"><img class="aligncenter size-full wp-image-140" title="MCDBA Certification KPIs / 1000 Km squared" src="http://mysqlpreacher.com/wordpress/wp-content/uploads/2009/03/no_km1.jpg" alt="" width="500" height="541" /></a></p>
<p style="text-align: left;">*PPK here means parts per 1000 Km squared</p>
<p><code>+----------------------+----------+-------------+----------+</code><br />
<code>| Country              | Area     | No of Certs | PPK*     |</code><br />
<code>+----------------------+----------+-------------+----------+</code><br />
<code>| Gibraltar            |        6 |           1 | 166.6667 | </code><br />
<code>| Singapore            |      699 |           9 |  12.8755 | </code><br />
<code>| Hong Kong            |     1108 |          10 |   9.0253 | </code><br />
<code>| Malta                |      316 |           2 |   6.3291 | </code><br />
<code>| Virgin Islands       |      347 |           1 |   2.8818 | <br />
| Luxembourg           |     2586 |           1 |   0.3867 | <br />
| Switzerland          |    41284 |          13 |   0.3149 | <br />
| Netherlands          |    41543 |          13 |   0.3129 | <br />
| Taiwan               |    36188 |           8 |   0.2211 | <br />
| Trinidad and Tobago  |     5130 |           1 |   0.1949 | <br />
| United Kingdom       |   242900 |          47 |   0.1935 | <br />
| Israel               |    22072 |           3 |   0.1359 | <br />
| Germany              |   357022 |          46 |   0.1288 | <br />
| South Korea          |    99678 |          12 |   0.1204 | <br />
| Belgium              |    30528 |           3 |   0.0983 | <br />
| Italy                |   301318 |          28 |   0.0929 | <br />
| Japan                |   377915 |          26 |   0.0688 | <br />
| Ireland              |    70273 |           4 |   0.0569 | <br />
| Slovenia             |    20273 |           1 |   0.0493 | <br />
| Denmark              |    43094 |           2 |   0.0464 | <br />
| Sri Lanka            |    65610 |           3 |   0.0457 | <br />
| United States        |  9629091 |         346 |   0.0359 | <br />
| Austria              |    83871 |           3 |   0.0358 | <br />
| Latvia               |    64589 |           2 |   0.0310 | <br />
| France               |   632760 |          16 |   0.0253 | <br />
| United Arab Emirates |    83600 |           2 |   0.0239 | <br />
| Poland               |   312685 |           7 |   0.0224 | <br />
| Sweden               |   450295 |          10 |   0.0222 | <br />
| Spain                |   505992 |          11 |   0.0217 | <br />
| Philippines          |   300000 |           6 |   0.0200 | <br />
| Bosnia Herzegovina   |    51197 |           1 |   0.0195 | <br />
| Croatia              |    56594 |           1 |   0.0177 | <br />
| Norway               |   323802 |           5 |   0.0154 | <br />
| Lithuania            |    65300 |           1 |   0.0153 | <br />
| Finland              |   338145 |           5 |   0.0148 | <br />
| Jordan               |    89342 |           1 |   0.0112 | <br />
| Portugal             |    92090 |           1 |   0.0109 | <br />
| India                |  3287263 |          34 |   0.0103 | <br />
| Guatemala            |   108889 |           1 |   0.0092 | <br />
| South Africa         |  1221037 |          10 |   0.0082 | <br />
| Bangladesh           |   143998 |           1 |   0.0069 | <br />
| Nepal                |   147181 |           1 |   0.0068 | <br />
| Ukraine              |   603500 |           3 |   0.0050 | <br />
| Thailand             |   513120 |           2 |   0.0039 | <br />
| New Zealand          |   270467 |           1 |   0.0037 | <br />
| Malaysia             |   329847 |           1 |   0.0030 | <br />
| Canada               |  9984670 |          23 |   0.0023 | <br />
| Brazil               |  8514877 |          18 |   0.0021 | <br />
| Australia            |  7692024 |          16 |   0.0021 | <br />
| China                |  9640821 |          20 |   0.0021 | <br />
| Egypt                |  1002000 |           2 |   0.0020 | <br />
| Kenya                |   580367 |           1 |   0.0017 | <br />
| Mexico               |  1964375 |           2 |   0.0010 | <br />
| Saudi Arabia         |  2000000 |           1 |   0.0005 | <br />
| Indonesia            |  1904569 |           1 |   0.0005 | <br />
| Russia               | 17098242 |           5 |   0.0003 | <br />
| Pakistan             |  7960951 |           1 |   0.0001 | <br />
+----------------------+----------+-------------+----------+<br />
</code></p>
<p style="text-align: left;">At this point I'd like to ask the community a couple of questions:</p>
<p style="text-align: left;">1. Do you think there are many good MySQL DBAs who never tried getting certified?</p>
<p style="text-align: left;">2. Would you think it is fair to assume, the people who never tried the MCDBA exam is proportional to does who did? (my guess is yes)</p>
<p style="text-align: left;"> <br />
KPIs for developers and cluster certified people will follow in other blogs.</p>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://mysqlpreacher.com/wordpress/2009/03/mcdba-certification-kpis/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MySQL HA &#8211; Let&#8217;s take a look at Sequoia</title>
		<link>http://mysqlpreacher.com/wordpress/2009/03/mysql-ha-quite-a-few-solutions-to-choose-from-here-is-a-look-at-sequoia/</link>
		<comments>http://mysqlpreacher.com/wordpress/2009/03/mysql-ha-quite-a-few-solutions-to-choose-from-here-is-a-look-at-sequoia/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 10:13:33 +0000</pubDate>
		<dc:creator>Darren Cassar</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Heartbeat]]></category>
		<category><![CDATA[High Availability]]></category>
		<category><![CDATA[MySQL Cluster]]></category>
		<category><![CDATA[MySQL HA]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[Sequoia]]></category>
		<category><![CDATA[Sun Cluster]]></category>
		<category><![CDATA[Tungsten]]></category>
		<category><![CDATA[Veritas]]></category>

		<guid isPermaLink="false">http://mysqlpreacher.com/wordpress/?p=117</guid>
		<description><![CDATA[MySQL HA:
1. Desirable &#8211; most of the time,
2. Needed &#8211; often enough,
3. Available &#8211; there are some good options out there.
Typical solutions consist of:
Heartbeat with DRBD on Linux. Although HB was introduced to Linux, it can be used on Solaris, FreeBSD and others without the DRBD but with other solutions.
Sun Cluster,
Veritas (commercial),
MySQL Proxy (still in [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL HA:<br />
1. Desirable &#8211; most of the time,<br />
2. Needed &#8211; often enough,<br />
3. Available &#8211; there are some good options out there.</p>
<p>Typical solutions consist of:<br />
Heartbeat with DRBD on Linux. Although HB was introduced to Linux, it can be used on Solaris, FreeBSD and others without the DRBD but with other solutions.<br />
Sun Cluster,<br />
Veritas (commercial),<br />
MySQL Proxy (still in alpha at the time of writing this blog but on testing proved to be a sweet solution),<br />
Sequoia,<br />
Tungsten (commercial),<br />
MySQL cluster (which sadly doesn&#8217;t fit my scenario) and others</p>
<p>Whist researching the above list of load balancers / auto failover solutions I decided to give Sequoia (a load balancer and auto failover tier) a shot. I documented the commands and configuration steps and am listing them here under.<br />
Used windows for this one (shameful I know :P) but should work the same on *nix.</p>
<p>After downloading and unzipping Sequoia I went ahead and configured the controller.xml file. Apart from several other parameters available, this is the place where you should set the port where sequoia listens to requests and forwards them to the MySQL instances it is configured to in return connect to.</p>
<p><code>------------------------------&gt; CONTROLLER.XML to be stored in sequoia.x.xx/config/controller </code></p>
<blockquote><p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243; ?&gt;</p>
<p>&lt;!DOCTYPE SEQUOIA-CONTROLLER PUBLIC &#8220;-//Continuent//DTD SEQUOIA-CONTROLLER 2.10.10//EN&#8221;  &#8220;http://sequoia.continuent.org/dtds/sequoia-controller-2.10.10.dtd&#8221;&gt;</p>
<p>&lt;SEQUOIA-CONTROLLER&gt;<br />
&lt;Controller port=&#8221;25322&#8243;&gt;<br />
&lt;Report hideSensitiveData=&#8221;true&#8221; generateOnShutdown=&#8221;true&#8221; generateOnFatal=&#8221;true&#8221; enableFileLogging=&#8221;true&#8221; /&gt;<br />
&lt;JmxSettings&gt;<br />
&lt;RmiJmxAdaptor/&gt;<br />
&lt;/JmxSettings&gt;<br />
&lt;/Controller&gt;<br />
&lt;/SEQUOIA-CONTROLLER&gt;</p></blockquote>
<p>Next came the distribution file which contains several general parameters for which you should read the documentation if you would like to know better what each does. I personally followed a standard file and tuned it for my needs.</p>
<p><code>------------------------------&gt; TEST-MYSQL-DISTRIBUTION.XML to be stored in sequoia.x.xx/config/virtualdatabase </code></p>
<blockquote><p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br />
&lt;!DOCTYPE SEQUOIA PUBLIC &#8220;-//Continuent//DTD SEQUOIA 2.10.10//EN&#8221; &#8220;http://sequoia.continuent.org/dtds/sequoia-2.10.10.dtd&#8221;&gt;</p>
<p>&lt;SEQUOIA&gt;</p>
<p>&lt;VirtualDatabase name=&#8221;test&#8221;&gt;</p>
<p>&lt;Monitoring&gt;<br />
&lt;SQLMonitoring defaultMonitoring=&#8221;off&#8221;&gt;<br />
&lt;SQLMonitoringRule queryPattern=&#8221;^select&#8221; caseSensitive=&#8221;false&#8221; applyToSkeleton =&#8221;false&#8221; monitoring=&#8221;on&#8221;/&gt;<br />
&lt;/SQLMonitoring&gt;<br />
&lt;/Monitoring&gt;</p>
<p>&lt;Backup&gt;<br />
&lt;Backuper backuperName=&#8221;Octopus&#8221;<br />
className=&#8221;org.continuent.sequoia.controller.backup.backupers.OctopusBackuper&#8221;<br />
options=&#8221;zip=true&#8221;/&gt;<br />
&lt;/Backup&gt;</p>
<p>&lt;AuthenticationManager&gt;<br />
&lt;Admin&gt;<br />
&lt;User username=&#8221;admin&#8221; password=&#8221;"/&gt;<br />
&lt;/Admin&gt;<br />
&lt;VirtualUsers&gt;<br />
&lt;VirtualLogin vLogin=&#8221;user&#8221; vPassword=&#8221;"/&gt;<br />
&lt;/VirtualUsers&gt;<br />
&lt;/AuthenticationManager&gt;</p>
<p>&lt;DatabaseBackend name=&#8221;localhost1&#8243; driver=&#8221;com.mysql.jdbc.Driver&#8221;<br />
url=&#8221;jdbc:mysql://localhost:3306/test&#8221;<br />
connectionTestStatement=&#8221;select 1&#8243;&gt;<br />
&lt;ConnectionManager vLogin=&#8221;user&#8221; rLogin=&#8221;test&#8221; rPassword=&#8221;"&gt;<br />
&lt;VariablePoolConnectionManager initPoolSize=&#8221;10&#8243; minPoolSize=&#8221;5&#8243;<br />
maxPoolSize=&#8221;50&#8243; idleTimeout=&#8221;30&#8243; waitTimeout=&#8221;10&#8243;/&gt;<br />
&lt;/ConnectionManager&gt;<br />
&lt;/DatabaseBackend&gt;</p>
<p>&lt;DatabaseBackend name=&#8221;localhost2&#8243; driver=&#8221;com.mysql.jdbc.Driver&#8221;<br />
url=&#8221;jdbc:mysql://localhost:3307/test&#8221;<br />
connectionTestStatement=&#8221;select 1&#8243;&gt;<br />
&lt;ConnectionManager vLogin=&#8221;user&#8221; rLogin=&#8221;test&#8221; rPassword=&#8221;"&gt;<br />
&lt;VariablePoolConnectionManager initPoolSize=&#8221;10&#8243; minPoolSize=&#8221;5&#8243;<br />
maxPoolSize=&#8221;50&#8243; idleTimeout=&#8221;30&#8243; waitTimeout=&#8221;10&#8243;/&gt;<br />
&lt;/ConnectionManager&gt;<br />
&lt;/DatabaseBackend&gt;</p>
<p>&lt;RequestManager&gt;<br />
&lt;RequestScheduler&gt;<br />
&lt;RAIDb-1Scheduler level=&#8221;passThrough&#8221;/&gt;<br />
&lt;/RequestScheduler&gt;</p>
<p>&lt;RequestCache&gt;<br />
&lt;MetadataCache/&gt;<br />
&lt;ParsingCache/&gt;<br />
&lt;!&#8211;       &lt;ResultCache granularity=&#8221;table&#8221;/&gt; &#8211;&gt;<br />
&lt;/RequestCache&gt;</p>
<p>&lt;LoadBalancer&gt;<br />
&lt;RAIDb-1&gt;<br />
&lt;WaitForCompletion policy=&#8221;first&#8221;/&gt;<br />
&lt;RAIDb-1-LeastPendingRequestsFirst/&gt;<br />
&lt;/RAIDb-1&gt;<br />
&lt;/LoadBalancer&gt;<br />
&lt;RecoveryLog driver=&#8221;com.mysql.jdbc.Driver&#8221;<br />
url=&#8221;jdbc:mysql://localhost:3306/recovery&#8221; login=&#8221;test&#8221; password=&#8221;"&gt;<br />
&lt;RecoveryLogTable tableName=&#8221;RECOVERY&#8221;<br />
logIdColumnType=&#8221;BIGINT NOT NULL&#8221;<br />
vloginColumnType=&#8221;VARCHAR NOT NULL&#8221;<br />
sqlColumnType=&#8221;VARCHAR NOT NULL&#8221;<br />
extraStatementDefinition=&#8221;,PRIMARY KEY (log_id)&#8221;/&gt;<br />
&lt;CheckpointTable tableName=&#8221;CHECKPOINT&#8221;<br />
checkpointNameColumnType=&#8221;VARCHAR(255) NOT NULL&#8221;/&gt;<br />
&lt;BackendTable tableName=&#8221;BACKEND&#8221;<br />
databaseNameColumnType=&#8221;VARCHAR(255) NOT NULL&#8221;<br />
backendNameColumnType=&#8221;VARCHAR(255) NOT NULL&#8221;<br />
checkpointNameColumnType=&#8221;VARCHAR(255) NOT NULL&#8221;/&gt;<br />
&lt;DumpTable tableName=&#8221;DUMP&#8221; dumpNameColumnType=&#8221;VARCHAR(255) NOT NULL&#8221;<br />
dumpDateColumnType=&#8221;TIMESTAMP&#8221;<br />
dumpPathColumnType=&#8221;VARCHAR(255) NOT NULL&#8221;<br />
dumpFormatColumnType=&#8221;VARCHAR(255) NOT NULL&#8221;<br />
checkpointNameColumnType=&#8221;VARCHAR(255) NOT NULL&#8221;<br />
backendNameColumnType=&#8221;VARCHAR(255) NOT NULL&#8221;<br />
tablesColumnType=&#8221;VARCHAR(255) NOT NULL&#8221;/&gt;<br />
&lt;/RecoveryLog&gt;</p>
<p>&lt;/RequestManager&gt;</p>
<p>&lt;/VirtualDatabase&gt;</p>
<p>&lt;/SEQUOIA&gt;</p></blockquote>
<p>Given the above recovery log table contains illegal names for MySQL, it complains and therefore I went along and created the table directly using SQL. List of MySQL reserved words can be found here: http://dev.mysql.com/doc/mysqld-version-reference/en/mysqld-version-reference-reservedwords-5-1.html</p>
<p><code>------------------------------&gt; INSTALLATION STEPS</code></p>
<p>1) Run the following create table before loading virtualdatabase configuration C:\test-mysql-distribution.xml on the console window:<br />
CREATE DATABSE recovery</p>
<p><code>CREATE TABLE recovery ( </code><br />
<code>`log_id` BIGINT NOT NULL UNIQUE, </code><br />
<code>`vlogin` TEXT NOT NULL, </code><br />
<code>`sql` VARCHAR(255) NOT NULL, </code><br />
<code>`sql_param` TEXT, </code><br />
<code>`auto_conn_tran` CHAR(1) NOT NULL,</code><br />
<code>`transaction_id` BIGINT, </code><br />
<code>`request_id` BIGINT, </code><br />
<code>`exec_status` CHAR(1) NOT NULL, </code><br />
<code>`exec_time` BIGINT, </code><br />
<code>`update_count` BIGINT, </code><br />
<code>PRIMARY KEY (`log_id`) </code><br />
<code>) </code><br />
<code> </code></p>
<p>Edit controller.bat and console.bat to include the mysqlconnector in the CLASSPATH<br />
SET CLASSPATH=;&#8221;C:\Program Files\sequoia-2.10.10-bin/drivers/mysql-connector-java-3.1.14-bin.jar&#8221;;$CLASSPATH</p>
<p><code>------------------------------&gt; MySQL INSTALLATION STEPS</code></p>
<p>Install two mysql instances on 3306 and 3307 respectively, on the same machine (can be done on different machines and test-mysql-distribution.xml changed to suit the IPs. Set master &#8211; master replication and prepare startup / stop script. (For help installing master &#8211; master replication you can either use sandbox or install it customly using my.cnf replication settings and remember to set auto_increment_increment and auto_increment_offset according to how many masters you have.</p>
<p>On a two node setup they would be:</p>
<p>First Master the values:</p>
<p>auto_increment_increment = 2<br />
auto_increment_offset = 1</p>
<p>Second Master:</p>
<p>auto_increment_increment = 2<br />
auto_increment_offset = 2</p>
<p>If you are not knowledgable about the subject I recommend you use MySQL Sandbox or check out MySQL Documentation at: http://dev.mysql.com/doc/refman/5.1/en/replication.html</p>
<p><code>------------------------------&gt; EXECUTION STEPS</code></p>
<p>Run controller.bat then console.bat and issue `load virtualdatabase configuration C:\test-mysql-distribution.xml` when ready</p>
<p><code>------------------------------&gt;  OUTPUT on CONSOLE.BAT window</code></p>
<p>NOTE if stuck in console, just hit `tab` and the commands will be displayed</p>
<p><code>Running the tools and software: </code><br />
<code> </code><br />
<code>Launching the Sequoia controller console </code><br />
<code>Initializing Controller module... </code><br />
<code>Initializing VirtualDatabase Administration module... </code><br />
<code>Initializing SQL Console module... </code><br />
<code>Sequoia driver (Sequoia core v2.10.10) successfully loaded. </code><br />
<code>localhost:1090 &gt; load virtualdatabase configuration C:\test-mysql-distribution.xml </code><br />
<code>XML file C:\test-mysql-distribution.xml successfully sent to Sequoia controller. </code><br />
<code>localhost:1090 &gt; admin test </code><br />
<code>Virtual database Administrator Login &gt; admin </code><br />
<code>Virtual database Administrator Password &gt; </code><br />
<code>Ready to administrate virtual database test </code><br />
<code>test(admin) &gt; initialize localhost1 </code><br />
<code>Virtual Database test has been successfully initialized from backend localhost1 </code><br />
<code>test(admin) &gt; initialize localhost2 </code><br />
<code>Backend localhost1 has a last known checkpoint (Initial_empty_recovery_log) </code><br />
<code>test(admin) &gt; show backend localhost1 </code><br />
<code>+--------------------------+----------------------------------+ </code><br />
<code>| Backend Name             | localhost1                       | </code><br />
<code>| Driver                   | com.mysql.jdbc.Driver            | </code><br />
<code>| URL                      | jdbc:mysql://localhost:3306/test | </code><br />
<code>| Active transactions      | 0                                | </code><br />
<code>| Pending Requests         | 0                                | </code><br />
<code>| Read Enabled             | false                            | </code><br />
<code>| Write Enabled            | false                            | </code><br />
<code>| Is Initialized           | false                            | </code><br />
<code>| Static Schema            | false                            | </code><br />
<code>| Connection Managers      | 1                                | </code><br />
<code>| Total Active Connections | 50                               | </code><br />
<code>| Persistent Connections   | 0                                | </code><br />
<code>| Total Requests           | 0                                | </code><br />
<code>| Total Transactions       | 0                                | </code><br />
<code>| Last known checkpoint    | Initial_empty_recovery_log       | </code><br />
<code>+--------------------------+----------------------------------+ </code><br />
<code> </code><br />
<code>test(admin) &gt; show backend localhost2 </code><br />
<code>+--------------------------+----------------------------------+ </code><br />
<code>| Backend Name             | localhost2                       | </code><br />
<code>| Driver                   | com.mysql.jdbc.Driver            | </code><br />
<code>| URL                      | jdbc:mysql://localhost:3307/test | </code><br />
<code>| Active transactions      | 0                                | </code><br />
<code>| Pending Requests         | 0                                | </code><br />
<code>| Read Enabled             | false                            | </code><br />
<code>| Write Enabled            | false                            | </code><br />
<code>| Is Initialized           | false                            | </code><br />
<code>| Static Schema            | false                            | </code><br />
<code>| Connection Managers      | 1                                | </code><br />
<code>| Total Active Connections | 50                               | </code><br />
<code>| Persistent Connections   | 0                                | </code><br />
<code>| Total Requests           | 0                                | </code><br />
<code>| Total Transactions       | 0                                | </code><br />
<code>| Last known checkpoint    |                         | </code><br />
<code>+--------------------------+----------------------------------+ </code><br />
<code> </code><br />
<code>test(admin) &gt; enable localhost1 force </code><br />
<code>Enabling backend localhost1 from its last known checkpoint </code><br />
<code>test(admin) &gt; show backend localhost1 </code><br />
<code>+--------------------------+----------------------------------+ </code><br />
<code>| Backend Name             | localhost1                       | </code><br />
<code>| Driver                   | com.mysql.jdbc.Driver            | </code><br />
<code>| URL                      | jdbc:mysql://localhost:3306/test | </code><br />
<code>| Active transactions      | 0                                | </code><br />
<code>| Pending Requests         | 0                                | </code><br />
<code>| Read Enabled             | true                             | </code><br />
<code>| Write Enabled            | true                             | </code><br />
<code>| Is Initialized           | true                             | </code><br />
<code>| Static Schema            | false                            | </code><br />
<code>| Connection Managers      | 1                                | </code><br />
<code>| Total Active Connections | 10                               | </code><br />
<code>| Persistent Connections   | 0                                | </code><br />
<code>| Total Requests           | 0                                | </code><br />
<code>| Total Transactions       | 0                                | </code><br />
<code>| Last known checkpoint    |                         | </code><br />
<code>+--------------------------+----------------------------------+ </code><br />
<code> </code><br />
<code>test(admin) &gt; initialize localhost2 force </code><br />
<code>Virtual Database test has been successfully initialized from backend localhost2 </code><br />
<code>test(admin) &gt; enable localhost2 </code><br />
<code>Enabling backend localhost2 from its last known checkpoint </code><br />
<code>test(admin) &gt; show backend localhost1 </code><br />
<code>+--------------------------+--------------------------------------------------------------+ </code><br />
<code>| Backend Name             | localhost1                                                   | </code><br />
<code>| Driver                   | com.mysql.jdbc.Driver                                        | </code><br />
<code>| URL                      | jdbc:mysql://localhost:3306/test                             | </code><br />
<code>| Active transactions      | 0                                                            | </code><br />
<code>| Pending Requests         | 0                                                            | </code><br />
<code>| Read Enabled             | false                                                        | </code><br />
<code>| Write Enabled            | false                                                        | </code><br />
<code>| Is Initialized           | false                                                        | </code><br />
<code>| Static Schema            | false                                                        | </code><br />
<code>| Connection Managers      | 2                                                            | </code><br />
<code>| Total Active Connections | 25                                                           | </code><br />
<code>| Persistent Connections   | 0                                                            | </code><br />
<code>| Total Requests           | 0                                                            | </code><br />
<code>| Total Transactions       | 0                                                            | </code><br />
<code>| Last known checkpoint    | backup localhost1-172.22.16.103:25322-20090311114054271+0000 | </code><br />
<code>+--------------------------+--------------------------------------------------------------+ </code><br />
<code> </code><br />
<code>test(admin) &gt; disable localhost1 </code><br />
<code>Disabling backend localhost1 with automatic checkpoint. </code><br />
<code>test(admin) &gt; initialize localhost1 force </code><br />
<code>Virtual Database test has been successfully initialized from backend localhost1 </code><br />
<code>test(admin) &gt; enable localhost1 </code><br />
<code>Enabling backend localhost1 from its last known checkpoint </code><br />
<code>test(admin) &gt; show backend localhost1 </code><br />
<code>+--------------------------+----------------------------------+ </code><br />
<code>| Backend Name             | localhost1                       | </code><br />
<code>| Driver                   | com.mysql.jdbc.Driver            | </code><br />
<code>| URL                      | jdbc:mysql://localhost:3306/test | </code><br />
<code>| Active transactions      | 0                                | </code><br />
<code>| Pending Requests         | 0                                | </code><br />
<code>| Read Enabled             | true                             | </code><br />
<code>| Write Enabled            | true                             | </code><br />
<code>| Is Initialized           | true                             | </code><br />
<code>| Static Schema            | false                            | </code><br />
<code>| Connection Managers      | 2                                | </code><br />
<code>| Total Active Connections | 30                               | </code><br />
<code>| Persistent Connections   | 0                                | </code><br />
<code>| Total Requests           | 0                                | </code><br />
<code>| Total Transactions       | 0                                | </code><br />
<code>| Last known checkpoint    |                         | </code><br />
<code>+--------------------------+----------------------------------+ </code><br />
<code> </code><br />
<code>test(admin) &gt; show backend localhost2 </code><br />
<code>+--------------------------+----------------------------------+ </code><br />
<code>| Backend Name             | localhost2                       | </code><br />
<code>| Driver                   | com.mysql.jdbc.Driver            | </code><br />
<code>| URL                      | jdbc:mysql://localhost:3307/test | </code><br />
<code>| Active transactions      | 0                                | </code><br />
<code>| Pending Requests         | 0                                | </code><br />
<code>| Read Enabled             | true                             | </code><br />
<code>| Write Enabled            | true                             | </code><br />
<code>| Is Initialized           | true                             | </code><br />
<code>| Static Schema            | false                            | </code><br />
<code>| Connection Managers      | 2                                | </code><br />
<code>| Total Active Connections | 25                               | </code><br />
<code>| Persistent Connections   | 0                                | </code><br />
<code>| Total Requests           | 3                                | </code><br />
<code>| Total Transactions       | 0                                | </code><br />
<code>| Last known checkpoint    |                         | </code><br />
<code>+--------------------------+----------------------------------+ </code><br />
<code> </code><br />
<code>test(admin) &gt; show backend localhost2 </code><br />
<code>+--------------------------+----------------------------------+ </code><br />
<code>| Backend Name             | localhost2                       | </code><br />
<code>| Driver                   | com.mysql.jdbc.Driver            | </code><br />
<code>| URL                      | jdbc:mysql://localhost:3307/test | </code><br />
<code>| Active transactions      | 0                                | </code><br />
<code>| Pending Requests         | 0                                | </code><br />
<code>| Read Enabled             | true                             | </code><br />
<code>| Write Enabled            | true                             | </code><br />
<code>| Is Initialized           | true                             | </code><br />
<code>| Static Schema            | false                            | </code><br />
<code>| Connection Managers      | 2                                | </code><br />
<code>| Total Active Connections | 25                               | </code><br />
<code>| Persistent Connections   | 0                                | </code><br />
<code>| Total Requests           | 3                                | </code><br />
<code>| Total Transactions       | 0                                | </code><br />
<code>| Last known checkpoint    |                         | </code><br />
<code>+--------------------------+----------------------------------+ </code><br />
<code> </code><br />
<code>test(admin) &gt; disable localhost2 </code><br />
<code>Disabling backend localhost2 with automatic checkpoint. </code><br />
<code>test(admin) &gt; initialize localhost2 force </code><br />
<code>Virtual Database test has been successfully initialized from backend localhost2 </code><br />
<code>test(admin) &gt; enable localhost2 </code><br />
<code>Enabling backend localhost2 from its last known checkpoint </code><br />
<code>test(admin) &gt; disable localhost1 </code><br />
<code>Disabling backend localhost1 with automatic checkpoint. </code><br />
<code>test(admin) &gt; initialize localhost1 </code><br />
<code>Backend localhost2 is not in a disabled state (current state is enabled) </code><br />
<code>test(admin) &gt; disable localhost1 </code><br />
<code>Disabling backend localhost1 with automatic checkpoint. </code><br />
<code>test(admin) &gt; initialize localhost1 </code><br />
<code>Backend localhost2 is not in a disabled state (current state is enabled) </code><br />
<code>test(admin) &gt; initialize localhost1 force </code><br />
<code>Virtual Database test has been successfully initialized from backend localhost1 </code><br />
<code>test(admin) &gt; enable localhost1 </code><br />
<code>Enabling backend localhost1 from its last known checkpoint </code><br />
<code>test(admin) &gt; </code><br />
<code> </code><br />
<code> </code><br />
<code> </code><br />
<code>------------------------------&gt;  OUTPUT on CMD JAVA PROCESS EXECUTION WINDOW </code><br />
<code> </code><br />
<code>C:\Program Files\MySQL&gt;java -cp .;"c:\Program Files\MySQL\sequoia-driver.jar" Connect </code><br />
<code>Database connection established </code><br />
<code>id = 2, name = snake, category = reptile </code><br />
<code>id = 4, name = frog, category = amphibian </code><br />
<code>id = 6, name = tuna, category = fish </code><br />
<code>id = 8, name = racoon, category = mammal </code><br />
<code>4 rows were retrieved </code><br />
<code>Database connection terminated </code><br />
<code> </code><br />
<code> </code><br />
<code> </code><br />
<code>-------------------------------&gt; Here I inserted some rows directly in the database and reran the java program </code><br />
<code> </code><br />
<code> </code><br />
<code>C:\Program Files\MySQL&gt;java -cp .;"c:\Program Files\MySQL\sequoia-driver.jar" Connect </code><br />
<code>Database connection established </code><br />
<code>id = 2, name = snake, category = reptile </code><br />
<code>id = 4, name = frog, category = amphibian </code><br />
<code>id = 6, name = tuna, category = fish </code><br />
<code>id = 8, name = racoon, category = mammal </code><br />
<code>id = 10, name = darren, category = human </code><br />
<code>id = 12, name = michael, category = alien </code><br />
<code>6 rows were retrieved </code><br />
<code>Database connection terminated </code><br />
<code> </code><br />
<code> </code><br />
<code> </code><br />
<code>------------------------------&gt; The JAVA PROGRAM used, obtained from: http://www.kitebird.com/articles/jdbc.html : </code><br />
<code> </code><br />
<code> </code><br />
<code> import java.sql.*; </code><br />
<code> </code><br />
<code> public class Connect </code><br />
<code> { </code><br />
<code> public static void main (String[] args) </code><br />
<code> { </code><br />
<code> Connection conn = null; </code><br />
<code> </code><br />
<code> try </code><br />
<code> { </code><br />
<code> String userName = "admin"; </code><br />
<code> String password = ""; </code><br />
<code> String url = "jdbc:sequoia://127.0.0.1:25322/test?user=root"; </code><br />
<code> Class.forName ("org.continuent.sequoia.driver.Driver").newInstance (); </code><br />
<code> conn = DriverManager.getConnection (url,userName,password); </code><br />
<code> System.out.println ("Database connection established"); </code><br />
<code> </code><br />
<code> /* Uncomment the following at the first run so that it creates a table called animal and inserts a few rows in it. </code><br />
<code> */ </code><br />
<code> /* Statement s = conn.createStatement (); </code><br />
<code> int count; </code><br />
<code> s.executeUpdate ("DROP TABLE IF EXISTS animal"); </code><br />
<code> s.executeUpdate ( </code><br />
<code> "CREATE TABLE animal (" </code><br />
<code> + "id INT UNSIGNED NOT NULL AUTO_INCREMENT," </code><br />
<code> + "PRIMARY KEY (id)," </code><br />
<code> + "name CHAR(40), category CHAR(40))"); </code><br />
<code> count = s.executeUpdate ( </code><br />
<code> "INSERT INTO animal (name, category)" </code><br />
<code> + " VALUES" </code><br />
<code> + "('snake', 'reptile')," </code><br />
<code> + "('frog', 'amphibian')," </code><br />
<code> + "('tuna', 'fish')," </code><br />
<code> + "('racoon', 'mammal')"); </code><br />
<code> s.close (); </code><br />
<code> System.out.println (count + " rows were inserted");  : */ </code><br />
<code> </code><br />
<code> Statement s = conn.createStatement (); </code><br />
<code> s.executeQuery ("SELECT id, name, category FROM animal"); </code><br />
<code> ResultSet rs = s.getResultSet (); </code><br />
<code> int count = 0; </code><br />
<code> while (rs.next ()) </code><br />
<code> { </code><br />
<code> int idVal = rs.getInt ("id"); </code><br />
<code> String nameVal = rs.getString ("name"); </code><br />
<code> String catVal = rs.getString ("category"); </code><br />
<code> System.out.println ( </code><br />
<code> "id = " + idVal </code><br />
<code> + ", name = " + nameVal </code><br />
<code> + ", category = " + catVal); </code><br />
<code> ++count; </code><br />
<code> } </code><br />
<code> rs.close (); </code><br />
<code> s.close (); </code><br />
<code> System.out.println (count + " rows were retrieved"); </code><br />
<code> </code><br />
<code> </code><br />
<code> </code><br />
<code> } </code><br />
<code> catch (Exception e) </code><br />
<code> { </code><br />
<code> System.err.println ("Cannot connect to database server"); </code><br />
<code> // System.err.println (e); </code><br />
<code> e.printStackTrace(); </code><br />
<code> } </code><br />
<code> finally </code><br />
<code> { </code><br />
<code> if (conn != null) </code><br />
<code> { </code><br />
<code> try </code><br />
<code> { </code><br />
<code> conn.close (); </code><br />
<code> System.out.println ("Database connection terminated"); </code><br />
<code> } </code><br />
<code> catch (Exception e) { /* ignore close errors */ } </code><br />
<code> } </code><br />
<code> } </code><br />
<code> } </code><br />
<code> } </code><br />
<code> </code><br />
<code> </code><br />
<code> </code><br />
<code>------------------------------&gt; COMPILING / EXECUTING JAVA PROGRAM </code><br />
<code> </code><br />
download and install JDK<br />
compile: javac Connect.java<br />
execute: java -cp .;&#8221;c:\Program Files\MySQL\sequoia-driver.jar&#8221; Connect</p>
]]></content:encoded>
			<wfw:commentRss>http://mysqlpreacher.com/wordpress/2009/03/mysql-ha-quite-a-few-solutions-to-choose-from-here-is-a-look-at-sequoia/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
