Date post: | 26-Jan-2015 |
Category: |
Technology |
Upload: | yin-gong |
View: | 2,550 times |
Download: | 1 times |
Agenda Brief Introduction High Availability and Scalability MySQL Replication MySQL Cluster DRBD Resources
MySQL Brief introduction
• High performance
• Reliable
• Easy To Use
MySQL Server Architecture
SQL Layer
Storage Engine Layer
High Availability
• 7 * 24 * 365 online
• Single point of failure
• Auto Recover
Scalability• Scalability refers to the ability to spread the load of your application queries across multiple MySQL servers.
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
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
Scalability - Scale out
•Database Scale out How?
Scalability - Principle•Principle :
Minimize Transaction RelevanceData Consistency, BASE modelHA 、 Data Security. Data Redundancy.
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
MySQL Replication - Process•Master • I/O thread• Binary Log (mysqld log-bin)•Slave • I/O thread• SQL thread• Relay Log• Master-info
MySQL Replication - LevelStatement Level
Row Level (support from 5.1.5)
Mixed Level (support from 5.1.8,default)
MySQL Replication - Architecture•Master-slaves
Master
salve
repl
W
R
client client client
MySQL Replication - Architecture•Master – Master
repl
R/W
client client client
MySQL Replication - Architecture•Master-Slaves-Slaves : Cascading replication
Master
salve
repl
salve
salve
repl
client client client
W
R
MySQL Replication - Architecture• Master-Master-Slaves
Master
salve
replMasterrepl
client client client
W
R
MySQL Replication - Architecture
MySQL Replication - ArchitectureEbay
MySQL Replication - ArchitectureFacebook
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
Sharding
Application System How to integrate all of data source?
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
Sharding• Problems :
Distribute transaction question
Join cross multi nodes ( supported by federated storage engine )
Merge sort paging cross multi nodes
MySQL Cluster
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• •
Shared-Nothing
MySQL Cluster
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
•
MySQL Cluster
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.
MySQL Cluster
MySQL cluster replicationreplicate asynchronously
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.
.
MySQL HA
Resources•HA: Heartbeat•Load balance : F5/NetScalar/LVS/HAProxy•Monitor : Nagios/cacti•http://highscalability.com/