Post on 05-Dec-2014
description
MySQL Cluster
Priyanka Sangam(priyanka.sangam@oracle.com)
Insert Picture Here
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.
Agenda
• Introduction to MySQL Cluster• Working with Cluster tables• Cluster Nodes• Architecture• Auto-sharding• Failover
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
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
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
Architecture
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 (mysql5.5.36 ndb7.2.16, Nodegroup: 0, *)id=4 @127.0.0.1 (mysql5.5.36 ndb7.2.16, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)id=1 @127.0.0.1 (mysql5.5.36 ndb7.2.16)
[mysqld(API)] 4 node(s)id=3 @127.0.0.1 (mysql5.5.36 ndb7.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)
Auto-sharding – partitioning a table
Auto-sharding – fragments
Auto-sharding - nodegroups
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
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