Pen : MySQL Load Balancing2015/01/31 |
Configure Pen to Load Balance to 2 MySQL backends.
| -------+----------------------------------------------- | +-------------------+--------------------+ |10.0.0.30 |10.0.0.51 |10.0.0.52 +-----+------+ +-------+------+ +-------+------+ | Frontend | | Backend#1 | | Backend#2 | | Pen Server | | MySQL Server | | MySQL Server | +------------+ +--------------+ +--------------+ |
[1] | Configure Pen. Before this section, configure basic settings. |
[root@dlp ~]#
vi /etc/pen.conf # create new
LOGFILE=/var/log/pen.log
WEBFILE=/var/www/pen/webstats.html CONTROL=127.0.0.1:10080 MAX_CONNECTIONS=256 ROUNDROBIN=true # listening port PORT=3306 # number of backends BACKEND=2 # define backend servers SERVER1=10.0.0.51:3306 SERVER2=10.0.0.52:3306 /etc/rc.d/init.d/pend restart Stopping Pend: [ OK ] Starting Pend: [ OK ] |
[2] | Make sure all works fine to access to the frontend server from a Client with SQL like follows. |
[root@desktop ~]# mysql -u keystone -p -h 10.0.0.30 keystone -e "select * from table01;" Enter password: +------+-------------------+ | id | name | +------+-------------------+ | 1 | db01.srv.world | +------+-------------------+[root@desktop ~]# mysql -u keystone -p -h 10.0.0.30 keystone -e "select * from table01;" Enter password: +------+-------------------+ | id | name | +------+-------------------+ | 1 | db02.srv.world | +------+-------------------+ |