MySQL agent: mysql-proxy implements read and write separation
This article system Centos6.0
MySQL Agent is a simple program between a MySQL client and a MySQL server that can be used to monitor, analyze, or transmit communications between them.Its flexibility allows you to use it to the fullest, including load balancing, fault tolerance, analytical query and correction, and more.
master : 192.168.182.128
slave : 192.168.182.129
mysql-proxy: 192.168.182.130
1.Install the database on the master and slave servers;
Master, slave operation:
[root@master ~]# yum install mysql mysql-devel-y
Configure master-slave replication;
master:
vim/etc/my.cnf log-bin=mysql-bin #Add server-id=1 #Add
slave:
vim/etc/my.cnf log-bin=mysql-bin #Add server-id=2 #Add
master: Add authorized user;
mysql> grant replication slave on *.* to 'leo'@'%'identified by 'leo123';
slave:
mysql> change master to master_host='192.168.182.128',master_user='leo',master_password='leo123',master_log_file='mysql-bin.000001',master_log_pos=247; mysql>start slave;
View Status:
Master-slave replication is ok;
Configure read-write separation on mysql-proxy below;
[root@mysql-proxy ~]# wget http://cdn.mysql.com/Downloads/MySQL-Proxy/mysql-proxy-0.8.3-linux-glibc2.3-x86-32bit.tar.gz [root@mysql-proxy ~]# useradd-r mysql-proxy [root@mysql-proxy ~]# tar zxvf mysql-proxy-0.8.3-linux-glibc2.3-x86-32bit.tar.gz-C/usr/local [root@mysql-proxy ~]# mv/usr/local/mysql-proxy-0.8.3-linux-glibc2.3-x86-32bit/usr/local/mysql-proxy [root@mysql-proxy ~]# export PATH=$PATH:/usr/local/mysql-proxy/bin/ [root@mysql-proxy ~]# echo "PATH=$PATH:/usr/local/mysql-proxy/bin">>/etc/profile
Let's first introduce the relevant parameters of mysql-proxy;
--help-all : Get all help information; --proxy-address=host:port : The address and port where the proxy service listens; --admin-address=host:port : The address and port where the management module listens; --proxy-backend-addresses=host:port : The address and port of the backend mysql server; --proxy-read-only-backend-addresses=host:port : The address and port of the backend read-only mysql server; --proxy-lua-script=file_name : The Lua script that completes the mysql proxy function; --daemon : start mysql-proxy in daemon mode; --keepalive : try to restart mysql-proxy when it crashes; --log-file=/path/to/log_file_name : log file name; --log-level=level : log level; --log-use-syslog : log based on syslog; --plugins=plugin: plugins loaded when mysql-proxy starts; --user=user_name : the user running the mysql-proxy process; --defaults-file=/path/to/conf_file_name : The default configuration file path; its configuration segment is identified by [mysql-proxy]; --proxy-skip-profiling : disable profiling; --pid-file=/path/to/pid_file_name : process file name;
Let's start:
First create a test user on the masterslave for remote use
master:
mysql> grant all on *.* to root@'%'identified by 'root123';
No operation on the slave; I configure the mysql library to be synchronized; so there is no need for redundant operations;
Start-up:
[root@mysql-proxy ~]# mysql-proxy--daemon--log-level=debug--user=mysql-proxy--keepalive--log-file=/var/log/mysql-proxy.log--plugins="proxy"--proxy-backend-addresses="192.168.182.128:3306"--proxy-read-only-backend-addresses="192.168.182.129:3306"--proxy-lua-script="/usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua"--plugins=admin--admin-username="admin"--admin-password="admin"--admin-lua-script="/usr/local/mysql-proxy/lib/mysql-proxy/lua/admin.lua"
View related information:
495 process is mysql-proxy to start the process
root is keepalive at work; try to restart when the process crashes; this is also a new feature of mysql-proxy;
4040 is the proxy port; 4041 is the admin port; that is, management
Tested below;
Open several terminals;
Log in to admin to view
Because the rw-splitting.lu
a script has 4 links by default to enable splitting; so open a few more terminals; test a few more times; you can also modify The relevant value inside;
The state appears; the separation is successful;
This article is from "Coffee_Blue Mountain" blog, please keep this source http://lansgg.blog.51cto.com/5675165/1242674
buy generic atorvastatin 40mg & lt;a href="https://lipiws.top/"& gt;order generic lipitor 20mg& lt;/a& gt; order atorvastatin pill
Kdhles
2024-03-07