proxysql cluster 的搭建

proxysql cluster 搭建筆記


官方文檔: 

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

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



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


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個節點上都確認下是否正常運行。


[email protected]:(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時候,自動同步到集羣其它節點) :

# 寫節點組 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設小,當讀不到從庫,回去主庫查詢。

# 修改之前的從庫的權限爲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;

[email protected]:(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)



[email protected]:(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 。 可以使用如下的方法:



在 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;




-- 查下結果是否正常

[email protected]:(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)


[email protected]:(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集羣的狀態

[email protected]:(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管理界面,並檢查當前配置校驗和:


[email protected]:(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, 表示沒有這個類的數據沒有改動過。






要查看整個集羣的狀態:


[email protected]:(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)





[email protected]:(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)




[email protected]:(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初次啓動信息,信息不會被同步到其它節點去。




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章