MySQL Cluster Tutorial
MySQL Cluster Tutorial
MySQL Cluster Tutorial
• Max Mether
– Trainer and Consultant at MySQL from 2001
– Curriculum Manager at MySQL
– Training Manager at SkySQL from 2010
• Johan Andersson
– Cluster Practice Manager at MySQL from 2003
– Consultant at Severalnines from 2010
• Joffrey Michaie
– Cluster Consultant at MySQL from 2009
– Consultant at SkySQL from 2010
• In-memory storage
– Some data can be stored on disk
– Checkpointing to disk for durability
• Two types of indexes
– Ordered T-trees
– Unique hash indexes
• Online operations
– Add node groups
– Software upgrade
– Some table alterations
Node 3 Node 4
Node 3 Node 4
Node 3 Node 4
Primary Replica
Node 3 Node 4
Secondary Replica
11.04.2011 SkySQL Ab 2011 Confidential
Partitioning – 4 Data Nodes
Table
Node 6 Node 5
Node 6 Node 5
Node 6 Node 5
Node 6 Node 5
SQL Node
Transaction
request
Node 3 Node 4
Node 3 Node 4
Node 3 Node 4
Node 3 Node 4
Node 3 Node 4
Node 3 Node 4
Node 3 Node 4
Node 3 Node 4
Node 3 Node 4
1. Take a backup
– Use the START BACKUP command
2. Start a clean cluster with no data
3. Use the backup to restore the data
– Use the ndb_restore utility
Clients
Load Balancer(s)
Redundant switches
SQL+Mgm SQL+Mgm
+AppServer +AppServer
+WebServer... +WebServer...
Bonding
• CPU: 2 – 16 cores
• RAM: Not so important – 4GB enough
(depends on connections and buffers)
• Disks: Used mainly for logging
– Binary log needed for replication
LCP UNDOLOG
REDOLOG (REDO LOG)
UNDOLOG
TABLESPACE 1
TABLESPACE
TABLESPACE 2
2 x SAS 10KRPM (preferably)
(REDO LOG / UNDO LOG)
LCP
– MaxNoOfExecutionThreads<=#cores
• Contention can occur → unexpected behaviour
– RedoBuffer=32-64M
• If you need to set it higher your disks are too slow
– FragmentLogFileSize=256M
– NoOfFragmentLogFiles=
6 x DataMemory (in MB) / (4x 256MB)
• Most common issue – redo log too small
– Try the configurator:
www.severalnines.com/config
11.04.2011 SkySQL Ab 2011 Confidential 52
Application - Primary Keys
App layer
SQL layer
Admin layer
• Mandatory to monitor
– CPU/Network/Memory usage
– Disk capacity (I/O) usage
– Network latency between nodes
– Node status ...
– Used Index/Data Memory
• www.severalnines.com/cmon- monitors data
nodes and MySQL servers