<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>mysql-proxy &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/mysql-proxy/</link>
	<description>Feed of posts on WordPress.com tagged "mysql-proxy"</description>
	<pubDate>Thu, 24 Dec 2009 11:10:35 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Load Balancing MySQL: Part II]]></title>
<link>http://cloudbuzz.wordpress.com/2009/10/21/load-balancing-mysql-part-ii/</link>
<pubDate>Wed, 21 Oct 2009 07:01:24 +0000</pubDate>
<dc:creator>samof76</dc:creator>
<guid>http://cloudbuzz.wordpress.com/2009/10/21/load-balancing-mysql-part-ii/</guid>
<description><![CDATA[In the first part of this series we saw how the MySQL replication is setup on P/V machines. Now we s]]></description>
<content:encoded><![CDATA[In the first part of this series we saw how the MySQL replication is setup on P/V machines. Now we s]]></content:encoded>
</item>
<item>
<title><![CDATA[Simple MySQL replication cluster with load balancer on the slaves]]></title>
<link>http://bluhaloit.wordpress.com/2009/05/11/simple-mysql-replication-cluster-with-load-balancer-on-the-slaves/</link>
<pubDate>Mon, 11 May 2009 13:46:18 +0000</pubDate>
<dc:creator>Simon Green</dc:creator>
<guid>http://bluhaloit.wordpress.com/2009/05/11/simple-mysql-replication-cluster-with-load-balancer-on-the-slaves/</guid>
<description><![CDATA[Scenario Background This post is a follow on from my previous post on how to setup a load balanced h]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><h2>Scenario</h2>
<h3>Background</h3>
<p>This post is a follow on from <a title="How to quickly setup a load balanced, high availability, Apache cluster" href="http://bluhaloit.wordpress.com/2009/04/29/how-to-quickly-setup-a-load-balanced-high-availability-apache-cluster/" target="_blank">my previous post</a> on how to setup a load balanced high availability Apache cluster and uses the same network setup and heartbeat setup. For the purposes of testing and to save on resource I am using the web servers from the previous guide as the MySQL servers in this guide. Obviously in a real world setup this would be doing it wrong <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h3>End Goal</h3>
<p>You will be able to connect to 1 IP address and port with MySQL client and be routed to 1 of many MySQL servers. The machine doing the routing will be in a high availability setup with another machine.</p>
<h3>Server Roles</h3>
<p><strong>bhlabs1/6</strong> will load balance mysql queries through mysql-proxy<br />
<strong>bhlabs2</strong> will be  the master replication server<br />
<strong>bhlabs3-5</strong> will be mysql slaves</p>
<p>I&#8217;m separating this guide into 3 sections:</p>
<ul>
<li>MySQL Replication Cluster</li>
<li>mysql-proxy Setup</li>
<li>Usage with heartbeat</li>
</ul>
<p><!--more--></p>
<h2>MySQL Replication Cluster</h2>
<p>On each of the servers :</p>
<pre># apt-get update
# apt-get install mysql-server</pre>
<p>The slave servers will need special access to stream the binary logs from the master server, so that needs to be setup using the following GRANT command as root on the master server:</p>
<pre>mysql&#62; GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%' IDENTIFIED BY 'ImASlave';</pre>
<p>Next un-comment server id and binary log entries in my.cnf (add them if they weren&#8217;t there in the first place):</p>
<pre>server-id   = 1
log_bin     = /var/log/mysql/mysql-bin.log</pre>
<p>You must also set the server-id on all slaves, starting from 2 and incrementing as you go. You do not need the log_bin entry on the slave servers.</p>
<p>Your slave servers must begin replication at exactly the same state as the master server. From the master server, export all databases with lock on all tables:</p>
<pre># mysqldump -p --all-databases --lock-all-tables &#62; initialDbDump.db</pre>
<p>And then import on to all slave servers:</p>
<pre># mysql -p -hbhlabs3 &#60; ./initialDbDump.db
# mysql -p -hbhlabs4 &#60; ./initialDbDump.db
# mysql -p -hbhlabs5 &#60; ./initialDbDump.db</pre>
<p>Get log position off bhlabs2:</p>
<pre>mysql&#62; show master status;
+------------------+----------+--------------+------------------+
&#124; File             &#124; Position &#124; Binlog_Do_DB &#124; Binlog_Ignore_DB &#124;
+------------------+----------+--------------+------------------+
&#124; mysql-bin.000002 &#124;      516 &#124;              &#124;                  &#124;
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)</pre>
<p>Set configuration and start slave on bhlabs3-5:</p>
<pre>mysql&#62; CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000002', MASTER_LOG_POS=516, MASTER_HOST='bhlabs2', MASTER_USER='repl', MASTER_PASSWORD='ImASlave';
mysql&#62; START SLAVE;</pre>
<p>You can check connectivity from bhlabs2:</p>
<pre>mysql&#62; show full processlist;
+----+------+---------------------+------+-------------+------+----------------------------------------------------------------+-----------------------+
&#124; Id &#124; User &#124; Host                &#124; db   &#124; Command     &#124; Time &#124; State                                                          &#124; Info                  &#124;
+----+------+---------------------+------+-------------+------+----------------------------------------------------------------+-----------------------+
&#124; 16 &#124; repl &#124; 192.168.11.36:40812 &#124; NULL &#124; Binlog Dump &#124;  248 &#124; Has sent all binlog to slave; waiting for binlog to be updated &#124; NULL                  &#124;
&#124; 17 &#124; repl &#124; 192.168.11.37:48080 &#124; NULL &#124; Binlog Dump &#124;  206 &#124; Has sent all binlog to slave; waiting for binlog to be updated &#124; NULL                  &#124;
&#124; 18 &#124; repl &#124; 192.168.11.38:54400 &#124; NULL &#124; Binlog Dump &#124;  202 &#124; Has sent all binlog to slave; waiting for binlog to be updated &#124; NULL                  &#124;
&#124; 22 &#124; root &#124; localhost           &#124; NULL &#124; Query       &#124;    0 &#124; NULL                                                           &#124; show full processlist &#124;
+----+------+---------------------+------+-------------+------+----------------------------------------------------------------+-----------------------+
4 rows in set (0.00 sec)</pre>
<p>And then create a test database on bhlabs2 and it should appear on the other 3 servers.</p>
<pre>mysql&#62; create database test;
Query OK, 1 row affected (0.00 sec)</pre>
<p>Drop the test database and it should disappear. If this works you&#8217;re set to go.</p>
<pre>mysql&#62; drop database test;
Query OK, 0 rows affected (0.07 sec)</pre>
<p>Remember from this point all commands that create or change anything in MySQL must now be run on the master server. With this in mind, create a read only user, you don&#8217;t want your websites accidentally writing to the slaves, that will break replication!</p>
<pre>mysql&#62; grant select on *.* to 'selectuser'@'%' identified by 'password';
Query OK, 0 rows affected (0.00 sec)

mysql&#62; grant select on *.* to 'selectuser'@'localhost' identified by 'password';
Query OK, 0 rows affected (0.00 sec)</pre>
<p>And then obivously, a write user:</p>
<pre>mysql&#62; grant select,insert,update,delete on *.* to 'writeuser'@'%' identified by 'password';
Query OK, 0 rows affected (0.00 sec)

mysql&#62; grant select,insert,update,delete on *.* to 'writeuser'@'localhost' identified by 'password';
Query OK, 0 rows affected (0.01 sec)</pre>
<h2>Proxy Servers</h2>
<p><em>Repeat this whole section on both proxy servers (bhlabs1/6)</em><br />
Install the proxy:</p>
<pre># apt-get updatep
# apt-get install mysql-proxy</pre>
<p>Initial startup:</p>
<pre># mysql-proxy --admin-address=:1337 --proxy-backend-addresses=192.168.11.36:3306 --proxy-backend-addresses=192.168.11.37:3306 --proxy-backend-addresses=192.168.11.38:3306 &#38;</pre>
<p>Check the proxy is running via netstat to see if the ports have been bound:</p>
<pre># netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 *:4040                  *:*                     LISTEN
tcp        0      0 *:1337                  *:*                     LISTEN</pre>
<p>Port 4040 is the proxy inbound port<br />
Port 1337 is the admin database</p>
<p>Connect to admin database:</p>
<pre># mysql -h 127.0.0.1 -P 1337 -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.20-agent MySQL Enterprise Agent

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql&#62;</pre>
<p>And then check your proxy_config tables at it should list your backend servers:</p>
<pre>mysql&#62; select * from proxy_config;
+----------------------------+--------------------+
&#124; option                     &#124; value              &#124;
+----------------------------+--------------------+
&#124; admin.address              &#124; :1337              &#124;
&#124; proxy.address              &#124; :4040              &#124;
&#124; proxy.lua_script           &#124; NULL               &#124;
&#124; proxy.backend_addresses[0] &#124; 192.168.11.36:3306 &#124;
&#124; proxy.backend_addresses[1] &#124; 192.168.11.37:3306 &#124;
&#124; proxy.backend_addresses[2] &#124; 192.168.11.38:3306 &#124;
&#124; proxy.fix_bug_25371        &#124; 0                  &#124;
&#124; proxy.profiling            &#124; 1                  &#124;
+----------------------------+--------------------+
8 rows in set (0.00 sec)</pre>
<p>Quit out of mysql and then reconnect on the proxy ingress port:</p>
<pre># mysql -h 127.0.0.1 -P 4040 -u selectuser -p</pre>
<p>And you should then be able to spot a Sleep connection on one of your slave servers through:</p>
<pre>mysql&#62; show full processlist;
+----+------------+---------------------+------+---------+------+-------+-----------------------+
&#124; Id &#124; User       &#124; Host                &#124; db   &#124; Command &#124; Time &#124; State &#124; Info                  &#124;
+----+------------+---------------------+------+---------+------+-------+-----------------------+
&#124; 20 &#124; selectuser &#124; 192.168.11.30:58522 &#124; NULL &#124; Sleep   &#124;  161 &#124;       &#124; NULL                  &#124;
&#124; 21 &#124; selectuser &#124; localhost           &#124; NULL &#124; Query   &#124;    0 &#124; NULL  &#124; show full processlist &#124;
+----+------------+---------------------+------+---------+------+-------+-----------------------+
2 rows in set (0.00 sec)</pre>
<p>Success!</p>
<p>You can now test failover by shutting down one of your slaves, running queries, even inserts (on the master!), and then starting the slave again. The slave will know the last log position it was at on the master logs and be able to catch back up once you restart it. The proxy will not route queries to a server thats down.</p>
<h2>High Availability (Optional)</h2>
<p>This will allow your proxy servers to failover between each other on the same address using heartbeat. For how to setup heartbeat initially see the guide <a title="How to quickly setup a load balanced, high availability, Apache cluster" href="http://bluhaloit.wordpress.com/2009/04/29/how-to-quickly-setup-a-load-balanced-high-availability-apache-cluster/" target="_blank">here</a>, we&#8217;re going to pick up at the end of that guide and just join our mysql-proxy to that shared IP address.</p>
<p>All you need to do to get it to listen on the shared address is add 1 more switch to the startup command, proxy-address:</p>
<pre># mysql-proxy --proxy-address=192.168.11.40:4040 --admin-address=:1337 --proxy-backend-addresses=192.168.11.36:3306 --proxy-backend-addresses=192.168.11.37:3306 --proxy-backend-addresses=192.168.11.38:3306 &#38;</pre>
<p>You can then check it&#8217;s listening on the specified IP via netstat again. Remember if heartbeat hasn&#8217;t failed over to this machine then you won&#8217;t be able to reach this address!</p>
<pre># netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 192.168.11.40:4040      *:*                     LISTEN</pre>
<h2>Furthur Reading</h2>
<h3>Automatically routing writes and reads</h3>
<p>It is possible to use 1 user for both your reads and your writes through 1 IP/Port by using mysql-proxy&#8217;s very extensive LUA support to route queries to different servers based on queries. See <a title="MySQL Proxy learns R/W Splitting" href="http://jan.kneschke.de/2007/8/1/mysql-proxy-learns-r-w-splitting" target="_blank">here</a> and <a title="MySQL Proxy: more R/W splitting" href="http://jan.kneschke.de/2007/8/26/mysql-proxy-more-r-w-splitting" target="_blank">here</a> for examples.</p>
<h3>Other funky LUA hacks</h3>
<p>There&#8217;s plenty you can do with LUA and mysql-proxy. <a title="Getting Started with MySQL Proxy" href="http://www.oreillynet.com/pub/a/databases/2007/07/12/getting-started-with-mysql-proxy.html?page=1" target="_blank">O&#8217;Reilly published a good guide</a> with examples such as rewriting queries on the fly to correct typos, executing remote shell commands through MySQL, etc.  Worth a read if you want to do anything automated with it.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[MySQL : Simulating Workload with MySQL Proxy]]></title>
<link>http://fabioce.wordpress.com/2009/04/02/mysql-simulating-workload-with-mysql-proxy/</link>
<pubDate>Thu, 02 Apr 2009 07:06:56 +0000</pubDate>
<dc:creator>fabioce</dc:creator>
<guid>http://fabioce.wordpress.com/2009/04/02/mysql-simulating-workload-with-mysql-proxy/</guid>
<description><![CDATA[]]></description>
<content:encoded><![CDATA[<div class='snap_preview'></div>]]></content:encoded>
</item>
<item>
<title><![CDATA[MySQL hardening with GUI tools &amp; MySQL Proxy]]></title>
<link>http://greensweater.wordpress.com/2009/02/11/mysql-hardening-with-gui-tools-mysql-proxy/</link>
<pubDate>Wed, 11 Feb 2009 14:06:50 +0000</pubDate>
<dc:creator>greensweater</dc:creator>
<guid>http://greensweater.wordpress.com/2009/02/11/mysql-hardening-with-gui-tools-mysql-proxy/</guid>
<description><![CDATA[There are many options for MySQL, but actually putting them into place can be a clunky process. For ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>There are many options for MySQL, but actually putting them into place can be a clunky process. For instance, in order to use GUI tools on a remote MySQL server, you need to open a port. If SSH tunneling is unavailable to you, you are stuck with either reconfiguring MySQL every time you want to connect, or worse, leaving port 3306 open for connections. Restarting the server every time you want to make a simple query is just too much.</p>
<p>The first thing I do with a MySQL install is close all incoming ports. In my.cnf:<br />
<code><br />
bind-address = 127.0.0.1</code></p>
<p>This forces the server to only accept connections from localhost. Then I limit access to the databases by creating an &#8220;application user&#8221; with access only to the needed databases and tables. I disable GRANT for this user. You could expand this to filter DROP, DELETE, etc. access if needed. (Don&#8217;t forget to change the root password.)</p>
<p>This method seals up the server pretty well, but now how can you use your handy GUI tools from your desktop? You have a couple of options:</p>
<p>1. SSH Tunneling. As mentioned above, it&#8217;s pretty easy to use <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/docs.html">PuTTY</a>, <a href="http://www.appgate.com/index/products/mindterm/">MindTerm</a> or any number of other console apps to create a tunnel. Once you&#8217;ve established the tunnel, point your GUI app at the localhost port you&#8217;ve bound to the tunnel and you&#8217;re good to go.</p>
<p>2. <a href="http://dev.mysql.com/downloads/mysql-proxy/index.html">MySQL Proxy</a>. If you can&#8217;t tunnel due to network restrictions, there&#8217;s a handy binary called mysql-proxy that can act as a little trapdoor to the server. You can put this binary anywhere and run it in the background like so:</p>
<p><code>&#62; mysql-proxy &#38;<br />
[1] 12345</code></p>
<p>The proxy opens port 4040 (by default) and you can connect to that with your GUI (<a href="http://www.webyog.com/en/">SQLYog</a> is my favorite right now). There are a ton of other options for mysql-proxy that I&#8217;m not concerned with; I just needed a dead-simple way to get at the server and this method fit the bill.</p>
<p>When you&#8217;re done you just kill 12345 and you&#8217;re out of there.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[سأعيد الكتابة عن ...........]]></title>
<link>http://mohammedsh.wordpress.com/2008/11/16/rewrite-in/</link>
<pubDate>Sun, 16 Nov 2008 11:42:45 +0000</pubDate>
<dc:creator>محمد شراب</dc:creator>
<guid>http://mohammedsh.wordpress.com/2008/11/16/rewrite-in/</guid>
<description><![CDATA[Ø§ÙØ³ÙØ§Ù Ø¹ÙÙÙÙ ÙØ±Ø­ÙØ© Ø§ÙÙÙ ÙØ¨Ø±ÙØ§ØªÙ ÙØ¨Ù Ø£Ù Ø£Ø¨Ø¯Ø£ ÙÙ Ø§ÙÙÙØ¶ÙØ¹Ø]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Ø§ÙØ³ÙØ§Ù Ø¹ÙÙÙÙ ÙØ±Ø­ÙØ© Ø§ÙÙÙ ÙØ¨Ø±ÙØ§ØªÙ</p>
<p>ÙØ¨Ù Ø£Ù Ø£Ø¨Ø¯Ø£ ÙÙ Ø§ÙÙÙØ¶ÙØ¹Ø Ø£ÙØ¯ Ø£Ù Ø£Ø°ÙØ± ÙÙØ§ Ø£ÙÙÙ Ø¨Ø¯Ø£Øª Ø§ÙÙØªØ§Ø¨Ø© ÙÙ ÙØ¬Ø§Ù ØªÙÙÙÙÙØ¬ÙØ§ Ø§ÙÙØ¹ÙÙÙØ§Øª ÙÙ Ø§ÙÙÙØªØ¯Ù Ø§ÙØ®Ø§Øµ Ø¨Ø·ÙØ§Ø¨ ÙÙÙØ© ØªÙÙÙÙÙØ¬ÙØ§ Ø§ÙÙØ¹ÙÙÙØ§Øª ÙÙ Ø§ÙØ¬Ø§ÙØ¹Ø© Ø§ÙØ¥Ø³ÙØ§ÙÙØ© ( TechNet )Ø ÙØ¨Ø¹Ø¯ Ø°ÙÙ Ø£ØµØ¨Ø­Øª ÙØ¯ÙØ± Ø§ÙÙØ§Ø¯Ù ÙØ¨Ø§ÙØªØ§ÙÙ ÙØ¯ÙØ± Ø§ÙÙÙÙØ¹ ÙØªØ§Ø¨Ø¹Øª Ø§ÙÙØªØ§Ø¨Ø© ÙÙÙ Ø¨Ø´ÙÙ Ø£ÙØ¨Ø±Ø Ø§ÙØªÙÙØª Ø¨Ø¹Ø¯ Ø°ÙÙ ÙÙÙØªØ§Ø¨Ø© ÙÙ ÙÙÙØ¹Ù Ø§ÙØ®Ø§Øµ ( Ø­Ø§Ø³ÙØ¨Ù )Ø ÙÙÙÙ ÙÙØ£Ø³Ù Ø§ÙØ´Ø¯ÙØ¯ Ø¥ÙØ§ ÙØ¶ØºÙØ· Ø£Ù ÙÙØ³Ù ØªÙÙÙØª ÙØ°Ù Ø§ÙÙØ´Ø§Ø±ÙØ¹Ø ÙÙÙ ÙØ«ÙØ± ÙÙ Ø§ÙØ£Ø­ÙØ§Ù Ø®Ø³Ø±Øª Ø£Ø±Ø´ÙÙ ÙÙØ§Ø¶ÙØ¹Ù Ø¨ÙØ§ Ø­ÙÙØªÙ ÙÙ Ø¨Ø¹Ø¶ Ø§ÙÙÙØ§Ø¶ÙØ¹ Ø§ÙØ¬ÙØ¯Ø©.</p>
<p>Ø³Ø£Ø¶Ø¹ ÙÙØ§ ØªÙÙÙØ§Øª ÙØªØ¨Øª Ø­ÙÙÙØ§ Ø¨Ø§Ø®ØªØµØ§Ø± Ø£Ù Ø£Ø´Ø±Øª Ø¥ÙÙÙØ§ ÙÙ ÙÙØ§Ø¶ÙØ¹ Ø³Ø§Ø¨ÙØ© ÙØ¹ Ø±ÙØ§Ø¨Ø· ÙØªÙÙ Ø§ÙÙÙØ§Ø¶ÙØ¹Ø ÙÙÙ Ø£ÙÙÙÙØ§ Ø¥ÙÙ Ø§ÙÙØ¯ÙÙØ© ÙÙØ§ ÙØ£ÙÙÙ Ø£Ø®Ø·Ø· ÙØ¥Ø¹Ø§Ø¯Ø© ÙØªØ§Ø¨Ø© ÙØ°Ù Ø§ÙÙÙØ§Ø¶ÙØ¹ ÙÙ Ø¬Ø¯ÙØ¯ ÙØªØªÙØ§Ø³Ø¨ ÙØ¹ Ø§ÙÙØ¯ÙÙØ© ÙÙØ¹ Ø§ÙÙØ±Ø§Ø¡Ø ÙÙØªØ­ØªÙÙ Ø¹ÙÙ ÙØ¹ÙÙÙØ§Øª Ø£ÙØ«Ø± ÙØ¨Ø´ÙÙ Ø£Ø±ØªØ¨ ÙØ£Ø¯ÙØ ÙÙÙØªØ§Ø¨Ø¹Ø© Ø§ÙØªØ·ÙØ±Ø§Øª Ø§ÙØªÙ Ø­ØµÙØª ÙÙØ° ÙØªØ§Ø¨Øª ØªÙÙ Ø§ÙÙÙØ§Ø¶ÙØ¹ Ø­ØªÙ ÙÙÙÙØ§ ÙØ°Ø§Ø ÙØ£ÙÙÙÙ ÙØ§Ø¦ÙØ© Ø¨Ø§ÙÙÙØ§Ø¶ÙØ¹:</p>
<ul>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=10&#38;t=168&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">Database normalization &#8211; Ø§ÙÙÙØ§Ø¦Ø¯ ÙØ§ÙØ®Ø·ÙØ§Øª &#8230;</a></li>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=10&#38;t=256&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">mysql proxy &#8211; ÙØ§ Ø²Ø§Ù alpha Ùwindows ÙÙØ³ ÙÙ Ø§ÙÙØ§Ø¦ÙØ©</a></li>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=97&#38;t=263&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">Wml Script</a></li>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=25&#38;t=248&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">Multitier architecture ÙÙØ£ÙÙÙØ©</a></li>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=97&#38;t=252&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">Xml, Xsl ÙÙÙØ§ÙØ¨Ù Ø§ÙØªØ·ÙØ± ÙÙØ·</a></li>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=24&#38;t=245&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">Microsoft Surface ÙÙ Ø¨Ø¯Ø£ Ø§ÙÙØ§Ø±Ø¯ ÙÙÙÙ !!</a></li>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=41&#38;t=247&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">prototype.js ÙÙØ·ÙØ±Ù Ø§ÙÙÙØ§ÙØ¹</a></li>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=96&#38;t=300&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">Ø§ÙØ¨Ø±ÙØ¬Ø© ÙÙØ¶ÙØ¹ÙØ© Ø§ÙØªÙØ¬Ù Aspect Oriented Programming AOP</a></li>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=96&#38;t=250&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">ÙØºØ© Ruby ØØ ÙØºØ© Ø§ÙÙ2007</a></li>
<li><span style="text-decoration:line-through;"><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=41&#38;t=257&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">ÙØ³Øª Ø£ÙÙ ÙØ¯Ø±Ø© ÙÙ Yahoo! ØµÙÙ Ø¨Ø§Ø­ØªØ±Ø§Ù</a></span><span class="topictitle"> &#62;&#62; </span><a title="ØµÙÙ ÙØ¨Ø±ÙØ¬Â Ø¨Ø§ØØªØ±Ø§Ù!" rel="bookmark" href="../2008/11/18/gwt-ext/">2 ÙÙ 1: ØµÙÙ ÙØ¨Ø±ÙØ¬Â Ø¨Ø§Ø­ØªØ±Ø§Ù!</a></li>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=12&#38;t=42&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">ØªØ·Ø¨ÙÙØ§Øª Ø¥ÙØªØ±ÙØª Ø¬Ø§ÙØ²Ø© ÙÙÙØªÙØ­Ø© Ø§ÙÙØµØ¯Ø±</a></li>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=30&#38;t=404&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">LINQ ØØ Ø£ÙØ¨Ø± ÙÙ ÙØ¬Ø±Ø¯ SQL ÙÙ ÙÙØ§Ø¹Ø¯ Ø¨ÙØ§ÙØ§Øª !!</a></li>
<li> <a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=33&#38;t=789&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">ADOdb ÙØºÙØ±Ù !!</a></li>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=10&#38;t=790&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">Ø¨ÙÙ Ø³Ø±Ø¹Ø© mysql ÙÙÙØ© Ø£Ø¯Ø§Ø¡ ÙÙØ¸Ø§Ø¦Ù Ø§ÙDBMS Ø§ÙØªØ¬Ø§Ø±ÙØ© PostgreSQL !</a></li>
</ul>
<p>ÙÙØ§ Ø£ÙÙÙ ÙÙØª ÙØ¯ ÙØªØ¨Øª Ø­ÙÙ Ø§ÙØ¹Ø¯ÙØ¯ ÙÙ Ø§ÙØ¨Ø±Ø§ÙØ¬ ÙØ¹Ø¯Ø¯ ÙÙ Ø§ÙÙØªØ¨ Ø§ÙØ¬ÙØ¯Ø© ÙÙÙÙÙ ÙØ´Ø§ÙØ¯ØªÙØ§ Ø­Ø§ÙÙØ§Ù ÙÙ <a href="http://www.it3ch.com/tech/search.php?st=0&#38;sk=t&#38;sd=d&#38;sr=topics&#38;sid=e14e409bd4f49e4f591fb127de3da6bb&#38;author=Dev.Moh+Sh&#38;sf=firstpost">Ø£Ø±Ø´ÙÙ ÙÙØ§Ø¶ÙØ¹Ù</a> ÙÙ ØªÙÙ ÙØª<br />
 <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  ÙØ­ØªØ§Ø± ÙÙ Ø£ÙÙ Ø£Ø¨Ø¯Ø£ Ø¥Ø¹Ø§Ø¯Ø© Ø§ÙÙØªØ§Ø¨Ø©Ø ÙÙØ¯ ÙÙÙÙ ÙØªØ¹ÙÙÙØ§ØªÙÙ Ø§ÙØ¯ÙØ± ÙÙ ØªØ±ØªÙØ¨ Ø§ÙØ£ÙÙÙÙØ§Øª</p>
<p>Ø¯ÙØªÙ Ø¨ÙØ¯</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[سأعيد الكتابة عن ...........]]></title>
<link>http://devmohsh.wordpress.com/2008/11/16/rewrite-in/</link>
<pubDate>Sun, 16 Nov 2008 11:42:45 +0000</pubDate>
<dc:creator>محمد شراب</dc:creator>
<guid>http://devmohsh.wordpress.com/2008/11/16/rewrite-in/</guid>
<description><![CDATA[السلام عليكم ورحمة الله وبركاته قبل أن أبدأ في الموضوع، أود أن أذكر هنا أنني بدأت الكتابة في مجال تك]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>السلام عليكم ورحمة الله وبركاته</p>
<p>قبل أن أبدأ في الموضوع، أود أن أذكر هنا أنني بدأت الكتابة في مجال تكنولوجيا المعلومات في المنتدى الخاص بطلاب كلية تكنولوجيا المعلومات في الجامعة الإسلامية ( TechNet )، وبعد ذلك أصبحت مدير النادي وبالتالي مدير الموقع وتابعت الكتابة فيه بشكل أكبر، انتقلت بعد ذلك للكتابة في موقعي الخاص ( حاسوبي )، ولكن للأسف الشديد إما لضغوط أو لكسل توقفت هذه المشاريع، وفي كثير من الأحيان خسرت أرشيف مواضيعي بما حملته من بعض المواضيع الجيدة.</p>
<p>سأضع هنا تقنيات كتبت حولها باختصار أو أشرت إليها في مواضيع سابقة مع روابط لتلك المواضيع، ولن أنقلها إلى المدونة هنا لأنني أخطط لإعادة كتابة هذه المواضيع من جديد لتتناسب مع المدونة ومع القراء، ولتحتوي على معلومات أكثر وبشكل أرتب وأدق، ولمتابعة التطورات التي حصلت منذ كتابت تلك المواضيع حتى يومنا هذا، وأليكم قائمة بالمواضيع:</p>
<ul>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=10&#38;t=168&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">Database normalization &#8211; الفوائد والخطوات &#8230;</a></li>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=10&#38;t=256&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">mysql proxy &#8211; ما زال alpha وwindows ليس في القائمة</a></li>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=97&#38;t=263&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">Wml Script</a></li>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=25&#38;t=248&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">Multitier architecture للأهمية</a></li>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=97&#38;t=252&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">Xml, Xsl لمواكبي التطور فقط</a></li>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=24&#38;t=245&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">Microsoft Surface هي بدأ المارد يفيق !!</a></li>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=41&#38;t=247&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">prototype.js لمطوري المواقع</a></li>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=96&#38;t=300&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">البرمجة موضوعية التوجه Aspect Oriented Programming AOP</a></li>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=96&#38;t=250&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">لغة Ruby ،، لغة الـ2007</a></li>
<li><span style="text-decoration:line-through;"><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=41&#38;t=257&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">لست أقل قدرة من Yahoo! صمم باحتراف</a></span><span class="topictitle"> &#62;&#62; </span><a title="صمم وبرمج باتراف!" rel="bookmark" href="../2008/11/18/gwt-ext/">2 في 1: صمم وبرمج باحتراف!</a></li>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=12&#38;t=42&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">تطبيقات إنترنت جاهزة ومفتوحة المصدر</a></li>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=30&#38;t=404&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">LINQ ،، أكبر من مجرد SQL لـ قواعد بيانات !!</a></li>
<li> <a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=33&#38;t=789&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">ADOdb وغيره !!</a></li>
<li><a class="topictitle" href="http://www.it3ch.com/tech/viewtopic.php?f=10&#38;t=790&#38;sid=e14e409bd4f49e4f591fb127de3da6bb">بين سرعة mysql وقوة أداء ووظائف الDBMS التجارية PostgreSQL !</a></li>
</ul>
<p>كما أنني كنت قد كتبت حول العديد من البرامج وعدد من الكتب الجيدة يمكنك مشاهدتها حالياً من <a href="http://www.it3ch.com/tech/search.php?st=0&#38;sk=t&#38;sd=d&#38;sr=topics&#38;sid=e14e409bd4f49e4f591fb127de3da6bb&#38;author=Dev.Moh+Sh&#38;sf=firstpost">أرشيف مواضيعي</a> في تيك نت</p>
<p> <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  محتار من أين أبدأ إعادة الكتابة، وقد يكون لتعليقاتكم الدور في ترتيب الأولويات</p>
<p>دمتم بود</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Mysql-proxy &amp; The power of lua]]></title>
<link>http://palanganator.wordpress.com/2008/10/09/mysql-proxy-the-power-of-lua/</link>
<pubDate>Thu, 09 Oct 2008 10:10:30 +0000</pubDate>
<dc:creator>palanganator</dc:creator>
<guid>http://palanganator.wordpress.com/2008/10/09/mysql-proxy-the-power-of-lua/</guid>
<description><![CDATA[Como sabeis lua es el lenguaje de programacion de raices ibericas que ha acabado siendo utilizado po]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Como sabeis lua es el lenguaje de programacion de raices ibericas que ha acabado siendo utilizado por grandes compañias, como puede ser el caso de Blizzard para lo que ha sido el evento ludico informatico mas importante en toda la historia de la informatica. EL WOW!!!!</p>
<p>Mysql-proxy lo ha adoptado como su lenguaje de scripting, y se pueden hacen virguerias. Cualquier conexion o query que pase por el proxy la podemos modificar a nuestro antojo, monitorear, logear, etc, etc, etc.</p>
<p>Es una gozada mas que recomendable arrancar el mysql-proxy en modo verbose con todo su debug escupiendose en consola, pero ojo, no ruede alguna lagrimilla,  recordando charlas, discusiones, peleas sobre si las conexiones se balanceaban correctamente o no. El super debug!</p>
<p>Aqui os dejo un tech tip, no tiene dificultad, pero al que se encuentre con ello, se ahorrara analizarlo, y solventarlo.</p>
<p>Este es el script que de lua que hace que las escrituras vayan al master definido, y las lecturas a los slave definidos.</p>
<p>/mysql-proxy/rw-splitting.lua</p>
<p>Este script no sabe de de las variables de entorno de los servers mysql. No deja de ser una conexion de cliente como cualquier otra, por lo que variables como los charset no tendran los valores que vosotros esperais.</p>
<p><a href="http://forums.mysql.com/read.php?146,198892,200418#msg-200418">http://forums.mysql.com/read.php?146,198892,200418#msg-200418</a></p>
<p>La solucion correcta de todas las opciones que aparece en el debate:</p>
<p><a href="http://forums.mysql.com/read.php?146,198892,200044">http://forums.mysql.com/read.php?146,198892,200044</a></p>
<p>Se tarda 10 segundos en implementar, otros 10 en testear, y el resto de tu vida puedes estar tranquilo.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[building mysql proxy ! not my cup of tea]]></title>
<link>http://alexlurthu.wordpress.com/2008/04/03/building-mysql-proxy-not-my-cup-of-tea/</link>
<pubDate>Thu, 03 Apr 2008 14:21:09 +0000</pubDate>
<dc:creator>Alex</dc:creator>
<guid>http://alexlurthu.wordpress.com/2008/04/03/building-mysql-proxy-not-my-cup-of-tea/</guid>
<description><![CDATA[On a RHEL 4u4 host run the following wget commands to get the necessary source code. wget http://gd.]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p align="justify">On a RHEL 4u4 host run the following wget commands to get the necessary source code.</p>
<p align="justify"><span style="color:#333399;">wget http://gd.tuwien.ac.at/graphics/gimp/gtk/v2.6/glib-2.6.4.tar.bz2</span></p>
<p align="justify"><span style="color:#333399;">wget http://dev.mysql.com/get/Downloads/MySQL-Proxy/mysql-proxy-0.6.1.tar.gz/from/http://mysql.easynet.be/</span></p>
<p align="justify"><span style="color:#333399;">wget http://luaforge.net/frs/download.php/3132/lua5_1_3_Sources.tar.gz</span></p>
<p align="justify"><span style="color:#333399;">wget http://monkey.org/~provos/libevent-1.3d.tar.gz</span></p>
<p align="justify">Untar all the files and run configure , make and make install.</p>
<p align="justify">To tackle few of the hiccups that you might encounter, you can install glib on to a location that is different from your root.</p>
<p align="justify">For Glib 2.6, compile to some dir under your home dir</p>
<p align="justify"><span style="color:#333399;">./configure &#8211;prefix=/home/user/mysql-proxy/lib/</span></p>
<p align="justify">Similarly edit the makefile of lua5.1 to change the install location. You can have this installed in the main root too. If so, by default it will go under /usr/local/lib.</p>
<p align="justify">After compiling and installing libevent (this can go into the main root), glib and lua set the following environment variables to tell the mysql-proxy configure script where to look for glib and lua.</p>
<p align="justify"><span style="color:#333399;">export LUA_CFLAGS=&#8221;-I/home/user/mysql-proxy/lib/include/&#8221;<br />
export LUA_LIBS=&#8221;-L/home/user/mysql-proxy/lib/lib&#8221;</span></p>
<div><span style="color:#333399;">export GLIB_CFLAGS = &#8220;-I/home/user/mysql-proxy/lib/include/glib-2.0 -I/home/user/mysql-proxy/lib/lib/glib-2.0/include/&#8221;</span></div>
<div><span style="color:#333399;">export GLIB_LIBS=&#8221;-L/home/user/mysql-proxy/lib/ -lglib-2.0 -ldl -llua5.1 -lm&#8221;</span></div>
<p align="justify">Also you need to install the mysql_config binary into a location in your path variable.</p>
<p align="justify">If you  had installed lua on the main root you might have to export the LD_LIBRARY_PATH.</p>
<p align="justify"><span style="color:#333399;"> export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib</span></p>
<p align="justify">Really got to know the internals of building 32 bit and 64 bit software. Sucked at building this pkg but learnt some stuff. Cool stuff with mysql-proxy coming up.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[MySQL: Tracking slow queries]]></title>
<link>http://feelsgood11.wordpress.com/2008/01/12/mysql-tracking-slow-queries/</link>
<pubDate>Sat, 12 Jan 2008 11:07:09 +0000</pubDate>
<dc:creator>feelsgood11</dc:creator>
<guid>http://feelsgood11.wordpress.com/2008/01/12/mysql-tracking-slow-queries/</guid>
<description><![CDATA[While running performance testing against some web application we should measure not only such metri]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>While running performance testing against some web application we should measure not only such metrics as page download time, hits per second and so on, but also those ones that relate to a database. It&#8217;s obvious that the time of queries execution has a great impact on the first metrics like page download time.</p>
<p>For such cases MySQL has a very handy ability to track slow queries.  For more info please visit <a href="http://dev.mysql.com/doc/refman/5.0/en/slow-query-log.html" title="http://dev.mysql.com/doc/refman/5.0/en/slow-query-log.html" target="_blank">http://dev.mysql.com/doc/refman/5.0/en/slow-query-log.html</a></p>
<p>Also there is a simple program called MySQL Proxy that can monitor, analyze or transform communication between application and server. Please go <a href="http://forge.mysql.com/wiki/MySQL_Proxy">here</a> to get more info.</p>
<p>And it&#8217;s useful to know about MySQL Profiles. Here is an article &#8220;<a href="http://dev.mysql.com/tech-resources/articles/using-new-query-profiler.html" target="_blank">Using the new MySQL Query Profiler</a>&#8220;</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Tutoriel mysql-proxy rw-splitting + Réplication MySQL]]></title>
<link>http://sangokode.wordpress.com/2007/12/24/mysql-proxy-rw-splitting-replication-mysql/</link>
<pubDate>Mon, 24 Dec 2007 11:29:32 +0000</pubDate>
<dc:creator>sangokode</dc:creator>
<guid>http://sangokode.wordpress.com/2007/12/24/mysql-proxy-rw-splitting-replication-mysql/</guid>
<description><![CDATA[Quand un site web dynamique commence à avoir un trafic important, généralement on va essayer de mult]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Quand un site web dynamique commence à avoir un trafic important, généralement on va essayer de multiplier les serveurs web qui hébergent les fichiers.<br />
Multiplier les serveurs web n&#8217;est pas le plus difficile, il suffit de faire une réplication des données à chaque mise à jour de votre site et de multiplier les sous-domaines.</p>
<p>Les choses se compliquent lorsque vous souhaitez avoir <b>plusieurs serveurs de base de données</b>. La base de données que nous étudierons ici est MySQL. Nous ne parlerons pas de <i>cluster MySQL</i> dans cet article.</p>
<p>Le but de l&#8217;article est de montrer comment <b>séparer un serveur MySQL en trois serveurs distincts : 1 maitre et deux esclaves</b>, avec un seul point d&#8217;entrée (le proxy MySQL). Le proxy devra envoyer les requêtes de lecture vers les serveurs esclaves et toutes les autres requêtes vers le serveur d&#8217;écriture.</p>
<p>La première partie de ce billet fera dans la théorie, nous verrons ensuite la mise en place.</p>
<h2>Théorie réplication et mysql-proxy</h2>
<p>Imaginons que vous ayez un site web avec <b>10% de mises à jour</b> de la BDD (&#8220;INSERT&#8221; ou &#8220;UPDATE&#8221;) et <b>90% de sélections</b> (&#8220;SELECT&#8221;). L&#8217;idéal serait de pouvoir séparer les écritures des lectures, et encore mieux de séparer les lectures en plusieurs serveurs.</p>
<p>La réplication MySQL permet d&#8217;avoir un serveur dit maitre (&#8220;MASTER&#8221;) et <i>n</i> serveurs esclaves (&#8220;SLAVES&#8221;). La réplication se fait du maitre vers les esclaves donc si vous faites un &#8220;INSERT&#8221; sur un esclave, les autres serveurs ne seront pas mis à jour.<br />
En gros la réplication enregistre dans des logs (appelés logs binaires) toutes les actions (les requêtes) et les esclaves viennent lire ces logs pour répéter ces mêmes actions.</p>
<p>La réplication seule n&#8217;est pas suffisante, car il va falloir séparer les requêtes selon leur type (&#8220;INSERT&#8221; ou &#8220;UPDATE&#8221;).<br />
Si vous avez déjà prévu dans votre application des fonctions du genre : mysql_read_master(), mysql_read_slave(), mysql_insert_master() alors aucun problème mais sinon il va falloir ajouter une couche logicielle entre votre application et vos serveurs MySQL.</p>
<p>Cette couche c&#8217;est mysql-proxy, un programme très récent écrit en C qui fonctionne sur la plupart des plateformes où fonctionne MySQL.</p>
<h2>Application</h2>
<p>J&#8217;imagine que vous savez ce que sont ssh, lynx, wget, mysqld, mysqldump et les commandes de base de Linux, sinon ce sera plus compliqué mais bon ça ira.</p>
<h3>Installation de la réplication MySQL</h3>
<p>Vous devez avoir au moins deux serveurs MySQL &#62;=5.0 (1 maitre et 1 esclave) sur deux machines différentes.<br />
Dans la suite de l&#8217;article j&#8217;utilise trois serveurs (1 maitre et 2 esclaves) mais il n&#8217;y a aucune différence.</p>
<p>Décidez quel serveur sera le maitre et qui seront les esclaves.</p>
<h4>Configuration du maitre :</h4>
<ul>
<li>Vérifiez que ces deux lignes n&#8217;apparaissent pas dans le fichier de configuration my.cnf :</li>
</ul>
<blockquote></blockquote>
<pre>skip-networking
bind-address = 127.0.0.1</pre>
<blockquote></blockquote>
<blockquote><p>Sinon vous ne pourrez pas vous connecter à distance au serveur.</p></blockquote>
<ul>
<li> Juste en dessous de la section [mysqld], rajoutez ces lignes :</li>
</ul>
<blockquote></blockquote>
<pre>log-bin=/home/mysql-logs/mysql-bin.log
binlog-do-db=bddarepliquer
server-id=1</pre>
<blockquote></blockquote>
<ul>
<li>Redémarrez votre serveur MySQL.</li>
</ul>
<ul>
<li>Connectez-vous au serveur MySQL pour y lancer quelques requêtes.<br />
Nous allons ajouter l&#8217;utilisateur qui sera utilisé par les esclaves pour lire les logs de réplication :</li>
</ul>
<blockquote></blockquote>
<pre>GRANT REPLICATION SLAVE ON *.*
TO 'replicant'@'%' IDENTIFIED BY 'motdepasse';
FLUSH PRIVILEGES;</pre>
<blockquote></blockquote>
<blockquote><p>Vous pouvez changez replicant pour un autre utilisateur et surtout changez motdepasse  par un vrai mot de passe !</p></blockquote>
<ul>
<li> Ensuite exécutez ces requêtes :</li>
</ul>
<blockquote></blockquote>
<pre>USE bddarepliquer;
FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS;</pre>
<blockquote></blockquote>
<blockquote><p>Nous avons bloqué les tables et demandé d&#8217;afficher la position dans le log binaire à cet instant précis. Vous allez obtenir ce genre de résultat :</p></blockquote>
<pre>+------------------+----------+---------------+------------------+
&#124; File             &#124; Position &#124; Binlog_do_db  &#124; Binlog_ignore_db &#124;
+------------------+----------+---------------+------------------+
&#124; mysql-bin.000001 &#124; 183      &#124; bddarepliquer &#124;                  &#124;
+------------------+----------+---------------+------------------+
1 row in set (0.00 sec)</pre>
<blockquote><p>Notez le nom du log binaire et sa position.Quittez le client MySQL, faites un dump de votre base SQL.</p></blockquote>
<ul>
<li> Connectez vous au serveur MySQL (toujours le maitre), nous allons débloquer les tables :</li>
</ul>
<blockquote></blockquote>
<pre>UNLOCK TABLES;</pre>
<blockquote></blockquote>
<p>Vous pouvez quitter votre client MySQL, <b>la configuration du maitre est terminée.</b></p>
<p>Nous avons donc : une sauvegarde d&#8217;un instant donné de votre base à répliquer, un serveur MySQL configuré en tant que maitre de réplication, des logs qui enregistrent toutes les actions faites sur ce serveur. Il ne nous reste qu&#8217;à configurer les esclaves.</p>
<h4>Configuration des esclaves :</h4>
<ul>
<li>Créez la base de donnée et importez les données du dump.</li>
</ul>
<ul>
<li> Éditez votre fichier my.cnf, ajoutez ces lignes en dessous de la section [mysqld] :</li>
</ul>
<blockquote></blockquote>
<pre>server-id=2
master-user=replicant
master-password=motdepasse
master-connect-retry=60
replicate-do-db=bddarepliquer</pre>
<blockquote></blockquote>
<ul>
<li>Redémarrez MySQL</li>
</ul>
<ul>
<li>Connectez vous à vos serveurs esclaves pour exécuter ces requêtes :</li>
</ul>
<blockquote></blockquote>
<pre>SLAVE STOP;
CHANGE MASTER TO MASTER_HOST='192.168.0.100', MASTER_USER='',
MASTER_PASSWORD='motdepasse', MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=183;</pre>
<blockquote></blockquote>
<blockquote><p>Remplacez toutes les valeurs par celles définies/récupérées plus haut.</p></blockquote>
<ul>
<li> Enfin executez, toujours dans votre client MySQL, ceci :</li>
</ul>
<blockquote></blockquote>
<pre>START SLAVE;</pre>
<blockquote></blockquote>
<p><b>La réplication est en place.<br />
</b></p>
<h3>Installation du proxy MySQL</h3>
<p>Le proxy recevra toutes les connexions destinées aux BDD de votre application sur le port 4040 (par défaut). Il redirigera ensuite automatiquement les requêtes vers les différents serveurs selon leur type.</p>
<ul>
<li>Il faut donc avoir un utilisateur ayant accès aux 3 serveurs MySQL, <b>sur chaque serveur</b> il faudra donc ajouter cet utilisateur :</li>
</ul>
<blockquote></blockquote>
<pre>GRANT ALL PRIVILEGES ON *.*
TO 'proxyuser'@'%' IDENTIFIED BY 'motdepasse';
FLUSH PRIVILEGES;</pre>
<blockquote></blockquote>
<p><i>Il faut décider où va se trouver le proxy MySQL (sur quel serveur), le<br />
choix importe peu finalement. Imaginons dans notre cas que le proxy<br />
soit situé sur le serveur maitre. </i></p>
<ul>
<li>Sur le serveur qui héberge le proxy MySQL, il faudra aussi cette ligne pour que le proxy puisse se connecter en local au serveur MySQL hebergé sur la même machine :</li>
</ul>
<blockquote></blockquote>
<pre>GRANT ALL PRIVILEGES ON *.*
TO 'proxyuser'@'localhost' IDENTIFIED BY 'motdepasse';
FLUSH PRIVILEGES;</pre>
<blockquote></blockquote>
<ul>
<li>Téléchargez la dernière version de mysql-proxy (actuellement c&#8217;est la 0.6.0) : http://dev.mysql.com/downloads/mysql-proxy/, vous pouvez soit télécharger les binaires, soit le compiler vous même.<br />
<b>Dans mon cas j&#8217;utilise des binaires déjà compilés.</b></li>
</ul>
<ul>
<li>Une fois le dossier du programme obtenu sur le serveur choisit pour le proxy, il n&#8217;y a plus qu&#8217;à le lancer avec la bonne commande, pour des besoins spécifiques j&#8217;ai créé un fichier sh :</li>
</ul>
<blockquote></blockquote>
<pre>while true;
do LUA_PATH="/etc/mysql-proxy-0.6.0/lib/?.lua"
/etc/mysql-proxy-0.6.0/src/mysql-proxy
	--proxy-lua-script=/etc/mysql-proxy-0.6.0/lib/rw-splitting.lua
	--proxy-backend-addresses=:3306
	--proxy-read-only-backend-addresses=ipesclave1
	--proxy-read-only-backend-addresses=ipesclave2 &#62; /dev/null
done;</pre>
<blockquote></blockquote>
<blockquote><p>En imaginant dans ce cas que vous avez décompressé les binaires dans <b>etc/mysql-proxy-0.6.0</b>.</p></blockquote>
<h3>Quelques explications, précisions</h3>
<ul>
<li><b>LUA_PATH=&#8221;/etc/mysql-proxy-0.6.0/lib/?.lua&#8221;</b><br />
définit ou se trouvent les scripts de traitements des requêtes.</li>
<li><b>/etc/mysql-proxy-0.6.0/src/mysql-proxy</b><br />
définit l&#8217;emplacement du binaire.</li>
<li><b>&#8211;proxy-lua-script=/etc/mysql-proxy-0.6.0/lib/rw-splitting.lua</b><br />
définit quel script de traitement des requêtes utiliser, dans notre cas c&#8217;est la séparation des requêtes d&#8217;écritures/lectures que nous utilisons (read/write splitting = rw-splitting)</li>
<li><b>&#8211;proxy-backend-addresses=:3306</b><br />
définit qui est le serveur d&#8217;écriture (:3306 correspond à localhost)</li>
<li><b>&#8211;proxy-read-only-backend-addresses=ipesclave1<span style="font-weight:bold;"> </span>&#8211;proxy-read-only-backend-addresses=ipesclave2</b><br />
définissent qui sont les serveurs de lectures (et donc les esclaves réplication)</li>
</ul>
<p>Voilà une fois ce script passé en executable (chmod +x nomfichier sous Linux) vous pourrez le lancer avec la commande ./script.sh.</p>
<p>Alors pourquoi ce script ? Il permet de relancer automatiquement le serveur quand il plante.<br />
En effet mysql-proxy est encore en version alpha mais tient la route. Le principal plantage intervient lorsque qu&#8217;un requête est mal formée, exemple :</p>
<pre>insert into table values (1,'test, 'probleme');</pre>
<blockquote><p>Ce genre de requête fait planter le proxy avec un message du style :</p></blockquote>
<pre>file sql-tokenizer.l: line 402 (sql_token_append_last_token): assertion failed: (tokens-&#62;len &#62; 0)</pre>
<p>Il y&#8217;a d&#8217;autres messages d&#8217;erreur comme :</p>
<pre>network-mysqld-proxy.c.2927: I have no server backend, closing connection</pre>
<blockquote><p>Qui intervient lorsque le serveur maitre ne répond plus, mais je n&#8217;ai pas encore trouvé pourquoi ce bug survient</p></blockquote>
<p>Vous pouvez poser vos questions dans les commentaires.</p>
</div>]]></content:encoded>
</item>

</channel>
</rss>
