MySQL Forums
Forum List  »  Router & Proxy

mySql Proxy error 2006
Posted by: Rainer Butzki
Date: July 19, 2010 11:51AM

Hallo,
I've configured a master/master replication for my two DB-server.
I want to use the first DB-server for rw and r (the whole traffic),
whike the server is up and running.
The second DB-server is for backup and failover.
The failover to the second DB-server is, when the first databse-server is down.
If the first DB-Server comes back, he gets action back.

On application-server (later it will be 7 server) i've configured mySQL Proxy.

My lua-script on app-server is (fix the first DB-Server):
function connect_server()
-- print ("connecting to .. 1")
proxy.connection.backend_ndx = 1
end

function read_query(packet)
-- print ("query to .. 1")
proxy.connection.backend_ndx = 1
end

my proxy-start on app-server is:
mysql-proxy --proxy-lua-script=/opt/scripts/failover.lua --proxy-backend-addresses=x.x.x.16:3306 --proxy-backend-addresses=x.x.x.66:3306 --log-level=debug

my mySql-start on app-server is:
mysql --host=127.0.0.1 --port=4040 --user=xx --password=xx
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.0.77-log Source distribution

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

mysql> insert into butest.testtable values('9');
Query OK, 1 row affected (0.00 sec)

mysql> -- here the first database stops
mysql> insert into butest.testtable values('10');
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> -- here again the statement
mysql> insert into butest.testtable values('10');
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 44
Current database: *** NONE ***

Query OK, 1 row affected (0.01 sec)


Here is the problem:
When the first database stops, the insert-statement didn't work
the first time. Send the same statement again, it reconnects and works fine.

Is there a way to failover the DB-server directly without any errors?

sorry, it is a lot of text....

Options: ReplyQuote


Subject
Views
Written By
Posted
mySql Proxy error 2006
3286
July 19, 2010 11:51AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.