+ All Categories
Home > Documents > MySql High Availability And Scalability

MySql High Availability And Scalability

Date post: 14-Oct-2014
Category:
Upload: yin-gong
View: 136 times
Download: 3 times
Share this document with a friend
Popular Tags:
36
MySql High Availability And Scalability [email protected] @gongyin
Transcript
Page 1: MySql High Availability And Scalability

MySql High Availability And Scalability

[email protected]@gongyin

Page 2: MySql High Availability And Scalability

Agenda Brief Introduction High Availability and Scalability MySQL Replication MySQL Cluster DRBD Resources

Page 3: MySql High Availability And Scalability

MySQL Brief introduction

• High performance

• Reliable

• Easy To Use

Page 4: MySql High Availability And Scalability

MySQL Server Architecture

SQL Layer

Storage Engine Layer

Page 5: MySql High Availability And Scalability

High Availability

• 7 * 24 * 365 online

• Single point of failure

• Auto Recover

Page 6: MySql High Availability And Scalability

Scalability• Scalability refers to the ability to spread the load of your application queries across multiple MySQL servers.

Page 7: MySql High Availability And Scalability

Scalability - Scale up•Scale vertically - add resources to a single node in a system, typically involving the addition of CPUs or memory to a single computer.

•Pros : Simple Maintenance Centralization Data, Simple application architecture

•Cons : Expensive Device Limitation of processing, Prone to bottleneck Single point of failure

Page 8: MySql High Availability And Scalability

Scalability - Scale out•Scale horizontal - add more nodes to a system, such as adding a new computer to a distributed software application.

•Pros : Bottleneck is not easy occur Low cost device. Little impact on single point of failure, HA

•Cons : More nodes, more complex Difficult to maintain

Page 9: MySql High Availability And Scalability

Scalability - Scale out

•Database Scale out How?

Page 10: MySql High Availability And Scalability

Scalability - Principle•Principle :

Minimize Transaction RelevanceData Consistency, BASE modelHA 、 Data Security. Data Redundancy.

Page 11: MySql High Availability And Scalability

MySQL Replication

Features : Across different platforms Asynchronous One master to any number of slaves.(separate R/W) Data can only be written to the master No guarantee that data on master and slaves will be consistent at a given point in time.

Full replication of data

Page 12: MySql High Availability And Scalability

MySQL Replication - Process•Master • I/O thread• Binary Log (mysqld log-bin)•Slave • I/O thread• SQL thread• Relay Log• Master-info

Page 13: MySql High Availability And Scalability

MySQL Replication - LevelStatement Level

Row Level (support from 5.1.5)

Mixed Level (support from 5.1.8,default)

Page 14: MySql High Availability And Scalability

MySQL Replication - Architecture•Master-slaves

Master

salve

repl

W

R

client client client

Page 15: MySql High Availability And Scalability

MySQL Replication - Architecture•Master – Master

repl

R/W

client client client

Page 16: MySql High Availability And Scalability

MySQL Replication - Architecture•Master-Slaves-Slaves : Cascading replication

Master

salve

repl

salve

salve

repl

client client client

W

R

Page 17: MySql High Availability And Scalability

MySQL Replication - Architecture• Master-Master-Slaves

Master

salve

replMasterrepl

client client client

W

R

Page 18: MySql High Availability And Scalability

MySQL Replication - Architecture

Page 19: MySql High Availability And Scalability

MySQL Replication - ArchitectureEbay

Page 20: MySql High Availability And Scalability

MySQL Replication - ArchitectureFacebook

Page 21: MySql High Availability And Scalability

ShardingVertical Sharding• according to function, different table locate on different DB

Horizontal Sharding• data on same table locate on different DB

Mixed Sharding

•Pros and Cons

Page 22: MySql High Availability And Scalability

Sharding

Application System How to integrate all of data source?

Page 23: MySql High Availability And Scalability

ShardingEach application system maintain its required data sources Unified management by middle layer• Self-developed• MySQL Proxy ( connection route 、 load balance 、 HA 、

query filter 、 query modify )• Amoeba , based on java• HiveDB

Page 24: MySql High Availability And Scalability

Sharding• Problems :

Distribute transaction question

Join cross multi nodes ( supported by federated storage engine )

Merge sort paging cross multi nodes

Page 25: MySql High Availability And Scalability

MySQL Cluster

Page 26: MySql High Availability And Scalability

MySQL Cluster Real-time transactional relational “Shared-nothing" distributed architecture No single point of failure, two replicas is needed Synchronous and two-phase commit R/W on any nodes Automatic failover between nodes• •

Page 27: MySql High Availability And Scalability

Shared-Nothing

Page 28: MySql High Availability And Scalability

MySQL Cluster

Page 29: MySql High Availability And Scalability

MySQL Cluster•Three parts:Manage nodeSQL node, startup with ndbclusterNDB data node• Data storage and management of both in-memory and disk-based data• Automatic and user defined partitioning of data• Synchronous replication of data between data nodes• Transactions and data retrieval• Automatic fail over• Resynchronization after failure

Page 30: MySql High Availability And Scalability

MySQL Cluster

Page 31: MySql High Availability And Scalability

MySQL ClusterCluster Nodes Node Groups[number_of_node_groups] = number_of_data_nodes / NumberOfReplicas ReplicasThe number of replicas is equal to the number of nodes per node groupPartitionsThis is a portion of the data stored by the cluster

MySQL Cluster normally partitions NDBCLUSTER tables automatically Horizontal Data Partitioning. Based on hash algorithm based on the primary key on the table.

Page 32: MySql High Availability And Scalability

MySQL Cluster

Page 33: MySql High Availability And Scalability

MySQL cluster replicationreplicate asynchronously

Page 34: MySql High Availability And Scalability

DRBDDRBD (Distributed Replicated Block Device) is a solution from Linbit supported only on Linux. DRBD creates a virtual block device (which is associated with an underlying physical block device) that can be replicated from the primary server to a secondary server.

.

Page 35: MySql High Availability And Scalability

MySQL HA

Page 36: MySql High Availability And Scalability

Resources•HA: Heartbeat•Load balance : F5/NetScalar/LVS/HAProxy•Monitor : Nagios/cacti•http://highscalability.com/


Recommended