ProxySQL Cluster的搭建
环境:
proxysql-1.4.10-1-centos7.x86_64
db210 192.168.99.210 老节点,已经做成mysql配置和读写分离设置
db211 192.168.99.211 新节点
db212 192.168.99.212 新节点
1.设置集群管理账号
在所有节点上做以下操作
admin@127.0.0.1 [man]>update global_variables set variable_value='admin:admin;cluster_21x:zstxxx' where variable_name='admin-admin_credentials';
Query OK, 1 row affected (0.00 sec)
admin@127.0.0.1 [man]>update global_variables set variable_value='cluster_21x' where variable_name='admin-cluster_username';
Query OK, 1 row affected (0.00 sec)
admin@127.0.0.1 [man]>update global_variables set variable_value='zstxxx' where variable_name='admin-cluster_password';
2.设置集群成员:
admin@127.0.0.1 [man]>insert into proxysql_servers(hostname,port,weight,comment) values('db210',6032,1,'primary'),('db211',6032,1,'secondary'),('db212',6032,1,'secondary');
3.加载配置
- 先加载已有服务器配置的第一个ProxySQL节点,再加载其他新节点.
admin@127.0.0.1 [man]>load admin variables to runtime;
admin@127.0.0.1 [man]>load proxysql servers to runtime;
admin@127.0.0.1 [man]>save admin variables to disk;
admin@127.0.0.1 [man]>save proxysql servers to disk;
4.查看群集状态:
注:节点db212还没有配置,所以状态为空
admin@127.0.0.1 [(none)]>select hostname,port,comment,Uptime_s,last_check_ms from stats_proxysql_servers_metrics;
+----------+------+-----------+----------+---------------+
| hostname | port | comment | Uptime_s | last_check_ms |
+----------+------+-----------+----------+---------------+
| db212 | 6032 | secondary | 1064 | 468 |
| db211 | 6032 | secondary | 100320 | 279 |
| db210 | 6032 | primary | 7300 | 283 |
+----------+------+-----------+----------+---------------+
3 rows in set (0.00 sec)
admin@127.0.0.1 [(none)]>select hostname,name,checksum,updated_at from stats_proxysql_servers_checksums;
+----------+-------------------+--------------------+------------+
| hostname | name | checksum | updated_at |
+----------+-------------------+--------------------+------------+
| db212 | admin_variables | | 1535100518 |
| db212 | mysql_query_rules | 0x0000000000000000 | 1535100518 |
| db212 | mysql_servers | 0xB58B50EC4FEF3D20 | 1535100518 |
| db212 | mysql_users | 0x0000000000000000 | 1535100518 |
| db212 | mysql_variables | | 1535100518 |
| db212 | proxysql_servers | 0xC405ABD157E8B011 | 1535100518 |
| db211 | admin_variables | | 1535100518 |
| db211 | mysql_query_rules | 0x0000000000000000 | 1535100518 |
| db211 | mysql_servers | 0xB58B50EC4FEF3D20 | 1535100518 |
| db211 | mysql_users | 0x0000000000000000 | 1535100518 |
| db211 | mysql_variables | | 1535100518 |
| db211 | proxysql_servers | 0xC405ABD157E8B011 | 1535100518 |
| db210 | admin_variables | | 1535100518 |
| db210 | mysql_query_rules | 0xC2127DA38220E59D | 1535100518 |
| db210 | mysql_servers | 0x2E65DC53740DC1C8 | 1535100518 |
| db210 | mysql_users | 0x9881C192AE6F7368 | 1535100518 |
| db210 | mysql_variables | | 1535100518 |
| db210 | proxysql_servers | 0xC405ABD157E8B011 | 1535100518 |
+----------+-------------------+--------------------+------------+
18 rows in set (0.00 sec)
5.数据同步的触发
集群建立后,发现有部分数据没有同步,如下表中可以看出db211和db212的mysql_query_rules,mysql_users的checksum都不对
admin@127.0.0.1 [(none)]>select hostname,name,checksum,updated_at from stats_proxysql_servers_checksums;
+----------+-------------------+--------------------+------------+
| hostname | name | checksum | updated_at |
+----------+-------------------+--------------------+------------+
| db212 | admin_variables | | 1535100518 |
| db212 | mysql_query_rules | 0x0000000000000000 | 1535100518 |
| db212 | mysql_servers | 0xB58B50EC4FEF3D20 | 1535100518 |
| db212 | mysql_users | 0x0000000000000000 | 1535100518 |
| db212 | mysql_variables | | 1535100518 |
| db212 | proxysql_servers | 0xC405ABD157E8B011 | 1535100518 |
| db211 | admin_variables | | 1535100518 |
| db211 | mysql_query_rules | 0x0000000000000000 | 1535100518 |
| db211 | mysql_servers | 0xB58B50EC4FEF3D20 | 1535100518 |
| db211 | mysql_users | 0x0000000000000000 | 1535100518 |
| db211 | mysql_variables | | 1535100518 |
| db211 | proxysql_servers | 0xC405ABD157E8B011 | 1535100518 |
| db210 | admin_variables | | 1535100518 |
| db210 | mysql_query_rules | 0xC2127DA38220E59D | 1535100518 |
| db210 | mysql_servers | 0x2E65DC53740DC1C8 | 1535100518 |
| db210 | mysql_users | 0x9881C192AE6F7368 | 1535100518 |
| db210 | mysql_variables | | 1535100518 |
| db210 | proxysql_servers | 0xC405ABD157E8B011 | 1535100518 |
+----------+-------------------+--------------------+------------+
18 rows in set (0.00 sec)
- 查日志发现以下信息:
detected a peer db211:6032 with mysql_users version 1, epoch 1535000044, diff_check 7860. Own version: 1, epoch: 1535093184. diff_check is increasing, but version 1 doesn't allow sync. This message will be repeated every 30 checks until LOAD MYSQL USERS TO RUNTIME is executed on candidate master.
- 解决办法:在主节点上load to RUNTIME
6.遗留问题:
- 发现admin_variables和mysql_variables 的 checksum 始终为空,修改值也无法同步.
- 集群同步监测表中没有mysql_group_replication_hostgroups,还需要自行同步.
- db212节点的mysql_servers表的checksum 不同,但肉眼只能看出记录顺序不同,导致一致产生大量日志,尝试重新同步很多次,都出现相同的结果.
db210主节点:
admin@127.0.0.1 [man]>select hostname,name,checksum,changed_at,diff_check from stats_proxysql_servers_checksums;
+----------+-------------------+--------------------+------------+------------+
| hostname | name | checksum | changed_at | diff_check |
+----------+-------------------+--------------------+------------+------------+
| db212 | admin_variables | | 0 | 0 |
| db212 | mysql_query_rules | 0xC2127DA38220E59D | 1535122622 | 0 |
| db212 | mysql_servers | 0xB58B50EC4FEF3D20 | 1535122622 | 110 |
| db212 | mysql_users | 0x6C619C922DBF30FF | 1535122622 | 0 |
| db212 | mysql_variables | | 0 | 0 |
| db212 | proxysql_servers | 0xC405ABD157E8B011 | 1535122623 | 0 |
| db211 | admin_variables | | 0 | 0 |
| db211 | mysql_query_rules | 0xC2127DA38220E59D | 1535111313 | 0 |
| db211 | mysql_servers | 0x2E65DC53740DC1C8 | 1535102178 | 0 |
| db211 | mysql_users | 0x6C619C922DBF30FF | 1535105932 | 0 |
| db211 | mysql_variables | | 0 | 0 |
| db211 | proxysql_servers | 0xC405ABD157E8B011 | 1535122626 | 0 |
| db210 | admin_variables | | 0 | 0 |
| db210 | mysql_query_rules | 0xC2127DA38220E59D | 1535096359 | 0 |
| db210 | mysql_servers | 0x2E65DC53740DC1C8 | 1535100019 | 0 |
| db210 | mysql_users | 0x6C619C922DBF30FF | 1535105930 | 0 |
| db210 | mysql_variables | | 0 | 0 |
| db210 | proxysql_servers | 0xC405ABD157E8B011 | 1535122622 | 0 |
+----------+-------------------+--------------------+------------+------------+
18 rows in set (0.00 sec)
admin@127.0.0.1 [man]>select * from mysql_servers;
+--------------+----------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| hostgroup_id | hostname | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
+--------------+----------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| 10 | db212 | 3507 | ONLINE | 1 | 0 | 1000 | 0 | 0 | 0 | |
| 11 | db210 | 3507 | ONLINE | 1 | 0 | 1000 | 0 | 0 | 0 | |
| 11 | db212 | 3507 | ONLINE | 1 | 0 | 1000 | 0 | 0 | 0 | |
| 11 | db211 | 3507 | ONLINE | 1 | 0 | 1000 | 0 | 0 | 0 | |
| 13 | db210 | 3507 | ONLINE | 1 | 0 | 1000 | 0 | 0 | 0 | |
| 13 | db211 | 3507 | ONLINE | 1 | 0 | 1000 | 0 | 0 | 0 | |
+--------------+----------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
6 rows in set (0.00 sec)
- db212节点
admin@127.0.0.1 [(none)]>select * from disk.mysql_servers;
+--------------+----------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| hostgroup_id | hostname | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
+--------------+----------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| 10 | db212 | 3507 | ONLINE | 1 | 0 | 1000 | 0 | 0 | 0 | |
| 13 | db211 | 3507 | ONLINE | 1 | 0 | 1000 | 0 | 0 | 0 | |
| 13 | db210 | 3507 | ONLINE | 1 | 0 | 1000 | 0 | 0 | 0 | |
| 11 | db211 | 3507 | ONLINE | 1 | 0 | 1000 | 0 | 0 | 0 | |
| 11 | db212 | 3507 | ONLINE | 1 | 0 | 1000 | 0 | 0 | 0 | |
| 11 | db210 | 3507 | ONLINE | 1 | 0 | 1000 | 0 | 0 | 0 | |
+--------------+----------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
6 rows in set (0.00 sec)
7.全配置信息
admin@127.0.0.1 [man]>select * from runtime_global_variables;
+-----------------------------------------------------+--------------------------------+
| variable_name | variable_value |
+-----------------------------------------------------+--------------------------------+
| admin-admin_credentials | admin:adminxxx;cluster_210:zstxxx |
| admin-stats_credentials | stats:stats |
| admin-stats_mysql_connections | 60 |
| admin-stats_mysql_connection_pool | 60 |
| admin-stats_mysql_query_cache | 60 |
| admin-stats_system_cpu | 60 |
| admin-stats_system_memory | 60 |
| admin-mysql_ifaces | 0.0.0.0:6032 |
| admin-telnet_admin_ifaces | (null) |
| admin-telnet_stats_ifaces | (null) |
| admin-refresh_interval | 2000 |
| admin-read_only | false |
| admin-hash_passwords | true |
| admin-version | v1.4.10-1-g5eb0f3e |
| admin-cluster_username | cluster_210 |
| admin-cluster_password | zstxxx |
| admin-cluster_check_interval_ms | 1000 |
| admin-cluster_check_status_frequency | 10 |
| admin-cluster_mysql_query_rules_diffs_before_sync | 3 |
| admin-cluster_mysql_servers_diffs_before_sync | 3 |
| admin-cluster_mysql_users_diffs_before_sync | 3 |
| admin-cluster_proxysql_servers_diffs_before_sync | 3 |
| admin-cluster_mysql_query_rules_save_to_disk | true |
| admin-cluster_mysql_servers_save_to_disk | true |
| admin-cluster_mysql_users_save_to_disk | true |
| admin-cluster_proxysql_servers_save_to_disk | true |
| admin-checksum_mysql_query_rules | true |
| admin-checksum_mysql_servers | true |
| admin-checksum_mysql_users | true |
| admin-web_enabled | false |
| admin-web_port | 6080 |
| mysql-shun_on_failures | 5 |
| mysql-shun_recovery_time_sec | 10 |
| mysql-query_retries_on_failure | 1 |
| mysql-client_multi_statements | true |
| mysql-connect_retries_on_failure | 10 |
| mysql-connect_retries_delay | 1 |
| mysql-connection_delay_multiplex_ms | 0 |
| mysql-connection_max_age_ms | 0 |
| mysql-connect_timeout_server | 3000 |
| mysql-connect_timeout_server_max | 10000 |
| mysql-eventslog_filename | |
| mysql-eventslog_filesize | 104857600 |
| mysql-default_charset | utf8 |
| mysql-free_connections_pct | 10 |
| mysql-session_idle_ms | 1000 |
| mysql-have_compress | true |
| mysql-client_found_rows | true |
| mysql-interfaces | 0.0.0.0:6033 |
| mysql-monitor_enabled | true |
| mysql-monitor_history | 600000 |
| mysql-monitor_connect_interval | 60000 |
| mysql-monitor_connect_timeout | 600 |
| mysql-monitor_ping_interval | 10000 |
| mysql-monitor_ping_max_failures | 3 |
| mysql-monitor_ping_timeout | 1000 |
| mysql-monitor_read_only_interval | 1500 |
| mysql-monitor_read_only_timeout | 500 |
| mysql-monitor_read_only_max_timeout_count | 3 |
| mysql-monitor_replication_lag_interval | 10000 |
| mysql-monitor_replication_lag_timeout | 1000 |
| mysql-monitor_groupreplication_healthcheck_interval | 5000 |
| mysql-monitor_groupreplication_healthcheck_timeout | 800 |
| mysql-monitor_username | proxysql |
| mysql-monitor_password | zstxxx |
| mysql-monitor_replication_lag_use_percona_heartbeat | |
| mysql-monitor_query_interval | 60000 |
| mysql-monitor_query_timeout | 100 |
| mysql-monitor_slave_lag_when_null | 60 |
| mysql-monitor_wait_timeout | true |
| mysql-monitor_writer_is_also_reader | true |
| mysql-max_allowed_packet | 4194304 |
| mysql-throttle_connections_per_sec_to_hostgroup | 1000000 |
| mysql-max_transaction_time | 14400000 |
| mysql-multiplexing | true |
| mysql-forward_autocommit | false |
| mysql-enforce_autocommit_on_reads | false |
| mysql-autocommit_false_not_reusable | false |
| mysql-autocommit_false_is_transaction | false |
| mysql-verbose_query_error | false |
| mysql-hostgroup_manager_verbose | 1 |
| mysql-threshold_query_length | 524288 |
| mysql-threshold_resultset_size | 4194304 |
| mysql-query_digests_max_digest_length | 2048 |
| mysql-query_digests_max_query_length | 65000 |
| mysql-wait_timeout | 28800000 |
| mysql-throttle_max_bytes_per_second_to_client | 2147483647 |
| mysql-throttle_ratio_server_to_client | 0 |
| mysql-max_connections | 2048 |
| mysql-max_stmts_per_connection | 20 |
| mysql-max_stmts_cache | 10000 |
| mysql-mirror_max_concurrency | 16 |
| mysql-mirror_max_queue_length | 32000 |
| mysql-default_max_latency_ms | 1000 |
| mysql-default_query_delay | 0 |
| mysql-default_query_timeout | 36000000 |
| mysql-query_processor_iterations | 0 |
| mysql-query_processor_regex | 1 |
| mysql-long_query_time | 1000 |
| mysql-query_cache_size_MB | 256 |
| mysql-ping_interval_server_msec | 120000 |
| mysql-ping_timeout_server | 500 |
| mysql-default_schema | information_schema |
| mysql-poll_timeout | 2000 |
| mysql-poll_timeout_on_failure | 100 |
| mysql-server_capabilities | 45578 |
| mysql-server_version | 5.5.30 |
| mysql-kill_backend_connection_when_disconnect | true |
| mysql-sessions_sort | true |
| mysql-session_idle_show_processlist | true |
| mysql-commands_stats | true |
| mysql-query_digests | true |
| mysql-query_digests_lowercase | false |
| mysql-servers_stats | true |
| mysql-default_reconnect | true |
| mysql-ssl_p2s_ca | |
| mysql-ssl_p2s_cert | |
| mysql-ssl_p2s_key | |
| mysql-ssl_p2s_cipher | |
| mysql-stacksize | 1048576 |
| mysql-threads | 4 |
| mysql-init_connect | |
| mysql-default_sql_mode | |
| mysql-default_time_zone | SYSTEM |
| mysql-connpoll_reset_queue_length | 50 |
| mysql-stats_time_backend_query | false |
| mysql-stats_time_query_processor | false |
+-----------------------------------------------------+--------------------------------+
127 rows in set (0.00 sec)
admin@127.0.0.1 [man]>
admin@127.0.0.1 [man]>select * from runtime_proxysql_servers;
+----------+------+--------+-----------+
| hostname | port | weight | comment |
+----------+------+--------+-----------+
| db210 | 6032 | 1 | primary |
| db211 | 6032 | 1 | secondary |
| db212 | 6032 | 1 | secondary |
+----------+------+--------+-----------+
3 rows in set (0.00 sec)
8.参考信息:
https://github.com/sysown/proxysql/wiki/ProxySQL-Cluster
http://www.cnblogs.com/2woods/p/9530091.html
ProxySQL Cluster的搭建的更多相关文章
- proxysql cluster 的搭建
文章转载自:https://blog.51cto.com/lee90/2298804 官方文档: https://proxysql.com/blog/proxysql-cluster 环境架构 在一主 ...
- 【ProxySQL】ProxySQL Cluster的搭建
文章转载自:https://blog.51cto.com/l0vesql/2104643 背景 早期的ProxySQL若需要做高可用,需要搭建两个实例,进行冗余.但两个ProxySQL实例之间的数据并 ...
- 重要参考步骤---ProxySQL Cluster 集群搭建步骤
环境 proxysql-1:192.168.20.202 proxysql-2:192.168.20.203 均采用yum方式安装 # cat <<EOF | tee /etc/yum.r ...
- ProxySQL Cluster 高可用集群环境部署记录
ProxySQL在早期版本若需要做高可用,需要搭建两个实例,进行冗余.但两个ProxySQL实例之间的数据并不能共通,在主实例上配置后,仍需要在备用节点上进行配置,对管理来说非常不方便.但是Proxy ...
- ProxySQL Cluster 高可用集群 + MySQL MGR环境部署 (多写模式) 部署记录
文章转载自:https://blog.51cto.com/u_6215974/4937192 ProxySQL 在早期版本若需要做高可用,需要搭建两个实例,进行冗余.但两个ProxySQL实例之间的数 ...
- Redis Cluster的搭建与部署,实现redis的分布式方案
前言 上篇Redis Sentinel安装与部署,实现redis的高可用实现了redis的高可用,针对的主要是master宕机的情况,我们发现所有节点的数据都是一样的,那么一旦数据量过大,redi也会 ...
- 服务发现 consul cluster 的搭建【转】
consul cluster setup 介绍和指南: consul用于服务发现.当底层服务发生变化时,能及时更新正确的mysql服务IP. 并提供给业务查询.但需要自行编写脚本,监测数据库状态和切断 ...
- redis单点、redis主从、redis哨兵sentinel,redis集群cluster配置搭建与使用
目录 redis单点.redis主从.redis哨兵 sentinel,redis集群cluster配置搭建与使用 1 .redis 安装及配置 1.1 redis 单点 1.1.2 在命令窗口操作r ...
- ProxySQL Cluster 概述
文章转载自:https://blog.csdn.net/n88Lpo/article/details/79608639 前言 在ProxySQL 1.4.2 之前,ProxySQL 单点的解决方法有配 ...
随机推荐
- 八大排序算法——冒泡排序(动图演示 思路分析 实例代码java 复杂度分析)
一.动图演示 二.思路分析 1. 相邻两个数两两相比,n[i]跟n[j+1]比,如果n[i]>n[j+1],则将连个数进行交换, 2. j++, 重复以上步骤,第一趟结束后,最大数就会被确定 ...
- STL 小白学习(1) 初步认识
#include <iostream> using namespace std; #include <vector> //动态数组 #include <algorithm ...
- ES6和ES5变量声明的区别(var let const)
// es5的语法与es6的语法区别 // var let const console.log(name);//undefine,不会报错,因为变量声明会提到作用域的最前面 var name=&quo ...
- Java容器解析系列(5) AbstractSequentialList LinkedList 详解
AbstractSequentialList为顺序访问的list提供了一个骨架实现,使实现顺序访问的list变得简单; 我们来看源码: /** AbstractSequentialList 继承自 A ...
- java运算符和流程图
- 异常处理:try - except 和 try finally。
异常处理:try-except语句 1) 此处:as reason为可选参数,reason是一个变量. 2) 使用try—except语句时,检测范围内出现错误,不会有红色的报错提 ...
- opcode cache与JIT的区别
要说明opcode cache与JIT的区别,得先明白,字节码,又叫中间码与机器码的区别. 操作码(opcode) 一条机器指令.比如我们汇编语言写的一条操作语句. 机器码(machine code) ...
- linux之创建用户
用户 useradd xxx 创建用户 默认是普通用户 useradd -u666 web 创建新用户 设置id号 groupadd -g 777 ...
- Fiddler中session请求/响应类型与图标含义
近期在看fiddler抓包工具,发现前面都会有小图标显示,不同的图标代表了不同的含义,通过查询,整理如下: 请求发送到服务器 从服务器下载响应结果 请求在断点处被暂停 响应在断点处被暂停 请 ...
- C#添加文字水印
使用的是iTextSharp添加PDF水印,由于是接口动态生成PDF,所以采用的是全部是内存流的形式,而且水印是平铺是.iTextSharp版本是5.5 /// <summary> /// ...