proxysql介绍
ProxySQL is a high performance, high availability, protocol aware proxy for MySQL and forks (like Percona Server and MariaDB). All the while getting the unlimited freedom that comes with a GPL license.
Its development is driven by the lack of open source proxies that provide high performance.
ProxySQL是一种针对mysql及其分支(如Percona,MariaDB)的一种高性能,高可用的代理协议。
ProxySQl之所以被开发出来是因为市面上缺少开源高可用的开源代理。
ProxySQL测试
proxysql安装:
cat <<EOF | tee /etc/yum.repos.d/proxysql.repo
[proxysql_repo]
name= ProxySQL YUM repository
baseurl=http://repo.proxysql.com/ProxySQL/proxysql-1.4.x/centos/\$releasever
gpgcheck=1
gpgkey=http://repo.proxysql.com/ProxySQL/repo_pub_key
EOF
yum makecache
yum install proxysql
proxysql -V
#ProxySQL version 1.4.12-9-g216b872, codename Truls
proxysql配置
需要注意的是proxysql的配置是支持动态配置的。
程序运行时会先读取sqlitedb(如果存在的话),否则就读取配置文件。部分参数是即使sqlitedb存在也读取配置文件的:
如下。
配置流程图如下:
datadir
: it defines the path of ProxySQL datadir, where database file, logs and other files are storedrestart_on_missing_heartbeats
(new in 1.4.4) : if MySQL threads missrestart_on_missing_heartbeats
heartbeats, proxysql will raise aSIGABRT
signal and restart. Default is 10 . See watchdog .execute_on_exit_failure
(new in 1.4.4) : if set, ProxySQL parent process will execute the defined script every time ProxySQL crashes. It is recommended to use this setting to generate an alert or log the event. Note that proxysql is able to restart in few milliseconds in case of crash, therefore it is possible that a normal failure is not detected by other monitoring tools.
+-------------------------+
| RUNTIME |
+-------------------------+
/|\ |
| |
[1] | [2] |
| \|/
+-------------------------+
| MEMORY |
+-------------------------+ _
/|\ | |\
| | \
[3] | [4] | \ [5]
| \|/ \
+-------------------------+ +-------------------------+
| DISK | | CONFIG FILE |
+-------------------------+ +-------------------------+
如上:
runtime----内存中保存的配置数据结构。直接用来进程处理请求。包含:实际连接的后端server列表。实际的全局变量,能连接proxysql的用户。用户无法直接设置runtime的数据。需要通过底层调用来修改。
memory(也可被叫做main)--存在于内存的中的db.这个db暴露出兼容mysql的接口供用户连接进行配置项修改。以下配置可以在该处进行修改:
- mysql_servers -- the list of backend servers which ProxySQL connects to
- mysql_users -- the list of users and their credentials which connect to ProxySQL. Please note that ProxyS