前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >proxysql cluster 的搭建

proxysql cluster 的搭建

作者头像
保持热爱奔赴山海
发布2019-09-17 14:21:21
1.4K0
发布2019-09-17 14:21:21
举报
文章被收录于专栏:饮水机管理员饮水机管理员

proxysql cluster 搭建笔记

官方文档: 

https://proxysql.com/blog/proxysql-cluster

https://proxysql.com/blog/proxysql-cluster-part2  

image.png
image.png

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 上执行添加账号的操作:

    -- 添加一个监控用账号(能监控到从库的复制情况)

    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段)

代码语言:javascript
复制
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      启动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信息, 添加读写分离的路由规则。

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

代码语言:javascript
复制
# 写节点组 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 ;

roxysql的核心都在规则,shutdown从之后,proxysql还是想路由到 hostgroup=1000,它不会自动选择默认的100(mysql_users里配置的default_hostgroup) 。

这里解决的办法是:在mysql_servers的hostgroup 1000 里面要插一条主库的记录,然后把weight设小,当读不到从库,回去主库查询。

代码语言:javascript
复制

# 修改之前的从库的权限为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)

代码语言:javascript
复制
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)

代码语言:javascript
复制
-- 添加一个账号,用于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;

定义读写分离的路由规则:

代码语言:javascript
复制
-- 定义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 。 可以使用如下的方法:

在 172.100.2.17 上配置文件:

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

代码语言:javascript
复制
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.

代码语言:javascript
复制
-- 插入一条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)

代码语言:javascript
复制
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(持续补充中): 

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

代码语言:javascript
复制
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, 表示没有这个类的数据没有改动过。

要查看整个集群的状态:

代码语言:javascript
复制
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)

代码语言:javascript
复制
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)

代码语言:javascript
复制
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初次启动信息,信息不会被同步到其它节点去。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018-10-11 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
访问管理
访问管理(Cloud Access Management,CAM)可以帮助您安全、便捷地管理对腾讯云服务和资源的访问。您可以使用CAM创建子用户、用户组和角色,并通过策略控制其访问范围。CAM支持用户和角色SSO能力,您可以根据具体管理场景针对性设置企业内用户和腾讯云的互通能力。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档