SlideShare uma empresa Scribd logo
1 de 49
Baixar para ler offline
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
馬楚成 - 首席技術顧問
Ivan Ma
2015-12-19
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
MySQL複製的演進和應用
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for
information purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality, and should not be relied upon
in making purchasing decisions. The development, release, and timing of any features or
functionality described for Oracle’s products remains at the sole discretion of Oracle.
2
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
目录
MySQL複製基礎 與 演進發展
MySQL複製應用
MySQL 5.7 GA的複製新功能
In labs - Group Replication和MySQL集群管理
1
2
3
4
3
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL複製基礎
與
演進發展
1
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
• 3.23
– One-way Replication
• 4.1
– Support was added for replication over SSL
connections
• 5.0/5.1
– Row-based Replication
• 5.5
– Semi-Sync Replication
– Replication Heartbeat
– Per server Replication Filter
• 5.6
– GTID
– Crash Safe Slave and Binlog
– Binlog Group Commit
– Optimized Row Based Replication
– Multi-threaded Slave (per Database)
– Time-delayed Replication
– Utility for Failover and Admin
• 5.7
– What’s New 复制新功能
MySQL 復製演進發展
5
2015年10月26日MySQL 5.7.9 GA啦
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
複製基礎 :複製的框架
Insert...
Insert...
B
binary log
Insert...
relay log
Insert...
A
binary log
Client
Dump
thread
IO
thread
SQL
Threads
Receiver
Meta-data
Update
Applier
Meta-data
Update
Network
6
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
複製基礎 :複製的框架
Insert...
Insert...
B
binary log
Insert...
relay log
Insert...
A
binary log
Client
Sender
thread
Receiver
thread
Applier
Threads
Receiver
Meta-data
Update
Applier
Meta-data
Update
Network
7
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
複製基礎 :複製的框架
• Binary Log
– 基於文件的邏輯日誌,記錄了Master上數據的變化。
• 語句格式(Statement),行格式(Row),混合模式(Mixed)。
– 每個事務會被記錄為一組Binlog Events.
– Control events: Rotate, Format Description, Gtid, ... Layout of a
Binary Log File
GTID ...E1 E2 COMMIT ...E1 E2 COMMIT
8
BEGIN GTID BEGIN...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
M S
write clients read clients
讀性能的擴展(Read scale-out)
複製基礎:複製的應用
9
S
S
S
M
read clients
write clients
More
reads?
More
slaves!
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
C
B
A
C
B
ACrash
Uh Oh!
C
B
A
B is the
new master
Whew!
Redundancy: 如果主服務器宕機,可以用一個從服務器來做新的主服務器。
複製基礎:複製的應用
10
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
使用不同存储引擎(Storage Engine)
複製基礎:複製的應用
11
https://dev.mysql.com/doc/refman/5.6/en/replication-solutions-diffengines.html
SE=ndb SE=InnoDB
Analytic
Replication
SE=ndb
SE=ndb
SE=ndb
ndbd ndbd ndbd ndbd
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
M
write clients
在線備份和做報表(On-line Backup and Reporting)
複製基礎:複製的應用
12
S
報表應用
海量信息查詢
S 在線備份
S
[ BI ] 商業智能應用
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
CB
BA
AC
Image from
www.ginkgomaps.com
複製基礎:複製的應用
遠距離數據分發
13
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL Fabric 通过数据分片来提升MySQL的性能...
那麼寫性能的擴展(write scale-out)呢?
14
S
M M
多源複製
M M
數據分片生成
MySQL 5.7
新功能
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL 5.7 GA裡的複製新功能
http://mysqlhighavailability.com/replication-in-mysql-5-7-ga/
3
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL 5.7 GA裡的複製新功能
GTID 新功能
多線程複製(Multi-Threaded Slave)新功能
多源複製(Multiple Source Replication)
Slave可用性的改進 / Master 性能的提升
半同步複製(Semi-synchronous Replication)的新功能
其他功能…
3
2015年11月21日星期六
3.1
3.2
3.3
3.4
3.5
MySQL @ 2015 Oracle 技术嘉年华
3.6
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
在線配置-GTID功能
• 挑戰
– 多台服務器的複製拓扑,5.6上-以GTID切換 – 要重啟服務器!!。
• 在線配置
– 整個配置過程,不需要重启MySQL服务器
– 不需要改變複製拓撲結構
– 簡化了的配置過程
GTID —Non-GTID
兼容
• GTID_MODE=OFF_PERMISSIVE
启用GTID
• GTID_MODE=ON_PERMISSIVE
等待所有服務器生
成GTID
• 等等等等等
只接受GTID
• GTID_MODE=ON
X
完整配置過程:
http://dev.mysql.com/doc/refman/5.7/en/replication-mode-
change-online-enable-gtids.html
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
存儲GTID到系統表中
• Slaves可以在不開啟binlog的條件下,使用GTID功能
– 有些Slave服務器永遠不會被當maser來使用,就不用開啟binlog.但這些服務器仍然
可以使用GTID及AUTO_POSITION來簡化管理。
• 保障意外刪除binlog
應用場景
18
在系統數據庫MySQL的,加了一張表gtid_executed
TABLE gtid_executed(
source_uuid CHAR(36) NOT NULL,
interval_start BIGINT NOT NULL,
interval_end BIGINT NOT NULL,
PRIMARY KEY(source_uuid, interval_start)
);
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 19
mysql 事 的数量mysql> SET GLOBAL gtid_executed_compression_period= N;(N – 事务的数量)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
存储GTID到系统表中
• 当binlog启用时
– 存储GTID到binlog.
– 只在binlog文件切换时,将该binlog文件中包含的gtid集合写入表中
– 性能比每事务写表高
• 当binlog未启用时
– 每个事务提交时,存储GTID到表中
• 始终crash-safe.
实现机制
20
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL 5.7 GA裡的複製新功能
GTID 新功能
多線程複製(Multi-Threaded Slave)新功能
多源複製(Multiple Source Replication)
Slave可用性的改進 / Master 性能的提升
半同步複製(Semi-synchronous Replication)的新功能
其他功能…
3
2015年11月21日星期六
3.1
3.2
3.3
3.4
3.5
MySQL @ 2015 Oracle 技术嘉年华
3.6
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
多線程的並發複製
• 支持語句(statement format)和行(row format)格式的binlog.
• 並發策略通過系統變量控制:
– logical_clock -採用基於鎖的並發策略
– database - 基於數據庫的並發策略(在MySQL-5.6上的並發機制)
mysqlmysql> SET slave_parallel_type= [logical_clock|database]
22
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
多線程的並發複製 (MTS Applier)
2015年11月21日星期六
Single Threaded Apply 8 Threads Applier 24 Threads Applier 48 Threads Applier 96 Threads Applier
0%
50%
100%
150%
200%
250%
Fast and Scalable Multi-threaded Replication Applier
(statement-based replication, durable settings, SSD storage)
Slaveapplytime
(SysbenchRWonthemasterwith96threads=100%)
10X
MySQL @ 2015 Oracle 技术嘉年华 23
slave_parallel_type= LOGICAL_CLOCK
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
多線程的並發複製 (MTS Applier)
T1
T2
T3
Time
Commit 完成
事務獲取了所有的鎖
Master上的並發執行過程
Execution
Commit
T1 和T2可並發
24
• Master上的並發信息,以邏輯
時間(Logical clock)的方式記入
gtid_log_event中。
• 具有重疊COMMIT持續時間,可
並行執行的交易
在Slave上,
T1和T2並發執行;
T3在T1完成後,
開始執行.
T2和T3可並發
slave_parallel_type= LOGICAL_CLOCK
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL 5.7 GA裡的複製新功能
GTID 新功能
多線程複製(Multi-Threaded Slave)新功能
多源複製(Multiple Source Replication)
Slave可用性的改進 / Master 性能的提升
半同步複製(Semi-synchronous Replication)的新功能
其他功能…
3
2015年11月21日星期六
3.1
3.2
3.3
3.4
3.5
MySQL @ 2015 Oracle 技术嘉年华
3.6
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
多源複製
Slave
M M
Slave可以有多個複制源
M M
聚合數據到一台數據庫服務器上的場景:
• 集成備份;
• 複合數據分析方面的用途;
• 分片數據的合併
27
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
多源複製
28
Insert...
B
binary log
Insert...
relay log
Master 1
A
Receiver
thread
Applier
Threads
Master info Relay info
Network
Named Channel
“Channel_1”
Insert...
relay log
Master 2
C
Master info Relay info
Network
Named Channel
“Channel_2”
Slave
Named Channel
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 29
replication_connection_status
replication_applier_status
改進的複制監控信息
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL 5.7 GA裡的複製新功能
GTID 新功能
多線程複製(Multi-Threaded Slave)新功能
多源複製(Multiple Source Replication)
Slave可用性的改進 / Master 性能的提升
半同步複製(Semi-synchronous Replication)的新功能
其他功能…
3
2015年11月21日星期六
3.1
3.2
3.3
3.4
3.5
MySQL @ 2015 Oracle 技术嘉年华
3.6
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Applier
在線配置Receiver/Applier
• 切換Master時,Applier線程仍然在運行:
• 改變applier參數時,receiver線程仍然在運行:
mysql
mysql
mysql> STOP SLAVE IO_THREAD;
mysql> CHANGE MASTER TO MASTER_HOST='master2', …;
mysql> START SLAVE IO_THREAD;
mysql> STOP SLAVE SQL_THREAD;
mysql
mysql> STOP SLAVE SQL_THREAD;
mysql> CHANGE MASTER TO MASTER_DELAY=3600, …;
mysql> START SLAVE SQL_THREAD;
31
C
B
A
B成為新
Master
Crash
切换数据源从A 到 B,无需停止applier threads.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
在線變更Replication Filter參數
• 動態變更Replication Filters
– 不再需要重啟MySQL server
– 支持所有的Filter選項
– 支持各種字符集
mysqlmysql> CHANGE REPLICATION FILTER REPLICATE_DO_DB= (db1, db2)
32
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
並發讀寫binlog
• sender 線程在讀binlog的同時,用戶線程並發的記錄binlog日誌.
– Sender線程和用戶線程在讀寫binlog時,不再互相阻塞對方
– Sender線程和用戶線程都有更好的性能
Sender Thread Reads Binary Log User Thread Writes to Binary Log
Sender Thread Reads Binary Log
User Thread Writes to Binary Log
pre 5.7.2
5.7.2+
33
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL 5.7 GA裡的複製新功能
GTID 新功能
多線程複製(Multi-Threaded Slave)新功能
多源複製(Multiple Source Replication)
Slave可用性的改進 / Master 性能的提升
半同步複製(Semi-synchronous Replication)的新功能
其他功能…
3
2015年11月21日星期六
3.1
3.2
3.3
3.4
3.5
MySQL @ 2015 Oracle 技术嘉年华
3.6
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
無數據丟失的半同步複製
Insert...
Insert...
B
binary log
Insert...
relay log
Insert...
A
binary log
Client
Sender
thread
Receiver
thread
Applier
Threads
Receiver
Meta-data
Update
Applier
Meta-data
Update
Network
35
1
2
3
4 - ACK
5
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
無數據丟失的半同步複製
Master
Slave
T1: INSERT INTO t1 VALUES (1000)
ACK
Time
T2: SELECT * FROM t1; T1 (1000)
execute prepare binlog
relay log
commit execute
36
mysqlmysql> SET rpl_semi_sync_master_wait_point= [AFTER_SYNC|AFTER_COMMIT]
T2 看到 t1(1000)
MySQL 5.6上: Master在commit後,才等待Slave的應答
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
無數據丟失的半同步複製
Master
Slave
T1: INSERT INTO t1 VALUES (1000)
ACK
Time
T2: SELECT * FROM t1; empty set
execute prepare binlog
relay log
commitexecute
37
mysqlmysql> SET rpl_semi_sync_master_wait_point= [AFTER_SYNC|AFTER_COMMIT]
T2 看不到 t1(1000)
Master 在收到slave的應答後才Commit事務
因此在確認事務複製到Slave上之前,並發的事務看不到當前事務的數據.a
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
• 單工通信方式,事務發送完畢後,要接收和處理應答。處理完答後才能
繼續發送下事務的Events。
MySQL-5.6
半同步複製更快 – ACK接收線程
Sender
Receiver
Time
Send
Trx
Receive
ACK
38
Report
ACK
Send
ACK
Receive
Trx
Send
Trx
Receive
Trx
Send
ACK
Receive
ACK
Report
ACK
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL-5.7
• 新加的應答ACK接收線程。
• 變成雙工模式。發送和接收互不影響。
半同步複製更快 – ACK接收線程
Sender
Receiver
ACK Time
39
ACK
ACK
Receiver
Send
Trx
Send
Trx
Send
Trx
Send
ACK
Receive
Trx
Send
ACK
Receive
Trx
Receive
ACK
Report
ACK
Receive
ACK
Report
ACK
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
半同步複製– 等待多個Slave的應答
• Master 接收到N個slave的應答後,才commit 事務.
• 用戶可以設置應答Slave的數量:
mysqlmysql> SET GLOBAL rpl_semi_sync_master_wait_for_slave_count= N
40
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
半同步複製– 等待多個Slave的應答
• Master 接收到N個slave的應答後,才commit 事務.
• 用戶可以設置應答Slave的數量:
mysqlmysql> SET GLOBAL rpl_semi_sync_master_wait_for_slave_count= N
Master
Slave 2
T1: Binlog
ACK
Slave 1
ACK
T1: COMMIT
succeeds
mysql> SET GLOBAL rpl_semi_sync_master_wait_for_slave_count= 2
Slave 3
Time
relay log
relay log
relay log
41
ACK
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL 5.7 GA裡的複製新功能
GTID 新功能
多線程複製(Multi-Threaded Slave)新功能
多源複製(Multiple Source Replication)
Slave可用性的改進 / Master 性能的提升
半同步複製(Semi-synchronous Replication)的新功能
其他功能…
3
2015年11月21日星期六
3.1
3.2
3.3
3.4
3.5
MySQL @ 2015 Oracle 技术嘉年华
3.6
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL Group Replication
2015年11月21日星期六
M M M
APP
• 虛擬的同步複製
• Shared-nothing state machine replication.
• 多master同時更新
• 沒有單點故障,不需要fail-over
• 自我管理
– 自動化創建同步新 節點和移除節點。
– 自動化故障檢測和節點管理。
MySQL @ 2015 Oracle 技术嘉年华 43
Write
Write
Write
Replication Group
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL Group Replication的實現
2015年11月21日星期六
M M M
APP
Replication Group
• 是一個MySQL plugin
• 基於row format 和InnoDB
– 用PK來做衝突檢測
• 基於GTID
• 可通過performance schema監控.
• MySQL-5.7.9 加入了XCom來替代corosync
– 更加容易編譯、安裝和使用。
– 支持更多操作系統:
Linux, Solaris, FreeBSD, OSX and Windows
MySQL @ 2015 Oracle 技术嘉年华 44
Write
Write
Write
Group Replication
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL Router
• 基於Connection的路由和負載均衡
• 可對多台服務器作分別路由。
• 平滑的故障切換(fail-over)
• 对APP是透明的
– 不需要升級connectors.
– 沒有connector的語言限制
• 高性能
• 簡單易用
2015年11月21日星期六 MySQL @ 2015 Oracle 技术嘉年华
NEW
45
GA
Group Replication
App
MySQL
Router
connectors
M M M
Virtual MySQL Server
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
总结
MySQL複製基礎 與 演進發展
MySQL複製應用
MySQL 5.7 GA的複制新功能
In labs - Group Replication
MySQL Router
1
2
3
4
46
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL 5.7 GA裡的複製新功能總結
GTID 新功能
多線程複製(Multi-Threaded Slave)新功能
多源複製(Multiple Source Replication)
Slave可用性的改進 / Master 性能的提升
半同步複製(Semi-synchronous Replication)的新功能
其他功能…
3
2015年11月21日星期六
3.1
3.2
3.3
3.4
3.5
MySQL @ 2015 Oracle 技术嘉年华
3.6
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
参考信息
• 安装包
– http://dev.mysql.com
– http://labs.mysql.com
• 手册
– http://dev.mysql.com/doc/#manual
• 開發人員的博客(新聞, 技術信息,其他有趣的內容)
– http://mysqlhighavailability.com
2015年11月21日星期六 MySQL @ 2015 Oracle 技术嘉年华 48
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
馬楚成 - 首席技術顧問
Ivan Ma
2015-12-19
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
MySQL複製的演進和應用

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Linux Containers and Docker SHARE.ORG Seattle 2015
Linux Containers and Docker SHARE.ORG Seattle 2015Linux Containers and Docker SHARE.ORG Seattle 2015
Linux Containers and Docker SHARE.ORG Seattle 2015
 
MySQL Cluster performance best practices
MySQL Cluster performance best practicesMySQL Cluster performance best practices
MySQL Cluster performance best practices
 
MySQL InnoDB Cluster / ReplicaSet - Tutorial
MySQL InnoDB Cluster / ReplicaSet - TutorialMySQL InnoDB Cluster / ReplicaSet - Tutorial
MySQL InnoDB Cluster / ReplicaSet - Tutorial
 
TechEvent Exdata X7-2 POC with OVM
TechEvent Exdata X7-2 POC with OVMTechEvent Exdata X7-2 POC with OVM
TechEvent Exdata X7-2 POC with OVM
 
2018 Oracle Impact 발표자료: Oracle Enterprise AI
2018  Oracle Impact 발표자료: Oracle Enterprise AI2018  Oracle Impact 발표자료: Oracle Enterprise AI
2018 Oracle Impact 발표자료: Oracle Enterprise AI
 
MySQL InnoDB Cluster / ReplicaSet - Making Provisioning & Troubleshooting as ...
MySQL InnoDB Cluster / ReplicaSet - Making Provisioning & Troubleshooting as ...MySQL InnoDB Cluster / ReplicaSet - Making Provisioning & Troubleshooting as ...
MySQL InnoDB Cluster / ReplicaSet - Making Provisioning & Troubleshooting as ...
 
MySQL InnoDB Cluster: Management and Troubleshooting with MySQL Shell
MySQL InnoDB Cluster: Management and Troubleshooting with MySQL ShellMySQL InnoDB Cluster: Management and Troubleshooting with MySQL Shell
MySQL InnoDB Cluster: Management and Troubleshooting with MySQL Shell
 
13회 Oracle Developer Meetup 발표 자료: Oracle Cloud Data Interface(2019.07.20)
13회 Oracle Developer Meetup 발표 자료: Oracle Cloud Data Interface(2019.07.20)13회 Oracle Developer Meetup 발표 자료: Oracle Cloud Data Interface(2019.07.20)
13회 Oracle Developer Meetup 발표 자료: Oracle Cloud Data Interface(2019.07.20)
 
20191119 Cloud Native Java : GraalVM
20191119 Cloud Native Java : GraalVM20191119 Cloud Native Java : GraalVM
20191119 Cloud Native Java : GraalVM
 
Red Hat for IBM System z IBM Enterprise2014 Las Vegas
Red Hat for IBM System z IBM Enterprise2014 Las Vegas Red Hat for IBM System z IBM Enterprise2014 Las Vegas
Red Hat for IBM System z IBM Enterprise2014 Las Vegas
 
Introduction to MySQL Cluster
Introduction to MySQL ClusterIntroduction to MySQL Cluster
Introduction to MySQL Cluster
 
Achieving Network Deployment Flexibility with Mirantis OpenStack
Achieving Network Deployment Flexibility with Mirantis OpenStackAchieving Network Deployment Flexibility with Mirantis OpenStack
Achieving Network Deployment Flexibility with Mirantis OpenStack
 
MuleSoft Online Meetup a Guide to RTF application deployment - October 2020
MuleSoft Online Meetup   a Guide to RTF application deployment  - October 2020MuleSoft Online Meetup   a Guide to RTF application deployment  - October 2020
MuleSoft Online Meetup a Guide to RTF application deployment - October 2020
 
NoSQL and SQL - blending the best of both worlds
NoSQL and SQL - blending the best of both worldsNoSQL and SQL - blending the best of both worlds
NoSQL and SQL - blending the best of both worlds
 
11회 Oracle Developer Meetup 발표 자료: Oracle NoSQL (2019.05.18) oracle-nosql pu...
11회 Oracle Developer Meetup 발표 자료: Oracle NoSQL  (2019.05.18) oracle-nosql pu...11회 Oracle Developer Meetup 발표 자료: Oracle NoSQL  (2019.05.18) oracle-nosql pu...
11회 Oracle Developer Meetup 발표 자료: Oracle NoSQL (2019.05.18) oracle-nosql pu...
 
Hkosc group replication-lecture_lab07
Hkosc group replication-lecture_lab07Hkosc group replication-lecture_lab07
Hkosc group replication-lecture_lab07
 
MySQL Replication Performance in the Cloud
MySQL Replication Performance in the CloudMySQL Replication Performance in the Cloud
MySQL Replication Performance in the Cloud
 
MySQL Shell - A DevOps-engineer day with MySQL’s development and administrati...
MySQL Shell - A DevOps-engineer day with MySQL’s development and administrati...MySQL Shell - A DevOps-engineer day with MySQL’s development and administrati...
MySQL Shell - A DevOps-engineer day with MySQL’s development and administrati...
 
Plan with confidence: Route to a successful Do178c multicore certification
Plan with confidence: Route to a successful Do178c multicore certificationPlan with confidence: Route to a successful Do178c multicore certification
Plan with confidence: Route to a successful Do178c multicore certification
 
Poc exadata 2018
Poc exadata 2018Poc exadata 2018
Poc exadata 2018
 

Destaque

Aws lambda-beware-of-escapes
Aws lambda-beware-of-escapesAws lambda-beware-of-escapes
Aws lambda-beware-of-escapes
Michael H. Oshita
 
J2 Me Gaming Using Netbeans
J2 Me Gaming Using NetbeansJ2 Me Gaming Using Netbeans
J2 Me Gaming Using Netbeans
strongdevil
 
My sql cluster_taipei_event
My sql cluster_taipei_eventMy sql cluster_taipei_event
My sql cluster_taipei_event
Ivan Tu
 
My sql overview 2012 04-25 by scott chen - 30min - tw-1
My sql overview 2012 04-25 by scott chen - 30min - tw-1My sql overview 2012 04-25 by scott chen - 30min - tw-1
My sql overview 2012 04-25 by scott chen - 30min - tw-1
Ivan Tu
 
7 吕智超-ssd101
7 吕智超-ssd1017 吕智超-ssd101
7 吕智超-ssd101
Ivan Tu
 
4 葉金榮-my sql優化 - 20151219
4 葉金榮-my sql優化 - 201512194 葉金榮-my sql優化 - 20151219
4 葉金榮-my sql優化 - 20151219
Ivan Tu
 
Social networking presentation 5 20
Social networking presentation 5 20Social networking presentation 5 20
Social networking presentation 5 20
Victor Hurdle
 
BallCatchingRobot
BallCatchingRobotBallCatchingRobot
BallCatchingRobot
gauravbrd
 
Company Snapshot
Company SnapshotCompany Snapshot
Company Snapshot
waldroncw
 
My sql introduction for Bestcom
My sql introduction for BestcomMy sql introduction for Bestcom
My sql introduction for Bestcom
Ivan Tu
 
3 周彦偉-隨需而變 我所經歷的my sql架構變遷﹣周彥偉﹣acmug@2015.12台北
3 周彦偉-隨需而變 我所經歷的my sql架構變遷﹣周彥偉﹣acmug@2015.12台北3 周彦偉-隨需而變 我所經歷的my sql架構變遷﹣周彥偉﹣acmug@2015.12台北
3 周彦偉-隨需而變 我所經歷的my sql架構變遷﹣周彥偉﹣acmug@2015.12台北
Ivan Tu
 
My sql fabric webinar tw2
My sql fabric webinar tw2My sql fabric webinar tw2
My sql fabric webinar tw2
Ivan Tu
 

Destaque (20)

My Varnish Setup
My Varnish SetupMy Varnish Setup
My Varnish Setup
 
Aws lambda-beware-of-escapes
Aws lambda-beware-of-escapesAws lambda-beware-of-escapes
Aws lambda-beware-of-escapes
 
J2 Me Gaming Using Netbeans
J2 Me Gaming Using NetbeansJ2 Me Gaming Using Netbeans
J2 Me Gaming Using Netbeans
 
sinsai.infoの裏側(インフラ偏)
sinsai.infoの裏側(インフラ偏)sinsai.infoの裏側(インフラ偏)
sinsai.infoの裏側(インフラ偏)
 
Server Festa 2013 Autumn
Server Festa 2013 AutumnServer Festa 2013 Autumn
Server Festa 2013 Autumn
 
My sql cluster_taipei_event
My sql cluster_taipei_eventMy sql cluster_taipei_event
My sql cluster_taipei_event
 
A crise ambiental - Seminário Integrado - CCTA
A crise ambiental - Seminário Integrado - CCTAA crise ambiental - Seminário Integrado - CCTA
A crise ambiental - Seminário Integrado - CCTA
 
5 古雷my sql源碼與資料庫規範
5 古雷my sql源碼與資料庫規範5 古雷my sql源碼與資料庫規範
5 古雷my sql源碼與資料庫規範
 
Social networking present 5 20
Social networking present 5 20Social networking present 5 20
Social networking present 5 20
 
My sql overview 2012 04-25 by scott chen - 30min - tw-1
My sql overview 2012 04-25 by scott chen - 30min - tw-1My sql overview 2012 04-25 by scott chen - 30min - tw-1
My sql overview 2012 04-25 by scott chen - 30min - tw-1
 
8 彭立勳-double binlog方案
8 彭立勳-double binlog方案8 彭立勳-double binlog方案
8 彭立勳-double binlog方案
 
7 吕智超-ssd101
7 吕智超-ssd1017 吕智超-ssd101
7 吕智超-ssd101
 
1 my sql20151219-kaji_ivan
1 my sql20151219-kaji_ivan1 my sql20151219-kaji_ivan
1 my sql20151219-kaji_ivan
 
4 葉金榮-my sql優化 - 20151219
4 葉金榮-my sql優化 - 201512194 葉金榮-my sql優化 - 20151219
4 葉金榮-my sql優化 - 20151219
 
Social networking presentation 5 20
Social networking presentation 5 20Social networking presentation 5 20
Social networking presentation 5 20
 
BallCatchingRobot
BallCatchingRobotBallCatchingRobot
BallCatchingRobot
 
Company Snapshot
Company SnapshotCompany Snapshot
Company Snapshot
 
My sql introduction for Bestcom
My sql introduction for BestcomMy sql introduction for Bestcom
My sql introduction for Bestcom
 
3 周彦偉-隨需而變 我所經歷的my sql架構變遷﹣周彥偉﹣acmug@2015.12台北
3 周彦偉-隨需而變 我所經歷的my sql架構變遷﹣周彥偉﹣acmug@2015.12台北3 周彦偉-隨需而變 我所經歷的my sql架構變遷﹣周彥偉﹣acmug@2015.12台北
3 周彦偉-隨需而變 我所經歷的my sql架構變遷﹣周彥偉﹣acmug@2015.12台北
 
My sql fabric webinar tw2
My sql fabric webinar tw2My sql fabric webinar tw2
My sql fabric webinar tw2
 

Semelhante a 2 ivan ma-mysql複製的演進和應用-twn- v1

Oracle DB 12c 加速企业转型之十大功能
Oracle DB 12c 加速企业转型之十大功能Oracle DB 12c 加速企业转型之十大功能
Oracle DB 12c 加速企业转型之十大功能
Ethan M. Liu
 
Replication features, technologies and 3rd party Extinction
Replication features, technologies and 3rd party ExtinctionReplication features, technologies and 3rd party Extinction
Replication features, technologies and 3rd party Extinction
Ben Mildren
 

Semelhante a 2 ivan ma-mysql複製的演進和應用-twn- v1 (20)

Replication featuresinmysql5.7andbeyond osi-final
Replication featuresinmysql5.7andbeyond osi-finalReplication featuresinmysql5.7andbeyond osi-final
Replication featuresinmysql5.7andbeyond osi-final
 
MySQL 5.7: Focus on Replication
MySQL 5.7: Focus on ReplicationMySQL 5.7: Focus on Replication
MySQL 5.7: Focus on Replication
 
MySQL 5.7 Replication News
MySQL 5.7 Replication News MySQL 5.7 Replication News
MySQL 5.7 Replication News
 
MySQL Tech Tour 2015 - 5.7 Replication
MySQL Tech Tour 2015 - 5.7 ReplicationMySQL Tech Tour 2015 - 5.7 Replication
MySQL Tech Tour 2015 - 5.7 Replication
 
Using The Mysql Binary Log As A Change Stream
Using The Mysql Binary Log As A Change StreamUsing The Mysql Binary Log As A Change Stream
Using The Mysql Binary Log As A Change Stream
 
MySQL Manchester TT - Replication Features
MySQL Manchester TT  - Replication FeaturesMySQL Manchester TT  - Replication Features
MySQL Manchester TT - Replication Features
 
Oracle DB 12c 加速企业转型之十大功能
Oracle DB 12c 加速企业转型之十大功能Oracle DB 12c 加速企业转型之十大功能
Oracle DB 12c 加速企业转型之十大功能
 
MySQL Replication
MySQL ReplicationMySQL Replication
MySQL Replication
 
5 razões estratégicas para usar MySQL
5 razões estratégicas para usar MySQL5 razões estratégicas para usar MySQL
5 razões estratégicas para usar MySQL
 
MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...
MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...
MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...
 
MySQL Tech Tour 2015 - Alt Intro
MySQL Tech Tour 2015 - Alt IntroMySQL Tech Tour 2015 - Alt Intro
MySQL Tech Tour 2015 - Alt Intro
 
MySQL Manchester TT - Performance Tuning
MySQL Manchester TT  - Performance TuningMySQL Manchester TT  - Performance Tuning
MySQL Manchester TT - Performance Tuning
 
Oracle GoldenGate Performance Tuning
Oracle GoldenGate Performance TuningOracle GoldenGate Performance Tuning
Oracle GoldenGate Performance Tuning
 
MySQL user camp march 11th 2016
MySQL user camp march 11th 2016MySQL user camp march 11th 2016
MySQL user camp march 11th 2016
 
Replication features, technologies and 3rd party Extinction
Replication features, technologies and 3rd party ExtinctionReplication features, technologies and 3rd party Extinction
Replication features, technologies and 3rd party Extinction
 
High-Availability using MySQL Fabric
High-Availability using MySQL FabricHigh-Availability using MySQL Fabric
High-Availability using MySQL Fabric
 
Hit Refresh with Oracle GoldenGate Microservices
Hit Refresh with Oracle GoldenGate MicroservicesHit Refresh with Oracle GoldenGate Microservices
Hit Refresh with Oracle GoldenGate Microservices
 
Oracle goldegate microservice
Oracle goldegate microserviceOracle goldegate microservice
Oracle goldegate microservice
 
MySQL High Availability Solutions - Feb 2015 webinar
MySQL High Availability Solutions - Feb 2015 webinarMySQL High Availability Solutions - Feb 2015 webinar
MySQL High Availability Solutions - Feb 2015 webinar
 
MySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated EnvironmentMySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated Environment
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

2 ivan ma-mysql複製的演進和應用-twn- v1

  • 1. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 馬楚成 - 首席技術顧問 Ivan Ma 2015-12-19 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. MySQL複製的演進和應用
  • 2. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 2
  • 3. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 目录 MySQL複製基礎 與 演進發展 MySQL複製應用 MySQL 5.7 GA的複製新功能 In labs - Group Replication和MySQL集群管理 1 2 3 4 3
  • 4. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | MySQL複製基礎 與 演進發展 1
  • 5. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | • 3.23 – One-way Replication • 4.1 – Support was added for replication over SSL connections • 5.0/5.1 – Row-based Replication • 5.5 – Semi-Sync Replication – Replication Heartbeat – Per server Replication Filter • 5.6 – GTID – Crash Safe Slave and Binlog – Binlog Group Commit – Optimized Row Based Replication – Multi-threaded Slave (per Database) – Time-delayed Replication – Utility for Failover and Admin • 5.7 – What’s New 复制新功能 MySQL 復製演進發展 5 2015年10月26日MySQL 5.7.9 GA啦
  • 6. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 複製基礎 :複製的框架 Insert... Insert... B binary log Insert... relay log Insert... A binary log Client Dump thread IO thread SQL Threads Receiver Meta-data Update Applier Meta-data Update Network 6
  • 7. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 複製基礎 :複製的框架 Insert... Insert... B binary log Insert... relay log Insert... A binary log Client Sender thread Receiver thread Applier Threads Receiver Meta-data Update Applier Meta-data Update Network 7
  • 8. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 複製基礎 :複製的框架 • Binary Log – 基於文件的邏輯日誌,記錄了Master上數據的變化。 • 語句格式(Statement),行格式(Row),混合模式(Mixed)。 – 每個事務會被記錄為一組Binlog Events. – Control events: Rotate, Format Description, Gtid, ... Layout of a Binary Log File GTID ...E1 E2 COMMIT ...E1 E2 COMMIT 8 BEGIN GTID BEGIN...
  • 9. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | M S write clients read clients 讀性能的擴展(Read scale-out) 複製基礎:複製的應用 9 S S S M read clients write clients More reads? More slaves!
  • 10. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | C B A C B ACrash Uh Oh! C B A B is the new master Whew! Redundancy: 如果主服務器宕機,可以用一個從服務器來做新的主服務器。 複製基礎:複製的應用 10
  • 11. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 使用不同存储引擎(Storage Engine) 複製基礎:複製的應用 11 https://dev.mysql.com/doc/refman/5.6/en/replication-solutions-diffengines.html SE=ndb SE=InnoDB Analytic Replication SE=ndb SE=ndb SE=ndb ndbd ndbd ndbd ndbd
  • 12. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | M write clients 在線備份和做報表(On-line Backup and Reporting) 複製基礎:複製的應用 12 S 報表應用 海量信息查詢 S 在線備份 S [ BI ] 商業智能應用
  • 13. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | CB BA AC Image from www.ginkgomaps.com 複製基礎:複製的應用 遠距離數據分發 13
  • 14. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | MySQL Fabric 通过数据分片来提升MySQL的性能... 那麼寫性能的擴展(write scale-out)呢? 14 S M M 多源複製 M M 數據分片生成 MySQL 5.7 新功能
  • 15. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | MySQL 5.7 GA裡的複製新功能 http://mysqlhighavailability.com/replication-in-mysql-5-7-ga/ 3
  • 16. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | MySQL 5.7 GA裡的複製新功能 GTID 新功能 多線程複製(Multi-Threaded Slave)新功能 多源複製(Multiple Source Replication) Slave可用性的改進 / Master 性能的提升 半同步複製(Semi-synchronous Replication)的新功能 其他功能… 3 2015年11月21日星期六 3.1 3.2 3.3 3.4 3.5 MySQL @ 2015 Oracle 技术嘉年华 3.6
  • 17. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 在線配置-GTID功能 • 挑戰 – 多台服務器的複製拓扑,5.6上-以GTID切換 – 要重啟服務器!!。 • 在線配置 – 整個配置過程,不需要重启MySQL服务器 – 不需要改變複製拓撲結構 – 簡化了的配置過程 GTID —Non-GTID 兼容 • GTID_MODE=OFF_PERMISSIVE 启用GTID • GTID_MODE=ON_PERMISSIVE 等待所有服務器生 成GTID • 等等等等等 只接受GTID • GTID_MODE=ON X 完整配置過程: http://dev.mysql.com/doc/refman/5.7/en/replication-mode- change-online-enable-gtids.html
  • 18. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 存儲GTID到系統表中 • Slaves可以在不開啟binlog的條件下,使用GTID功能 – 有些Slave服務器永遠不會被當maser來使用,就不用開啟binlog.但這些服務器仍然 可以使用GTID及AUTO_POSITION來簡化管理。 • 保障意外刪除binlog 應用場景 18 在系統數據庫MySQL的,加了一張表gtid_executed TABLE gtid_executed( source_uuid CHAR(36) NOT NULL, interval_start BIGINT NOT NULL, interval_end BIGINT NOT NULL, PRIMARY KEY(source_uuid, interval_start) );
  • 19. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 19 mysql 事 的数量mysql> SET GLOBAL gtid_executed_compression_period= N;(N – 事务的数量)
  • 20. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 存储GTID到系统表中 • 当binlog启用时 – 存储GTID到binlog. – 只在binlog文件切换时,将该binlog文件中包含的gtid集合写入表中 – 性能比每事务写表高 • 当binlog未启用时 – 每个事务提交时,存储GTID到表中 • 始终crash-safe. 实现机制 20
  • 21. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | MySQL 5.7 GA裡的複製新功能 GTID 新功能 多線程複製(Multi-Threaded Slave)新功能 多源複製(Multiple Source Replication) Slave可用性的改進 / Master 性能的提升 半同步複製(Semi-synchronous Replication)的新功能 其他功能… 3 2015年11月21日星期六 3.1 3.2 3.3 3.4 3.5 MySQL @ 2015 Oracle 技术嘉年华 3.6
  • 22. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 多線程的並發複製 • 支持語句(statement format)和行(row format)格式的binlog. • 並發策略通過系統變量控制: – logical_clock -採用基於鎖的並發策略 – database - 基於數據庫的並發策略(在MySQL-5.6上的並發機制) mysqlmysql> SET slave_parallel_type= [logical_clock|database] 22
  • 23. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 多線程的並發複製 (MTS Applier) 2015年11月21日星期六 Single Threaded Apply 8 Threads Applier 24 Threads Applier 48 Threads Applier 96 Threads Applier 0% 50% 100% 150% 200% 250% Fast and Scalable Multi-threaded Replication Applier (statement-based replication, durable settings, SSD storage) Slaveapplytime (SysbenchRWonthemasterwith96threads=100%) 10X MySQL @ 2015 Oracle 技术嘉年华 23 slave_parallel_type= LOGICAL_CLOCK
  • 24. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 多線程的並發複製 (MTS Applier) T1 T2 T3 Time Commit 完成 事務獲取了所有的鎖 Master上的並發執行過程 Execution Commit T1 和T2可並發 24 • Master上的並發信息,以邏輯 時間(Logical clock)的方式記入 gtid_log_event中。 • 具有重疊COMMIT持續時間,可 並行執行的交易 在Slave上, T1和T2並發執行; T3在T1完成後, 開始執行. T2和T3可並發 slave_parallel_type= LOGICAL_CLOCK
  • 25. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | MySQL 5.7 GA裡的複製新功能 GTID 新功能 多線程複製(Multi-Threaded Slave)新功能 多源複製(Multiple Source Replication) Slave可用性的改進 / Master 性能的提升 半同步複製(Semi-synchronous Replication)的新功能 其他功能… 3 2015年11月21日星期六 3.1 3.2 3.3 3.4 3.5 MySQL @ 2015 Oracle 技术嘉年华 3.6
  • 26. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 多源複製 Slave M M Slave可以有多個複制源 M M 聚合數據到一台數據庫服務器上的場景: • 集成備份; • 複合數據分析方面的用途; • 分片數據的合併 27
  • 27. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 多源複製 28 Insert... B binary log Insert... relay log Master 1 A Receiver thread Applier Threads Master info Relay info Network Named Channel “Channel_1” Insert... relay log Master 2 C Master info Relay info Network Named Channel “Channel_2” Slave Named Channel
  • 28. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 29 replication_connection_status replication_applier_status 改進的複制監控信息
  • 29. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | MySQL 5.7 GA裡的複製新功能 GTID 新功能 多線程複製(Multi-Threaded Slave)新功能 多源複製(Multiple Source Replication) Slave可用性的改進 / Master 性能的提升 半同步複製(Semi-synchronous Replication)的新功能 其他功能… 3 2015年11月21日星期六 3.1 3.2 3.3 3.4 3.5 MySQL @ 2015 Oracle 技术嘉年华 3.6
  • 30. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Applier 在線配置Receiver/Applier • 切換Master時,Applier線程仍然在運行: • 改變applier參數時,receiver線程仍然在運行: mysql mysql mysql> STOP SLAVE IO_THREAD; mysql> CHANGE MASTER TO MASTER_HOST='master2', …; mysql> START SLAVE IO_THREAD; mysql> STOP SLAVE SQL_THREAD; mysql mysql> STOP SLAVE SQL_THREAD; mysql> CHANGE MASTER TO MASTER_DELAY=3600, …; mysql> START SLAVE SQL_THREAD; 31 C B A B成為新 Master Crash 切换数据源从A 到 B,无需停止applier threads.
  • 31. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 在線變更Replication Filter參數 • 動態變更Replication Filters – 不再需要重啟MySQL server – 支持所有的Filter選項 – 支持各種字符集 mysqlmysql> CHANGE REPLICATION FILTER REPLICATE_DO_DB= (db1, db2) 32
  • 32. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 並發讀寫binlog • sender 線程在讀binlog的同時,用戶線程並發的記錄binlog日誌. – Sender線程和用戶線程在讀寫binlog時,不再互相阻塞對方 – Sender線程和用戶線程都有更好的性能 Sender Thread Reads Binary Log User Thread Writes to Binary Log Sender Thread Reads Binary Log User Thread Writes to Binary Log pre 5.7.2 5.7.2+ 33
  • 33. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | MySQL 5.7 GA裡的複製新功能 GTID 新功能 多線程複製(Multi-Threaded Slave)新功能 多源複製(Multiple Source Replication) Slave可用性的改進 / Master 性能的提升 半同步複製(Semi-synchronous Replication)的新功能 其他功能… 3 2015年11月21日星期六 3.1 3.2 3.3 3.4 3.5 MySQL @ 2015 Oracle 技术嘉年华 3.6
  • 34. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 無數據丟失的半同步複製 Insert... Insert... B binary log Insert... relay log Insert... A binary log Client Sender thread Receiver thread Applier Threads Receiver Meta-data Update Applier Meta-data Update Network 35 1 2 3 4 - ACK 5
  • 35. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 無數據丟失的半同步複製 Master Slave T1: INSERT INTO t1 VALUES (1000) ACK Time T2: SELECT * FROM t1; T1 (1000) execute prepare binlog relay log commit execute 36 mysqlmysql> SET rpl_semi_sync_master_wait_point= [AFTER_SYNC|AFTER_COMMIT] T2 看到 t1(1000) MySQL 5.6上: Master在commit後,才等待Slave的應答
  • 36. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 無數據丟失的半同步複製 Master Slave T1: INSERT INTO t1 VALUES (1000) ACK Time T2: SELECT * FROM t1; empty set execute prepare binlog relay log commitexecute 37 mysqlmysql> SET rpl_semi_sync_master_wait_point= [AFTER_SYNC|AFTER_COMMIT] T2 看不到 t1(1000) Master 在收到slave的應答後才Commit事務 因此在確認事務複製到Slave上之前,並發的事務看不到當前事務的數據.a
  • 37. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | • 單工通信方式,事務發送完畢後,要接收和處理應答。處理完答後才能 繼續發送下事務的Events。 MySQL-5.6 半同步複製更快 – ACK接收線程 Sender Receiver Time Send Trx Receive ACK 38 Report ACK Send ACK Receive Trx Send Trx Receive Trx Send ACK Receive ACK Report ACK
  • 38. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | MySQL-5.7 • 新加的應答ACK接收線程。 • 變成雙工模式。發送和接收互不影響。 半同步複製更快 – ACK接收線程 Sender Receiver ACK Time 39 ACK ACK Receiver Send Trx Send Trx Send Trx Send ACK Receive Trx Send ACK Receive Trx Receive ACK Report ACK Receive ACK Report ACK
  • 39. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 半同步複製– 等待多個Slave的應答 • Master 接收到N個slave的應答後,才commit 事務. • 用戶可以設置應答Slave的數量: mysqlmysql> SET GLOBAL rpl_semi_sync_master_wait_for_slave_count= N 40
  • 40. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 半同步複製– 等待多個Slave的應答 • Master 接收到N個slave的應答後,才commit 事務. • 用戶可以設置應答Slave的數量: mysqlmysql> SET GLOBAL rpl_semi_sync_master_wait_for_slave_count= N Master Slave 2 T1: Binlog ACK Slave 1 ACK T1: COMMIT succeeds mysql> SET GLOBAL rpl_semi_sync_master_wait_for_slave_count= 2 Slave 3 Time relay log relay log relay log 41 ACK
  • 41. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | MySQL 5.7 GA裡的複製新功能 GTID 新功能 多線程複製(Multi-Threaded Slave)新功能 多源複製(Multiple Source Replication) Slave可用性的改進 / Master 性能的提升 半同步複製(Semi-synchronous Replication)的新功能 其他功能… 3 2015年11月21日星期六 3.1 3.2 3.3 3.4 3.5 MySQL @ 2015 Oracle 技术嘉年华 3.6
  • 42. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication 2015年11月21日星期六 M M M APP • 虛擬的同步複製 • Shared-nothing state machine replication. • 多master同時更新 • 沒有單點故障,不需要fail-over • 自我管理 – 自動化創建同步新 節點和移除節點。 – 自動化故障檢測和節點管理。 MySQL @ 2015 Oracle 技术嘉年华 43 Write Write Write Replication Group
  • 43. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication的實現 2015年11月21日星期六 M M M APP Replication Group • 是一個MySQL plugin • 基於row format 和InnoDB – 用PK來做衝突檢測 • 基於GTID • 可通過performance schema監控. • MySQL-5.7.9 加入了XCom來替代corosync – 更加容易編譯、安裝和使用。 – 支持更多操作系統: Linux, Solaris, FreeBSD, OSX and Windows MySQL @ 2015 Oracle 技术嘉年华 44 Write Write Write Group Replication
  • 44. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | MySQL Router • 基於Connection的路由和負載均衡 • 可對多台服務器作分別路由。 • 平滑的故障切換(fail-over) • 对APP是透明的 – 不需要升級connectors. – 沒有connector的語言限制 • 高性能 • 簡單易用 2015年11月21日星期六 MySQL @ 2015 Oracle 技术嘉年华 NEW 45 GA Group Replication App MySQL Router connectors M M M Virtual MySQL Server
  • 45. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 总结 MySQL複製基礎 與 演進發展 MySQL複製應用 MySQL 5.7 GA的複制新功能 In labs - Group Replication MySQL Router 1 2 3 4 46
  • 46. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | MySQL 5.7 GA裡的複製新功能總結 GTID 新功能 多線程複製(Multi-Threaded Slave)新功能 多源複製(Multiple Source Replication) Slave可用性的改進 / Master 性能的提升 半同步複製(Semi-synchronous Replication)的新功能 其他功能… 3 2015年11月21日星期六 3.1 3.2 3.3 3.4 3.5 MySQL @ 2015 Oracle 技术嘉年华 3.6
  • 47. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 参考信息 • 安装包 – http://dev.mysql.com – http://labs.mysql.com • 手册 – http://dev.mysql.com/doc/#manual • 開發人員的博客(新聞, 技術信息,其他有趣的內容) – http://mysqlhighavailability.com 2015年11月21日星期六 MySQL @ 2015 Oracle 技术嘉年华 48
  • 48.
  • 49. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 馬楚成 - 首席技術顧問 Ivan Ma 2015-12-19 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. MySQL複製的演進和應用