mysql5.7 pxc方案_mysql5.7 pxc
pxc优点总结:
可以达到时时同步,无延迟现象发生
完全兼容MySQL
对于集群中新节点的加入,维护起来很简单
数据的强一致性
不足之处总结:
只支持Innodb存储引擎
存在多节点update更新问题,也就是写放大问题
在线DDL语句,锁表问题
sst针对新节点加入的传输代价过高的问题
关于写放大的原理图
下面从上次组复制转pxc
https://www.cnblogs.com/omsql/p/9277047.html
pxc架构图如下
卸载mysql
卸载前记得备份my.cnf
yum remove mysql-community-*
安装pxc
yum install http://www.percona.com/downloads/percona-release/redhat/0.1-6/percona-release-0.1-6.noarch.rpm
yum install http://rpmfind.net/linux/dag/redhat/el6/en/x86_64/dag/RPMS/socat-1.7.2.4-1.el6.rf.x86_64.rpm
yum install Percona-XtraDB-Cluster-57
修改my.cnf
#pxc
wsrep_provider=/usr/lib64/galera3/libgalera_smm.so
wsrep_cluster_address=gcomm://192.168.20.201,192.168.20.202,192.168.20.203
wsrep_slave_threads= 8
innodb_autoinc_lock_mode=2
wsrep_node_address=192.168.20.201
wsrep_cluster_name=ht-pxc-cluster
wsrep_node_name=pxc01
pxc_strict_mode=ENFORCING
wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth=sst:ocm123
第一个节点启动
/etc/init.d/mysqld bootstrap-pxc
创建用户
SHOW VARIABLES LIKE 'validate_password%';
set global validate_password_policy=LOW;
set global validate_password_length=4;
create user 'sst'@'localhost' identified by 'ocm123';
grant all privileges on *.* to 'sst'@'localhost' identified by 'ocm123';
flush privileges;
第二个节点启动
/etc/init.d/mysql start
第三个节点启动
/etc/init.d/mysql start
添加第三个节点redis03的时候redis02日志输出如下
1 redis022 2018-07-09T15:01:19.004758Z 0 [Note] WSREP: Member 2.0 (pxc03) requested state transfer from '*any*'. Selected 0.0 (pxc02)(SYNCED) asdonor.3 2018-07-09T15:01:19.004800Z 0 [Note] WSREP: Shifting SYNCED -> DONOR/DESYNCED (TO: 7054)4 2018-07-09T15:01:19.004867Z 5 [Note] WSREP: wsrep_notify_cmd isnot defined, skipping notification.5 2018-07-09T15:01:19.005039Z 0 [Note] WSREP: Initiating SST/IST transfer on DONOR side (wsrep_sst_xtrabackup-v2 --role 'donor' --address '192.168.20.203:4444/xtrabackup_sst//1' --socket '/data/mysql/mysql.sock' --datadir '/data/mysql/' --defaults-file '/etc/my.cnf' --defaults-group-suffix '' --binlog 'mysql-bin' --gtid '62e9006b-8379-11e8-bc64-874d49a77c07:7054')6 2018-07-09T15:01:19.087469Z 5 [Note] WSREP: DONOR thread signaled with 0
View Code
redis02被选为donar,使用xtrabackup备份整个库传到redis03下,同时查看redis03 /data/mysql
[root@redis03 mysql]# ls
galera.cache grastate.dat gvwstate.dat sst_in_progress
恢复完后如下
1 [root@redis03 mysql]# ls2 auto.cnf grastate.dat ib_logfile1 mysql-bin.000007 public_key.pem server-cert.pem xtrabackup_info3 ca-key.pem gvwstate.dat ibtmp1 mysql-bin.index pxc server-key.pem xtrabackup_master_key_id4 ca.pem ht innobackup.move.log mysql.sock redis03-relay-bin-group_replication_applier.000001sys5 client-cert.pem ib_buffer_pool innobackup.prepare.log mysql.sock.lock redis03-relay-bin-group_replication_applier.index xb_doublewrite6 client-key.pem ibdata1 mysql performance_schema redis03-relay-bin-group_replication_recovery.000001xtrabackup_binlog_pos_innodb7 galera.cache ib_logfile0 mysql-bin.000006 private_key.pem redis03-relay-bin-group_replication_recovery.index xtrabackup_galera_info
上面输出可以看出sst针对新节点加入的传输代价过高。
查看集群状态
root@redis03> show status like 'wsrep%';+----------------------------------+-------------------------------------------------------------+
| Variable_name | Value |
+----------------------------------+-------------------------------------------------------------+
| wsrep_local_state_uuid | 62e9006b-8379-11e8-bc64-874d49a77c07 |
| wsrep_protocol_version | 8 |
| wsrep_last_applied | 7054 |
| wsrep_last_committed | 7054 |
| wsrep_replicated | 0 |
| wsrep_replicated_bytes | 0 |
| wsrep_repl_keys | 0 |
| wsrep_repl_keys_bytes | 0 |
| wsrep_repl_data_bytes | 0 |
| wsrep_repl_other_bytes | 0 |
| wsrep_received | 2 |
| wsrep_received_bytes | 285 |
| wsrep_local_commits | 0 |
| wsrep_local_cert_failures | 0 |
| wsrep_local_replays | 0 |
| wsrep_local_send_queue | 0 |
| wsrep_local_send_queue_max | 1 |
| wsrep_local_send_queue_min | 0 |
| wsrep_local_send_queue_avg | 0.000000 |
| wsrep_local_recv_queue | 0 |
| wsrep_local_recv_queue_max | 1 |
| wsrep_local_recv_queue_min | 0 |
| wsrep_local_recv_queue_avg | 0.000000 |
| wsrep_local_cached_downto | 0 |
| wsrep_flow_control_paused_ns | 0 |
| wsrep_flow_control_paused | 0.000000 |
| wsrep_flow_control_sent | 0 |
| wsrep_flow_control_recv | 0 |
| wsrep_flow_control_interval | [ 173, 173 ] |
| wsrep_flow_control_interval_low | 173 |
| wsrep_flow_control_interval_high | 173 |
| wsrep_flow_control_status | OFF |
| wsrep_cert_deps_distance | 0.000000 |
| wsrep_apply_oooe | 0.000000 |
| wsrep_apply_oool | 0.000000 |
| wsrep_apply_window | 0.000000 |
| wsrep_commit_oooe | 0.000000 |
| wsrep_commit_oool | 0.000000 |
| wsrep_commit_window | 0.000000 |
| wsrep_local_state | 4 |
| wsrep_local_state_comment | Synced |
| wsrep_cert_index_size | 0 |
| wsrep_cert_bucket_count | 22 |
| wsrep_gcache_pool_size | 1320 |
| wsrep_causal_reads | 0 |
| wsrep_cert_interval | 0.000000 |
| wsrep_ist_receive_status | |
| wsrep_ist_receive_seqno_start | 0 |
| wsrep_ist_receive_seqno_current | 0 |
| wsrep_ist_receive_seqno_end | 0 |
| wsrep_incoming_addresses | 192.168.20.202:3306,192.168.20.201:3306,192.168.20.203:3306 |
| wsrep_desync_count | 0 |
| wsrep_evs_delayed | |
| wsrep_evs_evict_list | |
| wsrep_evs_repl_latency | 0/0/0/0/0 |
| wsrep_evs_state | OPERATIONAL |
| wsrep_gcomm_uuid | ee9c63ef-8388-11e8-af36-8bf4f2f07974 |
| wsrep_cluster_conf_id | 5 |
| wsrep_cluster_size | 3 |
| wsrep_cluster_state_uuid | 62e9006b-8379-11e8-bc64-874d49a77c07 |
| wsrep_cluster_status | Primary |
| wsrep_connected | ON |
| wsrep_local_bf_aborts | 0 |
| wsrep_local_index | 2 |
| wsrep_provider_name | Galera |
| wsrep_provider_vendor | Codership Oy |
| wsrep_provider_version | 3.26(rac090bc) |
| wsrep_ready | ON |
+----------------------------------+-------------------------------------------------------------+
View Code
在对pxc做此oltp测试
安装sysbench
yum install sysbench
生成数据,创建10个表,每个表百万行
sysbench oltp_common --tables=10 --table-size=1000000 --db-driver=mysql --mysql-db=pxc --mysql-user=root --mysql-password=ocm123 prepare
oltp 测试,开启50个并行
sysbench oltp_read_write.lua --db-driver=mysql --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-db=pxc --mysql-user=root --mysql-password=ocm123 --table_size=1000000 --tables=10 --threads=50 --report-interval=10 --time=300 run
oltp测试结果如下
1 [root@redis01 sysbench]# sysbench oltp_read_write.lua --db-driver=mysql --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-db=pxc --mysql-user=root --mysql-password=ocm123 --table_size=1000000 --tables=10 --threads=50 --report-interval=10 --time=300run2 sysbench 1.0.14 (using bundled LuaJIT 2.1.0-beta2)3
4 Running the test with following options:5 Number of threads: 50
6 Report intermediate results every 10second(s)7 Initializing random number generator fromcurrent time8
9
10 Initializing worker threads...11
12 Threads started!
13
14 [ 10s ] thds: 50 tps: 7.90 qps: 231.92 (r/w/o: 168.04/26.19/37.69) lat (ms,95%): 5813.24 err/s: 0.00 reconn/s: 0.00
15 [ 20s ] thds: 50 tps: 11.80 qps: 254.99 (r/w/o: 177.69/32.30/45.00) lat (ms,95%): 5918.87 err/s: 0.00 reconn/s: 0.00
16 [ 30s ] thds: 50 tps: 8.90 qps: 179.97 (r/w/o: 124.58/26.10/29.30) lat (ms,95%): 6476.48 err/s: 0.00 reconn/s: 0.00
17 [ 40s ] thds: 50 tps: 10.40 qps: 175.17 (r/w/o: 122.35/19.81/33.01) lat (ms,95%): 9284.15 err/s: 0.00 reconn/s: 0.00
18 [ 50s ] thds: 50 tps: 9.20 qps: 182.49 (r/w/o: 131.10/21.90/29.50) lat (ms,95%): 9799.46 err/s: 0.00 reconn/s: 0.00
19 [ 60s ] thds: 50 tps: 8.80 qps: 198.65 (r/w/o: 140.97/24.39/33.29) lat (ms,95%): 7215.39 err/s: 0.00 reconn/s: 0.00
20 [ 70s ] thds: 50 tps: 7.00 qps: 145.72 (r/w/o: 99.01/21.60/25.10) lat (ms,95%): 8795.93 err/s: 0.00 reconn/s: 0.00
21 [ 80s ] thds: 50 tps: 13.70 qps: 239.41 (r/w/o: 171.21/27.20/41.00) lat (ms,95%): 8484.79 err/s: 0.00 reconn/s: 0.00
22 [ 90s ] thds: 50 tps: 7.40 qps: 161.92 (r/w/o: 107.41/24.90/29.60) lat (ms,95%): 8484.79 err/s: 0.00 reconn/s: 0.00
23 [ 100s ] thds: 50 tps: 8.00 qps: 186.69 (r/w/o: 130.99/24.00/31.70) lat (ms,95%): 5918.87 err/s: 0.00 reconn/s: 0.00
24 [ 110s ] thds: 50 tps: 10.00 qps: 200.01 (r/w/o: 140.00/27.40/32.60) lat (ms,95%): 5709.50 err/s: 0.00 reconn/s: 0.00
25 [ 120s ] thds: 50 tps: 10.60 qps: 210.17 (r/w/o: 148.38/25.60/36.19) lat (ms,95%): 8184.67 err/s: 0.00 reconn/s: 0.00
26 [ 130s ] thds: 50 tps: 11.50 qps: 223.73 (r/w/o: 159.42/24.70/39.61) lat (ms,95%): 7895.16 err/s: 0.00 reconn/s: 0.00
27 [ 140s ] thds: 50 tps: 11.90 qps: 242.60 (r/w/o: 168.03/31.09/43.48) lat (ms,95%): 4943.53 err/s: 0.00 reconn/s: 0.00
28 [ 150s ] thds: 50 tps: 9.10 qps: 185.45 (r/w/o: 127.53/26.21/31.71) lat (ms,95%): 4517.90 err/s: 0.00 reconn/s: 0.00
29 [ 160s ] thds: 50 tps: 14.50 qps: 253.44 (r/w/o: 179.83/27.70/45.91) lat (ms,95%): 8184.67 err/s: 0.00 reconn/s: 0.00
30 [ 170s ] thds: 50 tps: 8.40 qps: 203.91 (r/w/o: 140.80/28.10/35.00) lat (ms,95%): 4943.53 err/s: 0.00 reconn/s: 0.00
31 [ 180s ] thds: 50 tps: 13.90 qps: 261.61 (r/w/o: 187.64/28.89/45.08) lat (ms,95%): 7754.26 err/s: 0.00 reconn/s: 0.00
32 [ 190s ] thds: 50 tps: 10.50 qps: 226.94 (r/w/o: 153.93/35.31/37.71) lat (ms,95%): 7754.26 err/s: 0.00 reconn/s: 0.00
33 [ 200s ] thds: 50 tps: 12.00 qps: 218.73 (r/w/o: 153.52/25.30/39.91) lat (ms,95%): 4203.93 err/s: 0.00 reconn/s: 0.00
34 [ 210s ] thds: 50 tps: 11.80 qps: 249.64 (r/w/o: 177.76/29.89/41.99) lat (ms,95%): 5607.61 err/s: 0.00 reconn/s: 0.00
35 [ 220s ] thds: 50 tps: 12.69 qps: 256.80 (r/w/o: 178.93/30.99/46.88) lat (ms,95%): 4517.90 err/s: 0.00 reconn/s: 0.00
36 [ 230s ] thds: 50 tps: 14.01 qps: 253.05 (r/w/o: 180.41/27.62/45.03) lat (ms,95%): 5709.50 err/s: 0.00 reconn/s: 0.00
37 [ 240s ] thds: 50 tps: 9.20 qps: 211.70 (r/w/o: 145.10/31.10/35.50) lat (ms,95%): 5507.54 err/s: 0.00 reconn/s: 0.00
38 [ 250s ] thds: 50 tps: 14.10 qps: 259.32 (r/w/o: 186.52/29.30/43.50) lat (ms,95%): 7086.63 err/s: 0.00 reconn/s: 0.00
39 [ 260s ] thds: 50 tps: 9.20 qps: 210.87 (r/w/o: 139.78/35.00/36.10) lat (ms,95%): 8038.61 err/s: 0.00 reconn/s: 0.00
40 [ 270s ] thds: 50 tps: 11.20 qps: 222.78 (r/w/o: 156.79/27.50/38.50) lat (ms,95%): 6026.41 err/s: 0.00 reconn/s: 0.00
41 [ 280s ] thds: 50 tps: 11.50 qps: 230.55 (r/w/o: 160.73/31.31/38.51) lat (ms,95%): 7615.89 err/s: 0.00 reconn/s: 0.00
42 [ 290s ] thds: 50 tps: 12.80 qps: 255.18 (r/w/o: 179.29/30.90/45.00) lat (ms,95%): 7086.63 err/s: 0.00 reconn/s: 0.00
43 [ 300s ] thds: 50 tps: 12.90 qps: 237.20 (r/w/o: 171.00/24.80/41.40) lat (ms,95%): 6247.39 err/s: 0.00 reconn/s: 0.00
44 SQL statistics:45 queries performed:46 read: 46186
47 write: 8348
48 other: 11446
49 total: 65980
50 transactions: 3299 (10.93per sec.)51 queries: 65980 (218.52per sec.)52 ignored errors: 0 (0.00per sec.)53 reconnects: 0 (0.00per sec.)54
55 General statistics:56 total time: 301.9413s57 total number of events: 3299
58
59 Latency (ms):60 min: 975.37
61 avg: 4575.91
62 max: 13565.48
63 95th percentile: 7479.98
64 sum: 15095927.24
65
66 Threads fairness:67 events (avg/stddev): 65.9800/1.97
68 execution time (avg/stddev): 301.9185/0.01
pxc的 qtp才为11 (虚拟机,3节点在一个磁盘上)
mysql5.7 pxc方案_mysql5.7 pxc相关推荐
- mysql的高可用方案-PXC方案(综合各方的资料)
一.基于主从复制的高可用方案:双节点主从 + keepalived 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 一般来说,中小型规模的时候,采用这种 ...
- MySQL数据库集群之PXC方案---安装pxc集群
1. 准备工作 1.1 准备虚拟机 因为我们要实现的是三台mysql节点集群,所以准备3台虚拟机 192.168.1.173 192.168.1.174 192.168.1.166 1.2 下载pxc ...
- mysql5.6主从复制(读写分离)方案_MySQL5.6主从复制(读写分离)方案
MySQL5.6主从复制(读写分离)方案 一.前言:为什么MySQL要做主从复制(读写分离)? 通俗来讲,如果对数据库的读和写都在同一个数据库服务器中操作,业务系统性能会降低. 为了提升业务系统性能, ...
- mysql5.5数据库名_mysql5.5数据库名
Linux下Web开发服务器搭建之一_MySQL Linux下Web开发服务器搭建之一 安装与配置MySQL 在现在很多中小企业中,都喜欢使用Linux+Apache+MySQL+PHP的搭配来实现企 ...
- mysql5.7设置密码规则_MySQL5.7密码设置步骤
在安装完MySQL5.7之后,就需要通过mysql -u root进入mysql系统进行数据库&表的创建等工作. 但是在输入mysql -u root回车之后,会出现如下信息: ERROR 1 ...
- mysql5.7 sql监控_MySQL5.7中 performance和sys schema中的监控参数解释
MySQL5.7中的mysql performance和sys 监控参数 1.performance schema:介绍 在MySQL5.7中,performance schema有很大改进,包括引 ...
- mysql-5.5.59安装_MySQL-5.5 安装
准备工作 为了不影响实验效果,提前可以把selinux 和iptables 关闭 [root@localhost ~]# chkconfig iptables off [root@localhost ...
- mysql5.7.17配置_mysql5.7.17安装配置
一.创建msql用户#添加运行mysql的用户,禁止该用户登录系统 [root@openstack-01 ~]# useradd mysql -s /sbin/nologin 二.创建相关目录#创建 ...
- mysql5.6cmd中代码_Mysql5.6.22源代码安装
二:安装MySQL 安装编译代码需要的包 yum -y install make gcc-c++ cmake bison-devel ncurses-devel 下载MySQL 5.6.14 wget ...
最新文章
- .NET平台开源项目速览(3)小巧轻量级NoSQL文件数据库LiteDB
- 使用psycopg2操作PostgreSQL数据库之二
- 2021年必备 Python 插件!
- 如何给SAP Cloud Connector Region列表中添加新的Region
- CABAC之手把手教你编码
- Kettle之数据抽取、转换、装载
- mysql如何植入到oracle_分享MSSQL、MySql、Oracle的大数据批量导入方法及编程手法细节...
- mysql索引结构优缺点_mysql索引优缺点及注意事项
- thinkPHP5.0数据查询表达式生成技巧
- python 倒数_【IT专家】python实现文件倒数N行读取
- 【报告分享】2019年12月郭广昌混沌课程ppt(附下载链接)
- UVA 1324 The Largest Clique 最大团(强连通分量,变形)
- python-读取dcm文件-2021.5.24
- 2020高压电工考试软件及高压电工模拟考试题库
- MariaDB—— 14.存储引擎
- 考研政治---马克思主义基本原理概论---认识论
- poj 2152 树形dp(建立消防站)
- RabbitMQ入门到掌握
- 三十而已 豆瓣短评分析
- 传美光科技竞标尔必达获胜 收购金额25亿美元