14
MySQL Cluster Priyanka Sangam ([email protected]) Insert Picture Here

MySQL User Camp: MySQL Cluster

Embed Size (px)

DESCRIPTION

Priyanka, a MySQL cluster developer, presented MySQL cluster in the MySQL User camp. The slide deck contains an introduction to the cluster module- the architecture, auto-sharding, failover etc in the cluster module.

Citation preview

Page 1: MySQL User Camp: MySQL Cluster

MySQL Cluster

Priyanka Sangam([email protected])

Insert Picture Here

Page 2: MySQL User Camp: MySQL Cluster

Safe Harbour 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.

Page 3: MySQL User Camp: MySQL Cluster

Agenda

• Introduction to MySQL Cluster• Working with Cluster tables• Cluster Nodes• Architecture• Auto-sharding• Failover

Page 4: MySQL User Camp: MySQL Cluster

Introduction to MySQL Cluster

• Distributed transactional database• In-memory storage• Auto-sharding• Shared-nothing architecture• Automatic failover and recovery• Runs on commodity hardware• SQL + NoSQL interfaces

Page 5: MySQL User Camp: MySQL Cluster

mysql> create table t1(id int primary key, value varchar(10))engine=ndb;Query OK, 0 rows affected (0.80 sec)

mysql> show create table t1;+­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+| Table | Create Table                              |                                    +­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+| t1    | CREATE TABLE `t1` (  `id` int(11) NOT NULL,  `value` varchar(10) DEFAULT NULL,  PRIMARY KEY (`id`)) ENGINE=ndbcluster DEFAULT CHARSET=latin1          |+­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+1 row in set (0.00 sec)

mysql> insert into t1 values(1, "one"), (2,"two");Query OK, 2 rows affected (0.00 sec)Records: 2  Duplicates: 0  Warnings: 0

mysql> select * from t1;+­­­­+­­­­­­­+| id | value |+­­­­+­­­­­­­+|  1 | one   ||  2 | two   |+­­­­+­­­­­­­+2 rows in set (0.00 sec)

Working with Cluster Tables

Page 6: MySQL User Camp: MySQL Cluster

Cluster Nodes•Data Nodes

•Store cluster data•Data partitioned + replicated across many data nodes•ndbd (single-threaded) or ndbmtd (multi-threaded)

•SQL Nodes•Access cluster data by querying data nodes•SQL + NoSQL•mysqld

•Management Nodes•Manage other nodes•Config, startup, shutdown, backup etc.•ndb_mgmd

Page 7: MySQL User Camp: MySQL Cluster
Page 8: MySQL User Camp: MySQL Cluster

Architecture

Page 9: MySQL User Camp: MySQL Cluster

ndb_mgmmysql@host1:~$ ndb_mgm ­e showConnected to Management Server at: localhost:1186Cluster Configuration­­­­­­­­­­­­­­­­­­­­­[ndbd(NDB)]     2 node(s)id=2    @127.0.0.1  (mysql­5.5.36 ndb­7.2.16, Nodegroup: 0, *)id=4    @127.0.0.1  (mysql­5.5.36 ndb­7.2.16, Nodegroup: 0)

[ndb_mgmd(MGM)] 1 node(s)id=1    @127.0.0.1  (mysql­5.5.36 ndb­7.2.16)

[mysqld(API)]   4 node(s)id=3    @127.0.0.1  (mysql­5.5.36 ndb­7.2.16)id=5 (not connected, accepting connect from any host)id=7 (not connected, accepting connect from any host)id=9 (not connected, accepting connect from any host)

Page 10: MySQL User Camp: MySQL Cluster

Auto-sharding – partitioning a table

Page 11: MySQL User Camp: MySQL Cluster

Auto-sharding – fragments

Page 12: MySQL User Camp: MySQL Cluster

Auto-sharding - nodegroups

Page 13: MySQL User Camp: MySQL Cluster

Failover• << Initial state >>

• Node1: Primary F1, Secondary F2, Nodegroup 0• Node2: Primary F2, Secondary F1, Nodegroup 0

• Node3: Primary F3, Secondary F4, Nodegroup 1• Node4: Primary F4, Secondary F3, Nodegroup 1

• << Node1 fails >>

• Node2: Primary F1, Primary F2

• Node3: Primary F3, Secondary F4, Nodegroup 1

• Node4: Primary F4, Secondary F3, Nodegroup 1

• << Node2 fails >>

• Cluster failure due to missing nodegroup

• Node3. Node4 shut down

Page 14: MySQL User Camp: MySQL Cluster

References

• Introduction to MySQL Cluster:

http://www.slideshare.net/andrewjamesmorgan/mysql-cluster-introduction

• Cluster Reference Manual: http://dev.mysql.com/doc/mysql-cluster-excerpt/5.1/en/index.html