Professional Documents
Culture Documents
com
Who Am I?
What is a Cluster?
SQL Request
Response
www.osscube.com
SQL Request
Partitionin
MySQL Client
g
Response Replicatio
n
Message
Response
Data Nodes
SQL Node (MySQL server)
www.osscube.com
Components of MySQL
Cluster
Various Nodes
API Data
Node Node
Application
Management
Node
(Data Nodes)
Organization
Partition
Partitioning
Horizontal
Partitioning
Vertical
Partitioning
Fragments
Node Groups
Split Brain
I have full
Servers can I have full
responsibility
not see responsibility
of the cluster
each other of the cluster
Arbitration
NG
1
Network
Split
First Node to ask will continue while the other will
be shut down
NG Network
1 Split/
Shutdown
N
G
Arbitrator Issues
Arbitrator Issues
Normal Operation
I a ive
m
Al
Al m
Ia
ive
l ive
A m
Al m
Ia
Ia
MySQL Cluster Tutorial, OSSPAC 09 ive
Singapore, © OSSCube
www.osscube.com
Missed Heartbeats
I a ive
m
Al
Alive
I am
Al m
Ia
MySQL Cluster Tutorial, OSSPAC 09 ive
Singapore, © OSSCube
www.osscube.com
Synchronous
Commit Commit
Message Message
Response Response
Message Message
Transaction Transaction
Successful Successful
Commit Commit
Transaction Transaction
Transaction Transaction
Failed Successful
Rollback Rollback
Transaction Transaction
Management Node
Data Nodes
• my.cnf# example additions to
my.cnf for MySQL Cluster
• [ndbd]
connect
string=ndb_mgmd.MySQL.com
SQL Nodes
• my.cnf
• # example additions to my.cnf for
MySQL Cluster
# (will work on all versions)
• # enable ndbcluster storage engine,
and provide connectstring for
management
• # server host to the default port
1186
• [MySQLd]
Ndbcluster
ndbconnectstring=ndb_mgmd.MySQL.com
:1186
MySQL Cluster Tutorial, OSSPAC 09
Singapore, © OSSCube
www.osscube.com
Config.ini Parameters
General Parameters
– Id
– Hostname
•Transaction Handling
Parameters
•TransactionInactiveTimeout
•TransactionDeadlockDetection
Timeout
•Utility Programs
www.osscube.com
• In-Memory Storage
• Disk-Based Storage
– New in MySQL 5.1
– Undo Logging
– Fixed-Width Columns
Tablespace Tablespace
Datafile DatafileDatafile
Datafile
Undo Log
Redo log
www.osscube.com
Indexes
Creating Indexes
• Each table in the cluster always has a hash index for a
Primary Key
• Ordered indexes
Country Table: Uniquecan be created
Constraint with
on Name and ALTER
Ordered TABLE
Index ADD
on Continent
Code Name Continent
INDEX .... BRA Brazil South America
CHE Switzerland Europe
CHN China Asia
ESP Spain Europe
FIN Finland Europe
GOR United KingdomEurope
IND India Asia
MOR Morocco Africa
SKO South Korea Asia
Ordered
Index
Ordered
Index
Primary Key
Unique Key Lookup
Unique
Lookup
Key Lookup may
require another network hop
Look up row
Data node
MySQL Server
T-
Tree
Data node
Inde
x
rows
MySQL
Server Data node T-
Tree
Inde
x
Data node
rows
MySQL
Server Data node
SQL Query
Data node
Few Rows
rows
Many Rows
MySQL
Where
Server
Conditi
on Data node
MySQL
Server
Storage of Indexes
Characteristics of NDB
storage Engine
Durability
Memory - RAM
• Memory Allocation
Total Memory = N(data nodes)* Local
Memory / NoOfReplicas
-- or --
Local Memory = Total Memory *
NoOfReplicas / N(data nodes)
Memory Pages
Table A Table B
IndexMemory
Memory Page
Table A
(up to 8Kb)
DataMemory
Memory Page
Table A
(up to 32Kb)
IndexMemory DataMemory
Memory Page Memory Page
Table B Table B
(up to 8Kb) (up to 32Kb)
MySQL Cluster Tutorial, OSSPAC 09
Singapore, © OSSCube
www.osscube.com
Table Space
Data Data
File File
Log File
Table Space
Group
Data Data (Only One per Server)
File File
Undo Undo
Data File File
File Disk Data
Table
MySQL Cluster Tutorial, OSSPAC 09
Disk ©
Data Disk Data
Singapore, OSSCube Table
Table
www.osscube.com
MySQL CLUSTER
MANAGEMENT
www.osscube.com
MySQL Cluster’s Native Backup
Tool
Backup-1.2.ctl
• Backup Data Data Data Backup-1.2.log
Backup-1.0.2.Data
– .ctl Node Node
Backup-1.1.2.Data
– .log
– .data
• Abort Backup
Backup-1.3.ctl
ndb_mgm> ABORT
Data BACKUP 6 Data Backup-1.3.log
Backup-1.0.3.Data
Node Node
Abort of backup 6 ordered Backup-1.1.3.Data
MySQLdump
Restoring Backups
• Recovering MySQL Cluster's Native Backup Files
(1/3)
– Verify Management Node is Running
shell> ndb_mgm -e "SHOW"
– Start and Empty the Data Nodes
• Start each data node with the --initial
option.
Restoring Backups
Restoring Backups
Optimization
www.osscube.com
EXPLAIN
MySQL
Server Data node
MySQL Where
Server Data node
Condition
Index Statistics
Query Design
MySQL Cluster
Replication
www.osscube.com
MySQL Replication
MySQL Server
Application W Slave
MySQL Server
Binlog
Slave
Relaylog Binlog
www.osscube.com
MySQLd MySQLd
Update
Update
Update
Ndb API Ndb API
www.osscube.com
MySQLd(slave) Binlog
MySQLd(Master) Replication
NdbClsuter Handler
www.osscube.com
QnA