Jacobian
Jacobian

Reputation: 10802

MySQL Proxy step by step configuration

I have an apache web server in my local network (local ip 192.168.0.100). There is a web-site which uses a MySQL database. I added one more slave server (local ip 192.168.0.101) and configured database replication. Now, I want to add a Proxy server for load balancing (at least to test how it works). So, I installed MySQL Proxy on another machine (local ip 192.168.0.102), I created a service in this way

C:\> sc create "Proxy" DisplayName= "MySQL Proxy" start= "auto" binPath="C:\mysql-proxy\bin\mysql-proxy-svc.exe --defaults-file= C:mysql-proxy\mysql-proxy.cnf"

In coonfiguration file, which is mysql-proxy.cnf I have put these lines:

[mysql-proxy]
daemon = true
log-file = "C:\mysql-proxy\mysql-proxy.log"
log-level = debug
proxy-address = 192.168.0.102:4040
proxy-backend-addresses = 192.168.0.100:3306,192.168.0.101:3306

In coomand line I ran

net start proxy

And I see, that it is running without errors. But now I'm stuck and do not know what to do next. In some guides they suggest running this query:

mysql> select * from proxy_connections;

But where to run, how to run - no one says it. If I just run it on my master server, I obviously get an error "No database selected". Other user guides almost from the very start discuss lua scripting. But I do not need that, at least now. What I want is to simply check load balancing. A simple test case would be to execute a query to the database, and to see, how proxy works. Besides, guys, I see that mysql proxy share folder contains a lot of lua scripts. I see ro-balance for example. Lib directory contains also balance.lua. I guess, load balancing will be easier with these scripts - probably I will have to just specify read and write servers. So, if you have already gone through all these steps - to get just the simplest load balancing work, please, share your experience.

Upvotes: 2

Views: 8786

Answers (1)

Mahesh Patil
Mahesh Patil

Reputation: 1551

Start MySQL proxy in this way:

C:\MySQL_proxy\> mysql-proxy.exe --proxy-backend-addresses=<MySQLserver host/IP>:mysql server port --proxy-address=<proxy host>:<proxy port>

You can test by using Mysql command line tool or any other MySQL client and see whether it is connecting to MySQL proxy or not.

mysql -uroot -p -hmysql_proxy-host-name -Pmysql-proxy-port 

Upvotes: 3

Related Questions