文章转载自:https://blog.51cto.com/lee90/2298804

官方文档: https://proxysql.com/blog/proxysql-cluster

环境架构

在一主两从的MySQL主机上各安装一个proxysql

MySQL环境

主库 172.100.2.13

从库1 172.100.2.11

从库2 172.100.2.14

proxysql节点

172.100.2.13

172.100.2.11

172.100.2.14

具体操作步骤

在主库 172.100.2.13 上执行添加账号的操作

# 添加一个监控用账号(能监控到从库的复制情况) ,在这里要么主从库自带的mysql库需要同步,若是没同步则每个MySQL都需要做这一步操作

GRANT USAGE,process,replication slave,replication client ON *.* TO 'proxysql'@'172.100.%.%' IDENTIFIED BY 'proxysql';   

# 注意:这里的账号密码要和下面我们在proxysql里面的mysql_variables段的账号密码配置的一样

# 添加一个程序连接用的账号

GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO 'sbuser'@'172.100.%.%' identified by 'sbuser';

在3台proxysql机器上,执行如下的操作

修改 /etc/proxysql.cnf (修改了admin_variables段、proxysql_servers段、mysql_variables段)

datadir="/var/lib/proxysql"
admin_variables =
{
admin_credentials="admin:admin;cluster_demo:123456"
mysql_ifaces="0.0.0.0:6032"
cluster_username="cluster_demo"
cluster_password="123456"
cluster_check_interval_ms=200
cluster_check_status_frequency=100
cluster_mysql_query_rules_save_to_disk=true
cluster_mysql_servers_save_to_disk=true
cluster_mysql_users_save_to_disk=true
cluster_proxysql_servers_save_to_disk=true
cluster_mysql_query_rules_diffs_before_sync=3
cluster_mysql_servers_diffs_before_sync=3
cluster_mysql_users_diffs_before_sync=3
cluster_proxysql_servers_diffs_before_sync=3
}
proxysql_servers =
(
{
hostname="172.100.2.11"
port=6032
comment="proxysql11"
},
{
hostname="172.100.2.13"
port=6032
comment="proxysql13"
},
{
hostname="172.100.2.14"
port=6032
comment="proxysql14"
}
)
mysql_variables=
{
threads=4
max_connections=2048
default_query_delay=0
default_query_timeout=36000000
have_compress=true
poll_timeout=2000
# interfaces="0.0.0.0:6033;/tmp/proxysql.sock"
interfaces="0.0.0.0:6033"
default_schema="information_schema"
stacksize=1048576
server_version="5.7.22"
connect_timeout_server=3000
# make sure to configure monitor username and password
# https://github.com/sysown/proxysql/wiki/Global-variables#mysql-monitor_username-mysql-monitor_password
monitor_username="proxysql"
monitor_password="proxysql"
monitor_history=600000
monitor_connect_interval=60000
monitor_ping_interval=10000
monitor_read_only_interval=1500
monitor_read_only_timeout=500
ping_interval_server_msec=120000
ping_timeout_server=500
commands_stats=true
sessions_sort=true
connect_retries_on_failure=10
}
# 启动proxysql进程
systemctl start proxysql # 然后到3个节点上都确认下是否正常运行
admin@127.0.0.1:(none) 01:19:38>select * from runtime_proxysql_servers ;
+--------------+------+--------+------------+
| hostname | port | weight | comment |
+--------------+------+--------+------------+
| 172.100.2.14 | 6032 | 0 | proxysql14 |
| 172.100.2.13 | 6032 | 0 | proxysql13 |
| 172.100.2.11 | 6032 | 0 | proxysql11 |
+--------------+------+--------+------------+ # 3个节点都是这样的话,就可以做其他操作了。

添加后端mysql信息, 添加读写分离的路由规则

添加后端mysql信息

在3节点中的任意一台proyxql的admin控制台执行下面的这些操作(这个新增的配置会在load runtime时候,自动同步到集群其它节点) :

# 写节点组 100, 读节点组 1000
delete from mysql_servers ;
insert into mysql_servers(hostgroup_id,hostname,port,weight,max_connections,max_replication_lag,comment) values(100,'172.100.2.13',3306,1,1000,10,'test proxysql');
insert into mysql_servers(hostgroup_id,hostname,port,weight,max_connections,max_replication_lag,comment) values(1000,'172.100.2.11',3306,1,1000,10,'test proxysql');
insert into mysql_servers(hostgroup_id,hostname,port,weight,max_connections,max_replication_lag,comment) values(1000,'172.100.2.14',3306,1,1000,10,'test proxysql'); select * from mysql_servers; # proxysql的核心都在规则,若是从节点关闭,proxysql还是想路由到 hostgroup=1000,它不会自动选择默认的100(mysql_users里配置的default_hostgroup) 。
# 这里解决的办法是:在mysql_servers的hostgroup 1000 里面要插一条主库的记录,然后把weight设小,当读不到从库,回去主库查询。
# 修改之前的从库的权限为9
update mysql_servers set weight=9 where hostgroup_id=100 and hostname='172.100.2.11' ;
update mysql_servers set weight=9 where hostgroup_id=100 and hostname='172.100.2.14' ; # 插入一条记录,权重为1
insert into mysql_servers(hostgroup_id,hostname,port,weight,max_connections,max_replication_lag,comment) values(1000,'172.100.2.13',3306,1,1000,10,'test proxysql'); # 意思是: 读组里有三个节点,一主两从,但是节点权重不一样,从节点权重高,读请求优先给从节点,若从节点关机导致无法访问,此时会把读请求给权重较低的主节点 # 加载到runtime,并把配置持久化
load mysql servers to runtime;
save mysql servers to disk; admin@127.0.0.1:(none) 02:31:37>select * from mysql_servers;
+--------------+--------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------------+
| hostgroup_id | hostname | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
+--------------+--------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------------+
| 100 | 172.100.2.11 | 3306 | ONLINE | 9 | 0 | 1000 | 10 | 0 | 0 | test proxysql |
| 100 | 172.100.2.14 | 3306 | ONLINE | 9 | 0 | 1000 | 10 | 0 | 0 | test proxysql |
| 1000 | 172.100.2.13 | 3306 | ONLINE | 1 | 0 | 1000 | 10 | 0 | 0 | test proxysql |
| 100 | 172.100.2.13 | 3306 | ONLINE | 1 | 0 | 1000 | 10 | 0 | 0 | test proxysql |
+--------------+--------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------------+
4 rows in set (0.00 sec) admin@127.0.0.1:(none) 02:31:40>select * from runtime_mysql_servers;
+--------------+--------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------------+
| hostgroup_id | hostname | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
+--------------+--------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------------+
| 100 | 172.100.2.13 | 3306 | ONLINE | 1 | 0 | 1000 | 10 | 0 | 0 | test proxysql |
| 1000 | 172.100.2.13 | 3306 | ONLINE | 1 | 0 | 1000 | 10 | 0 | 0 | test proxysql |
| 100 | 172.100.2.14 | 3306 | ONLINE | 9 | 0 | 1000 | 10 | 0 | 0 | test proxysql |
| 100 | 172.100.2.11 | 3306 | ONLINE | 9 | 0 | 1000 | 10 | 0 | 0 | test proxysql |
+--------------+--------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------------+
4 rows in set (0.00 sec) # 添加一个账号,用于proxysql和后端主机的连接
insert into mysql_users(username,password,active,default_hostgroup,transaction_persistent) values('sbuser','sbuser',1,100,1); # 一些其他的个性化参数设置,在这里再次设置下
set mysql-monitor_username='proxysql';
set mysql-monitor_password='proxysql';
set mysql-default_charset='utf8mb4';
set mysql-query_retries_on_failure=0;
set mysql-ping_timeout_server=500;
set mysql-monitor_connect_timeout=1000;
set mysql-default_max_latency_ms=2000;
set mysql-monitor_replication_lag_interval=500;
set mysql-ping_interval_server_msec=3000;
set mysql-monitor_ping_interval=5000;
set mysql-connect_timeout_server_max=3000; # 加载到runtime,并把配置持久化
load mysql servers to runtime;
load mysql users to runtime;
load mysql variables to runtime; save mysql servers to disk;
save mysql users to disk;
save mysql variables to disk;

定义读写分离的路由规则

# 定义sql规则,发送到写组
INSERT INTO mysql_query_rules(active,match_pattern,destination_hostgroup,apply) VALUES(1,'^SELECT.*FOR UPDATE$',100,1); # 定义sql规则,发送到读组
INSERT INTO mysql_query_rules(active,match_pattern,destination_hostgroup,apply) VALUES(1,'^SELECT',1000,1); # 加载路由规则到runtime,并把配置持久化
load mysql query rules to runtime;
save mysql query rules to disk; # 然后,连接proxysql做crud的测试(可以测试下读写分离情况)
mysql -usbuser -psbuser -h 172.100.2.13 -P6033

后期还有新的机器需要加入proxysql集群中的方法

例如3台proxysql觉得性能不够用了,需要加一台新机器为 172.100.2.17 。 可以使用如下的方法:

修改 /etc/proxysql.cnf (修改了admin_variables段、proxysql_servers段、mysql_variables段) 【要和proxysql cluster里面的其他节点运行配置一样,集群名称、各种账号密码要一致】

datadir="/var/lib/proxysql"
admin_variables =
{
admin_credentials="admin:admin;cluster_demo:123456"
mysql_ifaces="0.0.0.0:6032"
cluster_username="cluster_demo"
cluster_password="123456"
cluster_check_interval_ms=200
cluster_check_status_frequency=100
cluster_mysql_query_rules_save_to_disk=true
cluster_mysql_servers_save_to_disk=true
cluster_mysql_users_save_to_disk=true
cluster_proxysql_servers_save_to_disk=true
cluster_mysql_query_rules_diffs_before_sync=3
cluster_mysql_servers_diffs_before_sync=3
cluster_mysql_users_diffs_before_sync=3
cluster_proxysql_servers_diffs_before_sync=3
}
proxysql_servers =
(
{
hostname="172.100.2.11"
port=6032
comment="proxysql11"
},
{
hostname="172.100.2.13"
port=6032
comment="proxysql13"
},
{
hostname="172.100.2.14"
port=6032
comment="proxysql14"
}
)
mysql_variables=
{
threads=4
max_connections=2048
default_query_delay=0
default_query_timeout=36000000
have_compress=true
poll_timeout=2000
# interfaces="0.0.0.0:6033;/tmp/proxysql.sock"
interfaces="0.0.0.0:6033"
default_schema="information_schema"
stacksize=1048576
server_version="5.7.22"
connect_timeout_server=3000
# make sure to configure monitor username and password
# https://github.com/sysown/proxysql/wiki/Global-variables#mysql-monitor_username-mysql-monitor_password
monitor_username="proxysql"
monitor_password="proxysql"
monitor_history=600000
monitor_connect_interval=60000
monitor_ping_interval=10000
monitor_read_only_interval=1500
monitor_read_only_timeout=500
ping_interval_server_msec=120000
ping_timeout_server=500
commands_stats=true
sessions_sort=true
connect_retries_on_failure=10
} systemctl start proxysql

启动后, 可以看下 172.100.2.17 的 /var/lib/proxysql/proxysql.log 日志里面, 172.100.2.17 这个新加入的节点 会去其它节点拉取配置(但是其它节点不知道这个172.100.2.17到底是什么身份的存在)。

然后,我们在老的proxysql的任一节点上,将 172.100.2.17 这个新节点加入到集群环境:

Q: 为啥不能在172.100.2.17这个新节点执行下面的加到集群的命令?

A: 老群集的其余部分对新启动的172.100.2.17这个新节点一无所知,这也就意味着直接应用于172.100.2.17新节点的更改将不会复制到群集的其余部分。)

官方原话(https://proxysql.com/blog/proxysql-cluster-part2):

The fact that the rest of the cluster doesn't know anything about the new node means that changes applied directly to the new node won't be replicated to the rest of the cluster.

This creates a core cluster where nodes know about each other and synchronize from each other, and nodes that can only sync from the core cluster without affecting it. This is a big plus: only the core cluster can be the source of truth.

# 插入一条proxysql_server的信息
insert into proxysql_servers(hostname,port,comment ) values('172.100.2.17',6032,'bak proxysql') ; # 加载到runtime,并把配置持久化
load proxysql servers to runtime;
save proxysql servers to disk; # 查下结果是否正常
admin@127.0.0.1:(none) 01:33:45> select * from proxysql_servers ;
+--------------+------+--------+--------------+
| hostname | port | weight | comment |
+--------------+------+--------+--------------+
| 172.100.2.14 | 6032 | 0 | proxysql14 |
| 172.100.2.13 | 6032 | 0 | proxysql13 |
| 172.100.2.11 | 6032 | 0 | proxysql11 |
| 172.100.2.17 | 6032 | 0 | bak proxysql |
+--------------+------+--------+--------------+
4 rows in set (0.01 sec) admin@127.0.0.1:(none) 01:33:49>select * from runtime_proxysql_servers ;
+--------------+------+--------+--------------+
| hostname | port | weight | comment |
+--------------+------+--------+--------------+
| 172.100.2.17 | 6032 | 0 | bak proxysql |
| 172.100.2.14 | 6032 | 0 | proxysql14 |
| 172.100.2.13 | 6032 | 0 | proxysql13 |
| 172.100.2.11 | 6032 | 0 | proxysql11 |
+--------------+------+--------+--------------+ # 看下集群proxysql_server集群的状态
admin@127.0.0.1:(none) 04:01:22> SELECT hostname, port, name, version, FROM_UNIXTIME(epoch) epoch, checksum, FROM_UNIXTIME(changed_at) changed_at, FROM_UNIXTIME(updated_at) updated_at, diff_check, DATETIME('NOW') FROM stats_proxysql_servers_checksums WHERE version > 0 ORDER BY hostname, name;
+--------------+------+-------------------+---------+---------------------+--------------------+---------------------+---------------------+------------+---------------------+
| hostname | port | name | version | epoch | checksum | changed_at | updated_at | diff_check | DATETIME('NOW') |
+--------------+------+-------------------+---------+---------------------+--------------------+---------------------+---------------------+------------+---------------------+
| 172.100.2.11 | 6032 | mysql_query_rules | 1 | 2018-10-11 07:27:26 | 0x883C0BB2C4FD83AA | 2018-10-11 07:27:26 | 2018-10-11 08:01:23 | 0 | 2018-10-11 08:01:24 |
| 172.100.2.11 | 6032 | mysql_servers | 1 | 2018-10-11 07:27:26 | 0x73399E62D70543AA | 2018-10-11 07:27:26 | 2018-10-11 08:01:23 | 0 | 2018-10-11 08:01:24 |
| 172.100.2.11 | 6032 | mysql_users | 3 | 2018-10-11 07:45:21 | 0x5C08D3C8E9D57E7B | 2018-10-11 07:27:26 | 2018-10-11 08:01:23 | 0 | 2018-10-11 08:01:24 |
| 172.100.2.11 | 6032 | proxysql_servers | 1 | 2018-10-11 07:27:26 | 0xEF3F04DA70472767 | 2018-10-11 07:27:26 | 2018-10-11 08:01:23 | 0 | 2018-10-11 08:01:24 |
| 172.100.2.13 | 6032 | mysql_query_rules | 4 | 2018-10-11 05:05:45 | 0x883C0BB2C4FD83AA | 2018-10-11 07:27:26 | 2018-10-11 08:01:23 | 0 | 2018-10-11 08:01:24 |
| 172.100.2.13 | 6032 | mysql_servers | 4 | 2018-10-11 06:31:24 | 0x73399E62D70543AA | 2018-10-11 07:27:26 | 2018-10-11 08:01:23 | 0 | 2018-10-11 08:01:24 |
| 172.100.2.13 | 6032 | mysql_users | 3 | 2018-10-11 03:03:11 | 0x5C08D3C8E9D57E7B | 2018-10-11 07:27:26 | 2018-10-11 08:01:23 | 0 | 2018-10-11 08:01:24 |
| 172.100.2.13 | 6032 | proxysql_servers | 6 | 2018-10-11 05:33:24 | 0xEF3F04DA70472767 | 2018-10-11 07:27:26 | 2018-10-11 08:01:23 | 0 | 2018-10-11 08:01:24 |
| 172.100.2.14 | 6032 | mysql_query_rules | 1 | 2018-10-11 07:32:19 | 0x883C0BB2C4FD83AA | 2018-10-11 07:32:19 | 2018-10-11 08:01:24 | 0 | 2018-10-11 08:01:24 |
| 172.100.2.14 | 6032 | mysql_servers | 1 | 2018-10-11 07:32:19 | 0x73399E62D70543AA | 2018-10-11 07:32:19 | 2018-10-11 08:01:24 | 0 | 2018-10-11 08:01:24 |
| 172.100.2.14 | 6032 | mysql_users | 1 | 2018-10-11 07:32:19 | 0x5C08D3C8E9D57E7B | 2018-10-11 07:32:19 | 2018-10-11 08:01:24 | 0 | 2018-10-11 08:01:24 |
| 172.100.2.14 | 6032 | proxysql_servers | 1 | 2018-10-11 07:32:19 | 0xEF3F04DA70472767 | 2018-10-11 07:32:19 | 2018-10-11 08:01:24 | 0 | 2018-10-11 08:01:24 |
| 172.100.2.17 | 6032 | mysql_query_rules | 2 | 2018-10-11 05:30:41 | 0x883C0BB2C4FD83AA | 2018-10-11 07:27:26 | 2018-10-11 08:01:24 | 0 | 2018-10-11 08:01:24 |
| 172.100.2.17 | 6032 | mysql_servers | 3 | 2018-10-11 06:31:23 | 0x73399E62D70543AA | 2018-10-11 07:27:26 | 2018-10-11 08:01:24 | 0 | 2018-10-11 08:01:24 |
| 172.100.2.17 | 6032 | mysql_users | 2 | 2018-10-11 05:30:41 | 0x5C08D3C8E9D57E7B | 2018-10-11 07:27:26 | 2018-10-11 08:01:24 | 0 | 2018-10-11 08:01:24 |
| 172.100.2.17 | 6032 | proxysql_servers | 2 | 2018-10-11 05:33:24 | 0xEF3F04DA70472767 | 2018-10-11 07:27:26 | 2018-10-11 08:01:24 | 0 | 2018-10-11 08:01:24 |
+--------------+------+-------------------+---------+---------------------+--------------------+---------------------+---------------------+------------+---------------------+
16 rows in set (0.00 sec) 经过上面的步骤后, 172.100.2.17 就完成加集群的操作了。

其他一些tips

1.当群集处于活动状态时,proxysql会为每个活动模块的配置生成校验和。让我们连接到任何proxysql管理界面,并检查当前配置校验和:

admin@127.0.0.1:(none) 01:35:40>SELECT * FROM runtime_checksums_values ORDER BY name;
+-------------------+---------+------------+--------------------+
| name | version | epoch | checksum |
+-------------------+---------+------------+--------------------+
| admin_variables | 0 | 0 | |
| mysql_query_rules | 4 | 1539234345 | 0x883C0BB2C4FD83AA |
| mysql_servers | 3 | 1539226934 | 0xC19E3DC77E992B47 |
| mysql_users | 3 | 1539226934 | 0x5C08D3C8E9D57E7B |
| mysql_variables | 0 | 0 | |
| proxysql_servers | 7 | 1539236004 | 0xEF3F04DA70472767 |
+-------------------+---------+------------+--------------------+ # version为0, 表示没有这个类的数据没有改动过。

2.查看整个集群的状态

admin@127.0.0.1:(none) 01:35:46>SELECT * FROM stats_proxysql_servers_checksums;
+--------------+------+-------------------+---------+------------+--------------------+------------+------------+------------+
| hostname | port | name | version | epoch | checksum | changed_at | updated_at | diff_check |
+--------------+------+-------------------+---------+------------+--------------------+------------+------------+------------+
| 172.100.2.17 | 6032 | admin_variables | 0 | 0 | | 0 | 1539236272 | 0 |
| 172.100.2.17 | 6032 | mysql_query_rules | 2 | 1539235841 | 0x883C0BB2C4FD83AA | 1539236004 | 1539236272 | 0 |
| 172.100.2.17 | 6032 | mysql_servers | 2 | 1539235841 | 0xC19E3DC77E992B47 | 1539236004 | 1539236272 | 0 |
| 172.100.2.17 | 6032 | mysql_users | 2 | 1539235841 | 0x5C08D3C8E9D57E7B | 1539236004 | 1539236272 | 0 |
| 172.100.2.17 | 6032 | mysql_variables | 0 | 0 | | 0 | 1539236272 | 0 |
| 172.100.2.17 | 6032 | proxysql_servers | 2 | 1539236004 | 0xEF3F04DA70472767 | 1539236004 | 1539236272 | 0 |
| 172.100.2.14 | 6032 | admin_variables | 0 | 0 | | 0 | 1539236272 | 0 |
| 172.100.2.14 | 6032 | mysql_query_rules | 4 | 1539234345 | 0x883C0BB2C4FD83AA | 1539234346 | 1539236272 | 0 |
| 172.100.2.14 | 6032 | mysql_servers | 3 | 1539226934 | 0xC19E3DC77E992B47 | 1539226713 | 1539236272 | 0 |
| 172.100.2.14 | 6032 | mysql_users | 3 | 1539226934 | 0x5C08D3C8E9D57E7B | 1539226713 | 1539236272 | 0 |
| 172.100.2.14 | 6032 | mysql_variables | 0 | 0 | | 0 | 1539236272 | 0 |
| 172.100.2.14 | 6032 | proxysql_servers | 7 | 1539236004 | 0xEF3F04DA70472767 | 1539236004 | 1539236272 | 0 |
| 172.100.2.13 | 6032 | admin_variables | 0 | 0 | | 0 | 1539236272 | 0 |
| 172.100.2.13 | 6032 | mysql_query_rules | 4 | 1539234345 | 0x883C0BB2C4FD83AA | 1539234346 | 1539236272 | 0 |
| 172.100.2.13 | 6032 | mysql_servers | 3 | 1539226991 | 0xC19E3DC77E992B47 | 1539226714 | 1539236272 | 0 |
| 172.100.2.13 | 6032 | mysql_users | 3 | 1539226991 | 0x5C08D3C8E9D57E7B | 1539226714 | 1539236272 | 0 |
| 172.100.2.13 | 6032 | mysql_variables | 0 | 0 | | 0 | 1539236272 | 0 |
| 172.100.2.13 | 6032 | proxysql_servers | 6 | 1539236004 | 0xEF3F04DA70472767 | 1539236004 | 1539236272 | 0 |
| 172.100.2.11 | 6032 | admin_variables | 0 | 0 | | 0 | 1539236272 | 0 |
| 172.100.2.11 | 6032 | mysql_query_rules | 4 | 1539234345 | 0x883C0BB2C4FD83AA | 1539234345 | 1539236272 | 0 |
| 172.100.2.11 | 6032 | mysql_servers | 3 | 1539226994 | 0xC19E3DC77E992B47 | 1539226714 | 1539236272 | 0 |
| 172.100.2.11 | 6032 | mysql_users | 3 | 1539226994 | 0x5C08D3C8E9D57E7B | 1539226714 | 1539236272 | 0 |
| 172.100.2.11 | 6032 | mysql_variables | 0 | 0 | | 0 | 1539236272 | 0 |
| 172.100.2.11 | 6032 | proxysql_servers | 6 | 1539236003 | 0xEF3F04DA70472767 | 1539236003 | 1539236272 | 0 |
+--------------+------+-------------------+---------+------------+--------------------+------------+------------+------------+
24 rows in set (0.00 sec) admin@127.0.0.1:(none) 01:40:02>SELECT hostname, port, name, version, FROM_UNIXTIME(epoch) epoch, checksum, FROM_UNIXTIME(changed_at) changed_at, FROM_UNIXTIME(updated_at) updated_at, diff_check, DATETIME('NOW') FROM stats_proxysql_servers_checksums WHERE version > 0 ORDER BY hostname, name;
+--------------+------+-------------------+---------+---------------------+--------------------+---------------------+---------------------+------------+---------------------+
| hostname | port | name | version | epoch | checksum | changed_at | updated_at | diff_check | DATETIME('NOW') |
+--------------+------+-------------------+---------+---------------------+--------------------+---------------------+---------------------+------------+---------------------+
| 172.100.2.11 | 6032 | mysql_query_rules | 4 | 2018-10-11 05:05:45 | 0x883C0BB2C4FD83AA | 2018-10-11 05:05:45 | 2018-10-11 05:40:02 | 0 | 2018-10-11 05:40:02 |
| 172.100.2.11 | 6032 | mysql_servers | 3 | 2018-10-11 03:03:14 | 0xC19E3DC77E992B47 | 2018-10-11 02:58:34 | 2018-10-11 05:40:02 | 0 | 2018-10-11 05:40:02 |
| 172.100.2.11 | 6032 | mysql_users | 3 | 2018-10-11 03:03:14 | 0x5C08D3C8E9D57E7B | 2018-10-11 02:58:34 | 2018-10-11 05:40:02 | 0 | 2018-10-11 05:40:02 |
| 172.100.2.11 | 6032 | proxysql_servers | 6 | 2018-10-11 05:33:23 | 0xEF3F04DA70472767 | 2018-10-11 05:33:23 | 2018-10-11 05:40:02 | 0 | 2018-10-11 05:40:02 |
| 172.100.2.13 | 6032 | mysql_query_rules | 4 | 2018-10-11 05:05:45 | 0x883C0BB2C4FD83AA | 2018-10-11 05:05:46 | 2018-10-11 05:40:02 | 0 | 2018-10-11 05:40:02 |
| 172.100.2.13 | 6032 | mysql_servers | 3 | 2018-10-11 03:03:11 | 0xC19E3DC77E992B47 | 2018-10-11 02:58:34 | 2018-10-11 05:40:02 | 0 | 2018-10-11 05:40:02 |
| 172.100.2.13 | 6032 | mysql_users | 3 | 2018-10-11 03:03:11 | 0x5C08D3C8E9D57E7B | 2018-10-11 02:58:34 | 2018-10-11 05:40:02 | 0 | 2018-10-11 05:40:02 |
| 172.100.2.13 | 6032 | proxysql_servers | 6 | 2018-10-11 05:33:24 | 0xEF3F04DA70472767 | 2018-10-11 05:33:24 | 2018-10-11 05:40:02 | 0 | 2018-10-11 05:40:02 |
| 172.100.2.14 | 6032 | mysql_query_rules | 4 | 2018-10-11 05:05:45 | 0x883C0BB2C4FD83AA | 2018-10-11 05:05:46 | 2018-10-11 05:40:02 | 0 | 2018-10-11 05:40:02 |
| 172.100.2.14 | 6032 | mysql_servers | 3 | 2018-10-11 03:02:14 | 0xC19E3DC77E992B47 | 2018-10-11 02:58:33 | 2018-10-11 05:40:02 | 0 | 2018-10-11 05:40:02 |
| 172.100.2.14 | 6032 | mysql_users | 3 | 2018-10-11 03:02:14 | 0x5C08D3C8E9D57E7B | 2018-10-11 02:58:33 | 2018-10-11 05:40:02 | 0 | 2018-10-11 05:40:02 |
| 172.100.2.14 | 6032 | proxysql_servers | 7 | 2018-10-11 05:33:24 | 0xEF3F04DA70472767 | 2018-10-11 05:33:24 | 2018-10-11 05:40:02 | 0 | 2018-10-11 05:40:02 |
| 172.100.2.17 | 6032 | mysql_query_rules | 2 | 2018-10-11 05:30:41 | 0x883C0BB2C4FD83AA | 2018-10-11 05:33:24 | 2018-10-11 05:40:02 | 0 | 2018-10-11 05:40:02 |
| 172.100.2.17 | 6032 | mysql_servers | 2 | 2018-10-11 05:30:41 | 0xC19E3DC77E992B47 | 2018-10-11 05:33:24 | 2018-10-11 05:40:02 | 0 | 2018-10-11 05:40:02 |
| 172.100.2.17 | 6032 | mysql_users | 2 | 2018-10-11 05:30:41 | 0x5C08D3C8E9D57E7B | 2018-10-11 05:33:24 | 2018-10-11 05:40:02 | 0 | 2018-10-11 05:40:02 |
| 172.100.2.17 | 6032 | proxysql_servers | 2 | 2018-10-11 05:33:24 | 0xEF3F04DA70472767 | 2018-10-11 05:33:24 | 2018-10-11 05:40:02 | 0 | 2018-10-11 05:40:02 |
+--------------+------+-------------------+---------+---------------------+--------------------+---------------------+---------------------+------------+---------------------+
16 rows in set (0.00 sec) admin@127.0.0.1:(none) 01:40:02>SELECT hostname, port, name, version, FROM_UNIXTIME(epoch) epoch, checksum, FROM_UNIXTIME(changed_at) changed_at, FROM_UNIXTIME(updated_at) updated_at, diff_check, DATETIME('NOW') FROM stats_proxysql_servers_checksums WHERE name='mysql_users' ORDER BY hostname, name;
+--------------+------+-------------+---------+---------------------+--------------------+---------------------+---------------------+------------+---------------------+
| hostname | port | name | version | epoch | checksum | changed_at | updated_at | diff_check | DATETIME('NOW') |
+--------------+------+-------------+---------+---------------------+--------------------+---------------------+---------------------+------------+---------------------+
| 172.100.2.11 | 6032 | mysql_users | 3 | 2018-10-11 03:03:14 | 0x5C08D3C8E9D57E7B | 2018-10-11 02:58:34 | 2018-10-11 05:40:45 | 0 | 2018-10-11 05:40:45 |
| 172.100.2.13 | 6032 | mysql_users | 3 | 2018-10-11 03:03:11 | 0x5C08D3C8E9D57E7B | 2018-10-11 02:58:34 | 2018-10-11 05:40:45 | 0 | 2018-10-11 05:40:45 |
| 172.100.2.14 | 6032 | mysql_users | 3 | 2018-10-11 03:02:14 | 0x5C08D3C8E9D57E7B | 2018-10-11 02:58:33 | 2018-10-11 05:40:45 | 0 | 2018-10-11 05:40:45 |
| 172.100.2.17 | 6032 | mysql_users | 2 | 2018-10-11 05:30:41 | 0x5C08D3C8E9D57E7B | 2018-10-11 05:33:24 | 2018-10-11 05:40:45 | 0 | 2018-10-11 05:40:45 |
+--------------+------+-------------+---------+---------------------+--------------------+---------------------+---------------------+------------+---------------------+
4 rows in set (0.00 sec) # 注意: LOAD xxx TO RUNTIME 这种会改变version号。 如果 version=1 则会被当做是proxysql初次启动信息,信息不会被同步到其它节点去。

proxysql cluster 的搭建的更多相关文章

  1. 【ProxySQL】ProxySQL Cluster的搭建

    文章转载自:https://blog.51cto.com/l0vesql/2104643 背景 早期的ProxySQL若需要做高可用,需要搭建两个实例,进行冗余.但两个ProxySQL实例之间的数据并 ...

  2. ProxySQL Cluster的搭建

    环境: proxysql-1.4.10-1-centos7.x86_64 db210 192.168.99.210 老节点,已经做成mysql配置和读写分离设置db211 192.168.99.211 ...

  3. 重要参考步骤---ProxySQL Cluster 集群搭建步骤

    环境 proxysql-1:192.168.20.202 proxysql-2:192.168.20.203 均采用yum方式安装 # cat <<EOF | tee /etc/yum.r ...

  4. ProxySQL Cluster 高可用集群环境部署记录

    ProxySQL在早期版本若需要做高可用,需要搭建两个实例,进行冗余.但两个ProxySQL实例之间的数据并不能共通,在主实例上配置后,仍需要在备用节点上进行配置,对管理来说非常不方便.但是Proxy ...

  5. ProxySQL Cluster 高可用集群 + MySQL MGR环境部署 (多写模式) 部署记录

    文章转载自:https://blog.51cto.com/u_6215974/4937192 ProxySQL 在早期版本若需要做高可用,需要搭建两个实例,进行冗余.但两个ProxySQL实例之间的数 ...

  6. Redis Cluster的搭建与部署,实现redis的分布式方案

    前言 上篇Redis Sentinel安装与部署,实现redis的高可用实现了redis的高可用,针对的主要是master宕机的情况,我们发现所有节点的数据都是一样的,那么一旦数据量过大,redi也会 ...

  7. 服务发现 consul cluster 的搭建【转】

    consul cluster setup 介绍和指南: consul用于服务发现.当底层服务发生变化时,能及时更新正确的mysql服务IP. 并提供给业务查询.但需要自行编写脚本,监测数据库状态和切断 ...

  8. redis单点、redis主从、redis哨兵sentinel,redis集群cluster配置搭建与使用

    目录 redis单点.redis主从.redis哨兵 sentinel,redis集群cluster配置搭建与使用 1 .redis 安装及配置 1.1 redis 单点 1.1.2 在命令窗口操作r ...

  9. ProxySQL Cluster 概述

    文章转载自:https://blog.csdn.net/n88Lpo/article/details/79608639 前言 在ProxySQL 1.4.2 之前,ProxySQL 单点的解决方法有配 ...

随机推荐

  1. lerna源码阅读

    能够找到入口文件 能够本地调试

  2. Tapdata 与阿里云 PolarDB 开源数据库社区联合共建开放数据技术生态

      近日,阿里云 PolarDB 开源数据库社区宣布将与 Tapdata 联合共建开放数据技术生态.在此之际,一直专注实时数据服务平台的 Tapdata ,也宣布开源其数据源开发框架--PDK(Plu ...

  3. pytorch 基础内容

    一些基础的操作: import torch as th a=th.rand(3,4) #随机数,维度为3,4的tensor b=th.rand(4)print(a)print(b) a+b tenso ...

  4. 【cartogarpher_ros】三: 发布和订阅雷达scan信息

    上一节介绍和测试了cartographer的官方demo. 本节会编写ros系统中,最常用的激光雷达LaserScan传感数据的订阅和发布,方便在cartographer中加入自己的数据进行建图与定位 ...

  5. spring-security 配置简介

    1.Spring Security 简介 Spring Security 是一个能够基于 Spring 的企业应用系统提供声明式的安全访问控制解决方案的安全框架.它提供了一组可以在 Spring 应用 ...

  6. Spring 核心概念

    Spring 核心概念 引言 本文主要介绍 Spring 源码中使用到的一些核心类 1. BeanDefinition BeanDefinition表示Bean定义,BeanDefinition 中存 ...

  7. Solution -「Hdu3037」Saving Beans

    Prob. 给定 \(m\) 个相同球,\(n\) 个不同的盒子. 求在这 \(n\) 个盒子中放不超过 \(m\) 个球的方案数,并对 \(p\) 取模. 其中 \(1 \leq n, m \leq ...

  8. 关于分组查询的一道sql题

    背景:想做一道sql的测试题,题目为: 按照角色分组算出每个角色按有办公室和没办公室的统计人数(列出角色,数量,有无办公室,注意一个角色如果部分有办公室,部分没有需分开统计) 如下,构造测试环境与对应 ...

  9. 基于gRPC编写golang简单C2远控

    概述 构建一个简单的远控木马需要编写三个独立的部分:植入程序.服务端程序和管理程序. 植入程序是运行在目标机器上的远控木马的一部分.植入程序会定期轮询服务器以查找新的命令,然后将命令输出发回给服务器. ...

  10. Mysql 数据恢复流程 基于binlog redolog undolog

    注:文中有个易混淆的地方 sql事务,即每次数据库操作生成的事务,这个事务trx_id只在undolog里存储,同时undolog维护了此事务是否完成的状态. 日志持久化事务,为了保证redolog和 ...