greatsql mgr集群+proxysql,通过proxysql 写操作无法进行故障转移
你好,我部署了3台mgr的集群和1台proxysql做代理节点,部署完proxysql,读操作能正常实现自动轮询,
Admin>select hostgroup_id,hostname,port,status from runtime_mysql_servers;
+--------------+----------------+------+--------+
| hostgroup_id | hostname | port | status |
+--------------+----------------+------+--------+
| 10 | 192.168.209.26 | 3306 | ONLINE |
| 30 | 192.168.209.26 | 3306 | ONLINE |
| 30 | 192.168.209.27 | 3306 | ONLINE |
| 30 | 192.168.209.29 | 3306 | ONLINE |
+--------------+----------------+------+--------+
Admin>select * from monitor.mysql_server_connect_log;
+----------------+------+------------------+-------------------------+---------------+
| hostname | port | time_start_us | connect_success_time_us | connect_error |
+----------------+------+------------------+-------------------------+---------------+
| 192.168.209.29 | 3306 | 1702221005738355 | 1416 | NULL |
| 192.168.209.27 | 3306 | 1702221006526338 | 1089 | NULL |
| 192.168.209.26 | 3306 | 1702221007314330 | 596 | NULL |
| 192.168.209.29 | 3306 | 1702221065738730 | 994 | NULL |
| 192.168.209.27 | 3306 | 1702221066161317 | 992 | NULL |
| 192.168.209.26 | 3306 | 1702221486958648 | 539 | NULL |
| 192.168.209.29 | 3306 | 1702221545742088 | 1037 | NULL |
| 192.168.209.26 | 3306 | 1702221546167397 | 590 | NULL |
| 192.168.209.27 | 3306 | 1702221546592785 | 1394 | NULL |
+----------------+------+------------------+-------------------------+---------------+
30 rows in set (0.00 sec)
Admin>select * from mysql_server_ping_log limit 10;
+----------------+------+------------------+----------------------+------------+
| hostname | port | time_start_us | ping_success_time_us | ping_error |
+----------------+------+------------------+----------------------+------------+
| 192.168.209.29 | 3306 | 1702221015728400 | 229 | NULL |
| 192.168.209.26 | 3306 | 1702221015820460 | 107 | NULL |
| 192.168.209.27 | 3306 | 1702221015912469 | 222 | NULL |
| 192.168.209.27 | 3306 | 1702221025728898 | 283 | NULL |
| 192.168.209.29 | 3306 | 1702221025854012 | 242 | NULL |
| 192.168.209.26 | 3306 | 1702221025979120 | 103 | NULL |
| 192.168.209.29 | 3306 | 1702221035729246 | 253 | NULL |
| 192.168.209.27 | 3306 | 1702221035802663 | 288 | NULL |
| 192.168.209.26 | 3306 | 1702221035876052 | 94 | NULL |
| 192.168.209.26 | 3306 | 1702221045729747 | 104 | NULL |
+----------------+------+------------------+----------------------+------------+
10 rows in set (0.00 sec)
Admin>select rule_id,active,match_digest,destination_hostgroup,apply from mysql_query_rules;
+---------+--------+----------------------+-----------------------+-------+
| rule_id | active | match_digest | destination_hostgroup | apply |
+---------+--------+----------------------+-----------------------+-------+
| 1 | 1 | ^SELECT.*FOR UPDATES | 10 | 1 |
| 2 | 1 | ^SELECT | 20 | 1 |
| 3 | 1 | ^SHOW | 20 | 1 |
+---------+--------+----------------------+-----------------------+-------+
3 rows in set (0.00 sec)
问题:
写操作只能对开始部署的primary节点,当primary节点192.168.209.26转移到192.168.209.27或192.168.209.29,写操作依然轮至192.168.209.26,不能自动转移到其它primary节点。
检查proxysql日志,持续输出以下报错日志:
2023-12-10 23:26:15 MySQL_Monitor.cpp:1744:monitor_group_replication_thread(): mysql_fetch_fields returns NULL, or mysql_num_fields is incorrect. Server 192.168.209.26:3306 . See bug #1994
2023-12-10 23:26:15 MySQL_Monitor.cpp:1744:monitor_group_replication_thread(): mysql_fetch_fields returns NULL, or mysql_num_fields is incorrect. Server 192.168.209.27:3306 . See bug #1994
2023-12-10 23:26:15 MySQL_Monitor.cpp:1744:monitor_group_replication_thread(): mysql_fetch_fields returns NULL, or mysql_num_fields is incorrect. Server 192.168.209.29:3306 . See bug #1994
2023-12-10 23:26:20 MySQL_Monitor.cpp:1744:monitor_group_replication_thread(): mysql_fetch_fields returns NULL, or mysql_num_fields is incorrect. Server 192.168.209.26:3306 . See bug #1994
2023-12-10 23:26:20 MySQL_Monitor.cpp:1744:monitor_group_replication_thread(): mysql_fetch_fields returns NULL, or mysql_num_fields is incorrect. Server 192.168.209.27:3306 . See bug #1994
2023-12-10 23:26:20 MySQL_Monitor.cpp:1744:monitor_group_replication_thread(): mysql_fetch_fields returns NULL, or mysql_num_fields is incorrect. Server 192.168.209.29:3306 . See bug #1994 szhjb88 发表于 2023-12-10 23:27
检查proxysql日志,持续输出以下报错日志:
需要先说明proxysql和后端MySQL的版本号。
这应该是proxysql版本不对,或者哪里没设置正确导致无法识别primary节点切换。
可以在数据库端把general log打开,看看proxysql发出状态检测的SQL啥样的,是不是能匹配对应的后端数据库版本。
最后,建议改用MySQL Router来做,proxysql用户量并不大,小问题挺多的。
yejr 发表于 2023-12-11 08:55
需要先说明proxysql和后端MySQL的版本号。
你好 yejr,
谢谢回复。
版本号是这个 :
ProxySQL version 2.4.8-2-g2cc900a, codename Truls
GreatSQL 8.0.32-24
greatsql的general日志已经开启了,正在排查中。
如果使用MySQL Router,需要指定写和读的地址和端口,由于应用每个模块都有可能写和读,还没有拆分读和写,使用MySQL Router有办法实现吗? yejr 发表于 2023-12-11 08:55
需要先说明proxysql和后端MySQL的版本号。
他用的老方法, 通过proxysql 调用函数来判断, 这个是bug, 可以通过改一下创建的函数,
其次就是, 如果不想改, 可以直接使用最新版本的proxysql, 无需创建函数,视图等, 直接可以自动识别。 mysql_group_replication_hostgroups 这个配置了吗? 跟 runtime_mysql_servers保持一致 chongzh 发表于 2023-12-11 15:03
mysql_group_replication_hostgroups 这个配置了吗? 跟 runtime_mysql_servers保持一致
你好,chongzh,
以下是mysql_group_replication_hostgroups和 runtime_mysql_servers信息:
select * from mysql_group_replication_hostgroups ;
+------------------+-------------------------+------------------+-------------------+--------+-------------+-----------------------+-------------------------+---------+
| writer_hostgroup | backup_writer_hostgroup | reader_hostgroup | offline_hostgroup | active | max_writers | writer_is_also_reader | max_transactions_behind | comment |
+------------------+-------------------------+------------------+-------------------+--------+-------------+-----------------------+-------------------------+---------+
| 10 | 20 | 30 | 40 | 1 | 1 | 0 | 100 | NULL |
+------------------+-------------------------+------------------+-------------------+--------+-------------+-----------------------+-------------------------+---------+
1 row in set (0.00 sec)
select * fromruntime_mysql_servers ;
+--------------+----------------+------+-----------+--------+--------+-------------+-----------------+---------------------+---------+----------------+-------------------+
| hostgroup_id | hostname | port | gtid_port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
+--------------+----------------+------+-----------+--------+--------+-------------+-----------------+---------------------+---------+----------------+-------------------+
| 10 | 192.168.209.26 | 3306 | 0 | ONLINE | 1 | 0 | 1000 | 0 | 0 | 0 | writer_host Group |
| 30 | 192.168.209.26 | 3306 | 0 | ONLINE | 1 | 0 | 1000 | 0 | 0 | 0 | reader_host Group |
| 30 | 192.168.209.27 | 3306 | 0 | ONLINE | 1 | 0 | 1000 | 0 | 0 | 0 | reader_host Group |
| 30 | 192.168.209.29 | 3306 | 0 | ONLINE | 1 | 0 | 1000 | 0 | 0 | 0 | reader_host Group |
+--------------+----------------+------+-----------+--------+--------+-------------+-----------------+---------------------+---------+----------------+-------------------+
4 rows in set (0.00 sec)
忆雨林枫 发表于 2023-12-11 11:41
他用的老方法, 通过proxysql 调用函数来判断, 这个是bug, 可以通过改一下创建的函数,
其次就是, 如 ...
你好,忆雨林枫,
函数,视图是比较麻烦,网上找了很多个方法都有问题,最后找一个可以且用sql进行创建。
我来升级一下proxysql最新版本试试。谢谢 szhjb88 发表于 2023-12-11 15:49
你好,忆雨林枫,
函数,视图是比较麻烦,网上找了很多个方法都有问题,最后找一个可以且用sql进行创建 ...
我之前在网上放了,修改后的函数代码,就不会触发。
但是现在新版本可以不用了,尽量升级吧 忆雨林枫 发表于 2023-12-11 16:22
我之前在网上放了,修改后的函数代码,就不会触发。
但是现在新版本可以不用了,尽量升级吧 ...
你好,忆雨林枫,
我升级了,重新设置过,是正常了,感谢!
页:
[1]