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日志输出如下

 redis02
--09T15::.004758Z [Note] WSREP: Member 2.0 (pxc03) requested state transfer from '*any*'. Selected 0.0 (pxc02)(SYNCED) as donor.
--09T15::.004800Z [Note] WSREP: Shifting SYNCED -> DONOR/DESYNCED (TO: )
--09T15::.004867Z [Note] WSREP: wsrep_notify_cmd is not defined, skipping notification.
--09T15::.005039Z [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')
--09T15::.087469Z [Note] WSREP: DONOR thread signaled with

redis02被选为donar,使用xtrabackup备份整个库传到redis03下,同时查看redis03  /data/mysql

[root@redis03 mysql]# ls
galera.cache grastate.dat gvwstate.dat sst_in_progress

恢复完后如下

 [root@redis03 mysql]# ls
auto.cnf grastate.dat ib_logfile1 mysql-bin. public_key.pem server-cert.pem xtrabackup_info
ca-key.pem gvwstate.dat ibtmp1 mysql-bin.index pxc server-key.pem xtrabackup_master_key_id
ca.pem ht innobackup.move.log mysql.sock redis03-relay-bin-group_replication_applier. sys
client-cert.pem ib_buffer_pool innobackup.prepare.log mysql.sock.lock redis03-relay-bin-group_replication_applier.index xb_doublewrite
client-key.pem ibdata1 mysql performance_schema redis03-relay-bin-group_replication_recovery. xtrabackup_binlog_pos_innodb
galera.cache ib_logfile0 mysql-bin. 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--11e8-bc64-874d49a77c07 |
| wsrep_protocol_version | |
| wsrep_last_applied | |
| wsrep_last_committed | |
| wsrep_replicated | |
| wsrep_replicated_bytes | |
| wsrep_repl_keys | |
| wsrep_repl_keys_bytes | |
| wsrep_repl_data_bytes | |
| wsrep_repl_other_bytes | |
| wsrep_received | |
| wsrep_received_bytes | |
| wsrep_local_commits | |
| wsrep_local_cert_failures | |
| wsrep_local_replays | |
| wsrep_local_send_queue | |
| wsrep_local_send_queue_max | |
| wsrep_local_send_queue_min | |
| wsrep_local_send_queue_avg | 0.000000 |
| wsrep_local_recv_queue | |
| wsrep_local_recv_queue_max | |
| wsrep_local_recv_queue_min | |
| wsrep_local_recv_queue_avg | 0.000000 |
| wsrep_local_cached_downto | |
| wsrep_flow_control_paused_ns | |
| wsrep_flow_control_paused | 0.000000 |
| wsrep_flow_control_sent | |
| wsrep_flow_control_recv | |
| wsrep_flow_control_interval | [ , ] |
| wsrep_flow_control_interval_low | |
| wsrep_flow_control_interval_high | |
| 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 | |
| wsrep_local_state_comment | Synced |
| wsrep_cert_index_size | |
| wsrep_cert_bucket_count | |
| wsrep_gcache_pool_size | |
| wsrep_causal_reads | |
| wsrep_cert_interval | 0.000000 |
| wsrep_ist_receive_status | |
| wsrep_ist_receive_seqno_start | |
| wsrep_ist_receive_seqno_current | |
| wsrep_ist_receive_seqno_end | |
| wsrep_incoming_addresses | 192.168.20.202:,192.168.20.201:,192.168.20.203: |
| wsrep_desync_count | |
| wsrep_evs_delayed | |
| wsrep_evs_evict_list | |
| wsrep_evs_repl_latency | //// |
| wsrep_evs_state | OPERATIONAL |
| wsrep_gcomm_uuid | ee9c63ef--11e8-af36-8bf4f2f07974 |
| wsrep_cluster_conf_id | |
| wsrep_cluster_size | |
| wsrep_cluster_state_uuid | 62e9006b--11e8-bc64-874d49a77c07 |
| wsrep_cluster_status | Primary |
| wsrep_connected | ON |
| wsrep_local_bf_aborts | |
| wsrep_local_index | |
| wsrep_provider_name | Galera |
| wsrep_provider_vendor | Codership Oy <info@codership.com> |
| wsrep_provider_version | 3.26(rac090bc) |
| wsrep_ready | ON |
+----------------------------------+-------------------------------------------------------------+

在对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测试结果如下

 [root@redis01 sysbench]# sysbench oltp_read_write.lua --db-driver=mysql --mysql-host=127.0.0.1 --mysql-port= --mysql-db=pxc --mysql-user=root --mysql-password=ocm123 --table_size=  --tables= --threads= --report-interval= --time=  run
sysbench 1.0. (using bundled LuaJIT 2.1.-beta2) Running the test with following options:
Number of threads:
Report intermediate results every second(s)
Initializing random number generator from current time Initializing worker threads... Threads started! [ 10s ] thds: tps: 7.90 qps: 231.92 (r/w/o: 168.04/26.19/37.69) lat (ms,%): 5813.24 err/s: 0.00 reconn/s: 0.00
[ 20s ] thds: tps: 11.80 qps: 254.99 (r/w/o: 177.69/32.30/45.00) lat (ms,%): 5918.87 err/s: 0.00 reconn/s: 0.00
[ 30s ] thds: tps: 8.90 qps: 179.97 (r/w/o: 124.58/26.10/29.30) lat (ms,%): 6476.48 err/s: 0.00 reconn/s: 0.00
[ 40s ] thds: tps: 10.40 qps: 175.17 (r/w/o: 122.35/19.81/33.01) lat (ms,%): 9284.15 err/s: 0.00 reconn/s: 0.00
[ 50s ] thds: tps: 9.20 qps: 182.49 (r/w/o: 131.10/21.90/29.50) lat (ms,%): 9799.46 err/s: 0.00 reconn/s: 0.00
[ 60s ] thds: tps: 8.80 qps: 198.65 (r/w/o: 140.97/24.39/33.29) lat (ms,%): 7215.39 err/s: 0.00 reconn/s: 0.00
[ 70s ] thds: tps: 7.00 qps: 145.72 (r/w/o: 99.01/21.60/25.10) lat (ms,%): 8795.93 err/s: 0.00 reconn/s: 0.00
[ 80s ] thds: tps: 13.70 qps: 239.41 (r/w/o: 171.21/27.20/41.00) lat (ms,%): 8484.79 err/s: 0.00 reconn/s: 0.00
[ 90s ] thds: tps: 7.40 qps: 161.92 (r/w/o: 107.41/24.90/29.60) lat (ms,%): 8484.79 err/s: 0.00 reconn/s: 0.00
[ 100s ] thds: tps: 8.00 qps: 186.69 (r/w/o: 130.99/24.00/31.70) lat (ms,%): 5918.87 err/s: 0.00 reconn/s: 0.00
[ 110s ] thds: tps: 10.00 qps: 200.01 (r/w/o: 140.00/27.40/32.60) lat (ms,%): 5709.50 err/s: 0.00 reconn/s: 0.00
[ 120s ] thds: tps: 10.60 qps: 210.17 (r/w/o: 148.38/25.60/36.19) lat (ms,%): 8184.67 err/s: 0.00 reconn/s: 0.00
[ 130s ] thds: tps: 11.50 qps: 223.73 (r/w/o: 159.42/24.70/39.61) lat (ms,%): 7895.16 err/s: 0.00 reconn/s: 0.00
[ 140s ] thds: tps: 11.90 qps: 242.60 (r/w/o: 168.03/31.09/43.48) lat (ms,%): 4943.53 err/s: 0.00 reconn/s: 0.00
[ 150s ] thds: tps: 9.10 qps: 185.45 (r/w/o: 127.53/26.21/31.71) lat (ms,%): 4517.90 err/s: 0.00 reconn/s: 0.00
[ 160s ] thds: tps: 14.50 qps: 253.44 (r/w/o: 179.83/27.70/45.91) lat (ms,%): 8184.67 err/s: 0.00 reconn/s: 0.00
[ 170s ] thds: tps: 8.40 qps: 203.91 (r/w/o: 140.80/28.10/35.00) lat (ms,%): 4943.53 err/s: 0.00 reconn/s: 0.00
[ 180s ] thds: tps: 13.90 qps: 261.61 (r/w/o: 187.64/28.89/45.08) lat (ms,%): 7754.26 err/s: 0.00 reconn/s: 0.00
[ 190s ] thds: tps: 10.50 qps: 226.94 (r/w/o: 153.93/35.31/37.71) lat (ms,%): 7754.26 err/s: 0.00 reconn/s: 0.00
[ 200s ] thds: tps: 12.00 qps: 218.73 (r/w/o: 153.52/25.30/39.91) lat (ms,%): 4203.93 err/s: 0.00 reconn/s: 0.00
[ 210s ] thds: tps: 11.80 qps: 249.64 (r/w/o: 177.76/29.89/41.99) lat (ms,%): 5607.61 err/s: 0.00 reconn/s: 0.00
[ 220s ] thds: tps: 12.69 qps: 256.80 (r/w/o: 178.93/30.99/46.88) lat (ms,%): 4517.90 err/s: 0.00 reconn/s: 0.00
[ 230s ] thds: tps: 14.01 qps: 253.05 (r/w/o: 180.41/27.62/45.03) lat (ms,%): 5709.50 err/s: 0.00 reconn/s: 0.00
[ 240s ] thds: tps: 9.20 qps: 211.70 (r/w/o: 145.10/31.10/35.50) lat (ms,%): 5507.54 err/s: 0.00 reconn/s: 0.00
[ 250s ] thds: tps: 14.10 qps: 259.32 (r/w/o: 186.52/29.30/43.50) lat (ms,%): 7086.63 err/s: 0.00 reconn/s: 0.00
[ 260s ] thds: tps: 9.20 qps: 210.87 (r/w/o: 139.78/35.00/36.10) lat (ms,%): 8038.61 err/s: 0.00 reconn/s: 0.00
[ 270s ] thds: tps: 11.20 qps: 222.78 (r/w/o: 156.79/27.50/38.50) lat (ms,%): 6026.41 err/s: 0.00 reconn/s: 0.00
[ 280s ] thds: tps: 11.50 qps: 230.55 (r/w/o: 160.73/31.31/38.51) lat (ms,%): 7615.89 err/s: 0.00 reconn/s: 0.00
[ 290s ] thds: tps: 12.80 qps: 255.18 (r/w/o: 179.29/30.90/45.00) lat (ms,%): 7086.63 err/s: 0.00 reconn/s: 0.00
[ 300s ] thds: tps: 12.90 qps: 237.20 (r/w/o: 171.00/24.80/41.40) lat (ms,%): 6247.39 err/s: 0.00 reconn/s: 0.00
SQL statistics:
queries performed:
read:
write:
other:
total:
transactions: (10.93 per sec.)
queries: (218.52 per sec.)
ignored errors: (0.00 per sec.)
reconnects: (0.00 per sec.) General statistics:
total time: .9413s
total number of events: Latency (ms):
min: 975.37
avg: 4575.91
max: 13565.48
95th percentile: 7479.98
sum: 15095927.24 Threads fairness:
events (avg/stddev): 65.9800/1.97
execution time (avg/stddev): 301.9185/0.01

pxc的  qtp才为11 (虚拟机,3节点在一个磁盘上)

最新文章

  1. java25
  2. codeforce 121E - Lucky Array
  3. 安装.cer证书并将证书从.cer格式转化为.pem格式
  4. C#在excel中添加超链接
  5. Atitit.hybrid混合型应用 浏览器插件,控件的实现方式 浏览器运行本地程序的解决方案大的总结---提升用户体验and开发效率..
  6. JAVA学习绘图颜色及其笔画属性设置字体显示文字
  7. jQuery插件:模拟select下拉菜单
  8. Tomcat 7优化前及优化后的性能对比
  9. Jalopy 之 HelloWorld —— Jalopy 在 MyEclipse 下的安装与使用
  10. 【转载】C++ inline 函数
  11. How to download a website for offline usage
  12. Mysql slave 状态之Seconds_Behind_Master
  13. 导航栏控制器和标签栏控制器(UINavigationController和UITabBarController)混用
  14. 使用jQuery实现tag便签去重效果
  15. Java多线程学习之ThreadLocal源码分析
  16. Head First设计模式之桥接模式
  17. 质心坐标(barycentric coordinates)及其应用
  18. TCP协议和UDP协议基础介绍
  19. Canvas绘图优化之使用位图--基于createjs库
  20. C# WPF DataGrid 分组(Group)

热门文章

  1. HDU 1575(裸矩阵快速幂)
  2. 使用yield和send实现简单的协程函数
  3. 在Java中调用Python
  4. js工具库
  5. bash test命令探秘
  6. 《Python数据可视化编程实战》
  7. VUE项目安装
  8. xtrabackup 在线主从搭建
  9. CPU缓存一致性协议—MESI详解
  10. 360doc个人图书馆解决复制问题