MySQL Forums
Forum List  »  Router & Proxy

Use MySQL Proxy just to redirect to a backend from a database name
Posted by: Frnck Geo
Date: February 27, 2012 10:05AM

Hello,

MySQL Proxy is presented as program that sits between client and MySQL servers for load balancing or failover... and more.
Many LUA samples show this capacity...

For using MySQL Proxy without as load balancing or failover,
Is it possible to use MySQL Proxy for redirect to good MySQL server (backend) from schema name notified in client request connection ?

In other words,
When a MySQL client is connected to MySQL Proxy for the access to a specific database,
How configure MySQL Proxy to redirect to server backend that contains database ?

I think a LUA script below (which don't run) is better for understand my problem.
Of course, I tested the script but the 'default_db' is always empty and the choice of backend isn't operational:

function connect_server()

print('inside connect_server')
print("BD: " .. proxy.connection.client.default_db)

if proxy.connection.client.default_db == "db1" then
proxy.connection.backend_ndx = 1
elseif proxy.connection.client.default_db == "db2" then
proxy.connection.backend_ndx = 2
elseif proxy.connection.client.default_db == "db3" then
proxy.connection.backend_ndx = 3
else
error("invalid operation")
end

end

Thank you for your response,
Sincerely.

Options: ReplyQuote


Subject
Views
Written By
Posted
Use MySQL Proxy just to redirect to a backend from a database name
4146
February 27, 2012 10:05AM


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.