自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

MySQL組復(fù)制技術(shù)實(shí)現(xiàn)與數(shù)據(jù)庫(kù)性能測(cè)試工具

原創(chuàng)
數(shù)據(jù)庫(kù)
MySQL當(dāng)前存在的三種復(fù)制模式有:異步模式、半同步模式和組復(fù)制模式。本次主要調(diào)研MySQL組復(fù)制技術(shù)實(shí)現(xiàn),與數(shù)據(jù)庫(kù)性能測(cè)試工具使用。

【51CTO.com原創(chuàng)稿件】MySQL 當(dāng)前存在的三種復(fù)制模式有:異步模式、半同步模式和組復(fù)制模式。本次主要調(diào)研 MySQL 組復(fù)制技術(shù)實(shí)現(xiàn),與數(shù)據(jù)庫(kù)性能測(cè)試工具使用。

測(cè)試環(huán)境

本文檔是在 99Cloud Lab OpenStack 平臺(tái)虛機(jī)上面測(cè)試,僅供參考。

系統(tǒng): CentOS 7.3

虛機(jī): 2 核 4G

版本: MySQL 5.7

技術(shù)架構(gòu)

MySQL Group Replication(簡(jiǎn)稱 MGR)是官方推出的高可用解決方案,原生復(fù)制技術(shù),基于插件的方式工作。其中 single primary mode 單主模式只有一個(gè)讀寫,其余都是只讀。

multi primary mode多主模式全部可讀寫

不管組復(fù)制單主還是多主的故障切換都無(wú)法讓應(yīng)用無(wú)感知,需要自主實(shí)現(xiàn),包含以下特性:

  •     復(fù)制管理操作更為自動(dòng)化。
  •     通過 Paxos 協(xié)議提供數(shù)據(jù)庫(kù)集群節(jié)點(diǎn)數(shù)據(jù)強(qiáng)一致性保證。
  •     多主模式所有節(jié)點(diǎn)都可讀寫操作。
  •     解決網(wǎng)絡(luò)分區(qū)導(dǎo)致的腦裂問題,提升復(fù)制數(shù)據(jù)的可靠性。

一些不足

01、官方引言

 Quite obviously, regardless the mode Group Replication is deployed, it does not handle client-side fail-over. That must be handled by the application itself, connector or a middleware framework such as a proxy or router.

意思就是 MGR 內(nèi)部沒有提供一種機(jī)制來(lái)實(shí)現(xiàn)主節(jié)點(diǎn)故障切換對(duì)應(yīng)用的無(wú)感知。應(yīng)用的這種故障無(wú)感知需要借助外力實(shí)現(xiàn)。

02、組復(fù)制的局限

所有涉及的數(shù)據(jù)都必須發(fā)生在 InnoDB 存儲(chǔ)引擎的表內(nèi)。

  •     所有的表必須有明確的主鍵定義。
  •     網(wǎng)絡(luò)地址只支持 IPv4。
  •     需要低延遲,高帶寬的網(wǎng)絡(luò)。
  •     目前集群限制最多允許 9 個(gè)節(jié)點(diǎn)。
  •     必須啟用 binlog。
  •     binlog 格式必須是 row 格式。
  •     必須打開 gtid 模式。
  •     復(fù)制相關(guān)信息必須使用表存儲(chǔ)。
  •     事務(wù)寫集合(Transaction write set extraction)必須打開。
  •     log slave updates 必須打開。
  •     binlog 的 checksum 目前不支持。
  •     由于事務(wù)寫集合的干擾,無(wú)法使用 savepoint。
  •     serializable 隔離級(jí)別目前不支持。
  •     對(duì)同一個(gè)對(duì)象,在集群中不同的實(shí)例上,并行地執(zhí)行 DDL(哪怕是相互沖突的DDL)是可行的,但會(huì)導(dǎo)致數(shù)據(jù)一致性等方面的錯(cuò)誤,目前階段不支持在多節(jié)點(diǎn)同時(shí)執(zhí)行同一對(duì)象的 DDL。
  •     外鍵的級(jí)聯(lián)約束操作目前的實(shí)現(xiàn)并不完全支持,不推薦使用。

實(shí)驗(yàn)搭建

01、實(shí)驗(yàn)環(huán)境

主機(jī)名

主機(jī)地址

組復(fù)制端口

mysql01

172.16.200.4

33061

mysql02

172.16.200.6

33062

mysql03

172.16.200.9

33063

02、安裝軟件

數(shù)據(jù)庫(kù)主配文件定義

  1. datadir=/var/lib/mysql  
  2. socket=/var/lib/mysql/mysql.sock 
  3. report_host = 172.16.200.4 
  4. max_connections = 4096 
  5. # Disabling symbolic-links is recommended to prevent assorted security risks 
  6. symbolic-links=0 
  7. log-error=/var/log/mysqld.log 
  8. pid-file=/var/run/mysqld/mysqld.pid 
  9. server_id=1 
  10. gtid_mode=ON 
  11. enforce_gtid_consistency=ON 
  12. master_info_repository=TABLE 
  13. relay_log_info_repository=TABLE 
  14. binlog_checksum=NONE 
  15. log_slave_updates=ON 
  16. log_bin=binlog 
  17. binlog_format=ROW 
  18. # Group Replication configuration 
  19. transaction_write_set_extraction=XXHASH64 
  20. loose-group_replication_group_name="09f09aca-2ee4-44f7-b4bb-7d5fe32b52a4"  
  21. loose-group_replication_start_on_boot=off 
  22. loose-group_replication_local_address= "172.16.200.4:33061" 
  23. loose-group_replication_group_seeds= "172.16.200.9:33063,172.16.200.4:33061,172.16.200.6:33062" 
  24. loose-group_replication_bootstrap_group= off 
  25. #loose-group_replication_single_primary_mode=FALSE 
  26. #loose-group_replication_enforce_update_everywhere_checks= TRUE 

03、復(fù)制授權(quán)

進(jìn)入數(shù)據(jù)庫(kù)

  1. mysql> SET SQL_LOG_BIN=0
  2. mysql> CREATE USER rpl_user@'%' IDENTIFIED BY 'rpl_pass'; 
  3. mysql> GRANT REPLICATION SLAVE ON *.* TO rpl_user@'%'; 
  4. mysql> FLUSH PRIVILEGES; 
  5. mysql> SET SQL_LOG_BIN=1
  6. mysql> CHANGE MASTER TO MASTER_USER='rpl_user'MASTER_PASSWORD='rpl_pass'      FOR CHANNEL 'group_replication_recovery'; 

04、啟動(dòng)組復(fù)制

安裝插件

  1. INSTALL PLUGIN group_replication SONAME 'group_replication.so';  

啟動(dòng)復(fù)制通道

  1. SET GLOBAL group_replication_bootstrap_group=ON; 
  2. START GROUP_REPLICATION; 
  3. SET GLOBAL group_replication_bootstrap_group=OFF; 

查看集群成員

  1. mysql> SELECT * FROM performance_schema.replication_group_members; 

創(chuàng)建測(cè)試同步數(shù)據(jù)

  1. mysql> CREATE DATABASE test; 
  2. mysql> USE test; 
  3. mysql> CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 TEXT NOT NULL); 
  4. mysql> INSERT INTO t1 VALUES (1'Luis'); 

檢查同步數(shù)據(jù)和 Binlog

05、加入集群

其余節(jié)點(diǎn)加入集群

1)先定義主配文件與主機(jī) hosts

2)建立通道授權(quán)

  1. SET SQL_LOG_BIN=0
  2. CREATE USER rpl_user@'%' IDENTIFIED BY 'rpl_pass' ; 
  3. GRANT REPLICATION SLAVE ON *.* TO rpl_user@'%' IDENTIFIED BY 'rpl_pass'
  4. SET SQL_LOG_BIN=1
  5. CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='rpl_pass'  
  6.     FOR CHANNEL 'group_replication_recovery'

3)添加插件

  1. mysql>INSTALLPLUGINgroup_replicationSONAME'group_replication.so'

4)啟動(dòng)復(fù)制通道

  1. mysql>STARTGROUP_REPLICATION; 

5)查看集群成員

  1. mysql>SELECT*FROMperformance_schema.replication_group_members; 

06、集群驗(yàn)證

在各個(gè)節(jié)點(diǎn)都能看到同步的數(shù)據(jù),說(shuō)明集群搭建成功。

查看集群中的主節(jié)點(diǎn)

  1. mysql> SELECT VARIABLE_VALUE FROM performance_schema.global_status
  2. WHERE VARIABLE_NAME= 'group_replication_primary_member'

性能測(cè)試

01、工具選型

對(duì)于 MySQL 壓力測(cè)試,大多用 sysbench/tpcc-mysql 工具,主要針對(duì)數(shù)據(jù)庫(kù) OLTP(在線事務(wù)處理)指標(biāo)。

在編輯 tpcc-mysql 環(huán)境時(shí)依賴 mysql_config,MySQL 5.7 版本以后 mysql_config 更換為了 pkg--config,明顯 tpcc-mysql 跟不上節(jié)奏。

本文檔性能測(cè)試工具選用sysbench 1.0.6

02、工具用法

準(zhǔn)備測(cè)試數(shù)據(jù)

 sysbencholtp_read_write.lua --mysql-host=172.16.200.4 --mysql-port=3306 --mysql-db=test --mysql-user=root --mysql-password=MyNewPass4! --table_size=5000 --tables=10 --threads=300 --time=60 --report-interval=10 prepare

開始?jí)簻y(cè)

 sysbencholtp_read_write.lua --mysql-host=172.16.200.4 --mysql-port=3306 --mysql-db=test --mysql-user=root --mysql-password=MyNewPass4! --table_size=5000 --tables=10 --threads=300 --time=60 --report-interval=10 run

清除測(cè)試數(shù)據(jù)

 sysbencholtp_read_write.lua --mysql-host=172.16.200.4 --mysql-port=3306 --mysql-db=test --mysql-user=root --mysql-password=MyNewPass4! --table_size=5000 --tables=10 --threads=300 --time=60 --report-interval=10 cleanup

03、壓測(cè) screen view

準(zhǔn)備測(cè)試數(shù)據(jù)

集群測(cè)試

單機(jī)測(cè)試

04、測(cè)試結(jié)果

 

tps

qps

備注

單機(jī)

576.86

11617.78

 

集群(3節(jié)點(diǎn)single mode)

263.48

7507.35

單個(gè)IP讀寫

集群(3節(jié)點(diǎn)multi mode)

307.19

8343.02

單個(gè)IP讀寫

調(diào)研結(jié)果

組復(fù)制模式配置比異步復(fù)制,半同步復(fù)制簡(jiǎn)單便捷,數(shù)據(jù)同步效率也較高,組復(fù)制以插件形式工作。不管組復(fù)制單主還是多主的故障切換都無(wú)法讓應(yīng)用無(wú)感知,需要自主實(shí)現(xiàn)。

參考文檔

單庫(kù)安裝:https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html

集群安裝:https://dev.mysql.com/doc/refman/5.7/en/group-replication-deploying-in-single-primary-mode.html

【51CTO原創(chuàng)稿件,合作站點(diǎn)轉(zhuǎn)載請(qǐng)注明原文作者和出處為51CTO.com】

責(zé)任編輯:王雪燕 來(lái)源: 51CTO
相關(guān)推薦

2013-05-23 09:40:09

LinkBench性能測(cè)試數(shù)據(jù)庫(kù)性能測(cè)試

2012-08-01 10:50:48

性能測(cè)試測(cè)試架構(gòu)

2014-07-11 09:48:42

2012-06-28 10:18:01

數(shù)據(jù)庫(kù)

2010-10-15 09:37:14

MySQL性能測(cè)試

2021-05-07 07:27:51

Python測(cè)試工具

2011-08-04 09:57:03

dbmonsterMySQL

2023-12-08 13:15:00

MySQL數(shù)據(jù)庫(kù)Java

2021-06-02 07:15:57

Locust測(cè)試工具

2010-06-04 16:07:09

Linux 性能測(cè)試工

2010-06-07 14:42:47

Linux性能測(cè)試工具

2025-01-26 11:05:23

2022-06-22 09:41:16

接口異常測(cè)試

2024-03-06 18:09:06

Linux性能工具

2016-09-14 11:09:06

Web工具運(yùn)維

2024-11-19 13:11:19

2010-05-17 13:16:23

MySQL壓力測(cè)試工具

2010-06-10 17:37:08

Linux 性能測(cè)試工

2019-08-30 09:32:32

監(jiān)控負(fù)載測(cè)試工具

2011-05-18 09:39:19

Oracle數(shù)據(jù)庫(kù)性能優(yōu)化
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)