OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09
-
Upload
osscube-llc-a-global-open-source-enterprise-for-open-source-solutions -
Category
Technology
-
view
2.560 -
download
0
description
Transcript of OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09
![Page 1: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/1.jpg)
MySQL Cluster Tutorial
Presented by – Sonali Minocha
![Page 2: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/2.jpg)
Who Am I?
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 3: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/3.jpg)
Architecture and OrganizationArchitecture and Organization
![Page 4: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/4.jpg)
What is a Cluster?
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 5: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/5.jpg)
Single MySQL Server Architecture
MySQL ClientMySQL Client MySQL Server
SQL Request
Response
![Page 6: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/6.jpg)
MySQL Cluster Architecture
MySQL ClientMySQL ClientSQL Request
Response
SQL Node (MySQL server)Data Nodes
Response
NDB API Call
PartitioningReplicationMessage
![Page 7: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/7.jpg)
Components of MySQL Cluster
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 8: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/8.jpg)
Various Nodes
Application
API Node Data Node
Management Node
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 9: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/9.jpg)
(Data Nodes)
NdbClusterEngine
NdbClusterEngine
NdbClusterEngine
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 10: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/10.jpg)
Organization
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 11: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/11.jpg)
Partition
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 12: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/12.jpg)
Partitioning
HorizontalPartitioning
VerticalPartitioning
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 13: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/13.jpg)
Fragments
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 14: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/14.jpg)
Node Groups
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 15: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/15.jpg)
Split Brain
Servers can not see each other
I have full responsibility of the cluster
I have full responsibility of the cluster
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 16: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/16.jpg)
Arbitration
First Node to ask will continue while the other will be shut down
Network Split
NG 1
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 17: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/17.jpg)
More Data Nodes
NG 1
NG 2
Network Split/ Shutdown
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 18: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/18.jpg)
Arbitrator Issues
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 19: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/19.jpg)
Arbitrator Issues
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 20: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/20.jpg)
Normal Operation
I am
Aliv
e
I am
Aliv
eI am
Alive
I am Aliv
e
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 21: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/21.jpg)
Missed Heartbeats
I am
Aliv
e
I am
Alive
I am
A
live
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 22: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/22.jpg)
Synchronous
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 23: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/23.jpg)
Phase One: Commit-Request
Commit
Message
Commit
Message
Response
Message
Response
Message
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 24: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/24.jpg)
Phase Two: Successful Commit
Transaction
Successful
Transaction
Successful
Commit
Transaction
Commit
Transaction
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 25: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/25.jpg)
Phase Two: Failure (Abort Commit)
Transaction
Successful
Transaction
Failed
Rollback
Transaction
Rollback
Transaction
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 26: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/26.jpg)
INSTALL MySQL CLUSTERINSTALL MySQL CLUSTER
![Page 27: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/27.jpg)
Initiate MySQL Cluster
• # file "config.ini" - 2 data nodes and 2 SQL nodes# This file is placed in the startup directory of ndb_mgmd (the# management server)
• # The first MySQL Server can be started from any host. The second# can be started only on the host MySQLd_5.MySQL.com
• [NDBD DEFAULT]NoOfReplicas= 2DataDir= /var/lib/MySQL-cluster
• [NDB_MGMD]Hostname= ndb_mgmd.MySQL.comDataDir= /var/lib/MySQL-cluster
• [NDBD]HostName= ndbd_2.MySQL.com
• [NDBD]HostName=ndbd_3.MySQL.com
• [MySQLD]• [MySQLD]
HostName= MySQLd_5.MySQL.comMySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 28: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/28.jpg)
Management Node
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 29: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/29.jpg)
Data Nodes
• my.cnf# example additions to my.cnf for MySQL Cluster
• [ndbd]
connect-string=ndb_mgmd.MySQL.com
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 30: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/30.jpg)
Data Node Configurations Options
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 31: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/31.jpg)
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
![Page 32: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/32.jpg)
Config.ini ParametersGeneral Parameters
– Id– Hostname
File and Directory Location Parameter– BackupDataDir– DataDir– FileSystemPath
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 33: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/33.jpg)
![Page 34: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/34.jpg)
•Transaction Handling Parameters•TransactionInactiveTimeout•TransactionDeadlockDetectionTimeout
•Memory Usage Parameters•LockPagesInMainMemory
•Utility Programs•ndb_size.pl
![Page 35: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/35.jpg)
Monitoring the Startup Phases
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube. http://osscube.com/technology/mysql
![Page 36: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/36.jpg)
MySQL Cluster Storage Engine --NDBMySQL Cluster Storage Engine --NDB
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 37: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/37.jpg)
NDB Storage Engine
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 38: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/38.jpg)
NDB’s Storage Method
• In-Memory Storage
• Disk-Based Storage– New in MySQL 5.1– Undo Logging– Fixed-Width Columns
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 39: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/39.jpg)
Tablespace Tablespace
Log File group
DatafileDatafile Datafile Datafile
Redo log Undo Log
![Page 40: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/40.jpg)
Indexes
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 41: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/41.jpg)
Creating Indexes• Each table in the cluster always has a hash index for a Primary Key
• Ordered indexes can be created with ALTER TABLE ADD INDEX ....
Code Name ContinentBRA Brazil South AmericaCHE Switzerland EuropeCHN China AsiaESP Spain EuropeFIN Finland EuropeGOR United KingdomEuropeIND India AsiaMOR Morocco AfricaSKO South Korea Asia
Data Node Data Node
Country Table: Unique Constraint on Name and Ordered Index on Continent
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 42: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/42.jpg)
First Node/First Fragment• Hidden field/table created that will handle the management of the
Unique Index on Name• Ordered Index (T-Tree) created for Continent field
HiddenField
Name_Hash Name Code17832 Morocco MOR24556 Brazil BRA27432 Spain ESP28900 United Kingdom GOR31234 China CHN
HiddenTable
Code_Hash Code Name Continent1351 CHE Switzerland Europe1785 CHN China Asia1943 FIN Finland Europe2031 GOR United Kingdom Europe2345 SKO South Korea Asia
Code_Hash Code Name Continent1351 CHE Switzerland Europe1785 CHN China Asia1943 FIN Finland Europe2031 GOR United Kingdom Europe2345 SKO South Korea Asia
OrderedIndex
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 43: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/43.jpg)
Second Node/Second Fragment• Same as First Node/Fragment setup• Contains the remaining data
Code Hash Code Name Continent1231 BRA Brazil South America1853 ESP Spain Europe2145 IND India Asia2197 MOR Morocco Africa
Code Hash Code Name Continent1231 BRA Brazil South America1853 ESP Spain Europe2145 IND India Asia2197 MOR Morocco Africa
HiddenField
Name_Hash Name Code17832 Finland FIN24556 South Korea SKO27432 Switzerland CHE28974 India IND
HiddenTable
OrderedIndex
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 44: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/44.jpg)
Primary Key Lookup
PK values Function()Hash Data nodeData node
Look up row
Data nodeData node
MySQL Server
Unique Key Lookup
Look up row
Unique Key Lookup may require another network hop
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 45: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/45.jpg)
Parallel Ordered Index Scan
Data nodeData node
Data nodeData nodeMySQL Server
rows
T- Tree Index
T- Tree Index
T- Tree Index
T- Tree Index
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 46: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/46.jpg)
Parallel full table scan
Data nodeData node
Data nodeData nodeMySQL Server
rows
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 47: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/47.jpg)
Parallel full table scan ( WHERE condition processed in SQL
node)
Data nodeData node
Data nodeData node
MySQL Server
rows
SQL Query
Many RowsMany RowsFew RowsFew Rows
Where Condition
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 48: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/48.jpg)
Parallel full table scan ( WHERE condition
processed in data node)
Data nodeData node
Data nodeData node
MySQL Server
rows
SQL Query
Few RowsFew RowsFew RowsFew Rows
Where Condition
Where Condition
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 49: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/49.jpg)
Storage of Indexes
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 50: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/50.jpg)
Characteristics of NDB storage Engine
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 51: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/51.jpg)
Durability
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 52: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/52.jpg)
Global Check Point
• A GCP occurs every few seconds, when transactions for all nodes are synchronized and the REDO log is flushed to disk
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 53: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/53.jpg)
Local Check Point
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 54: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/54.jpg)
Memory - RAM
• Memory AllocationTotal Memory = N(data nodes)* Local Memory / NoOfReplicas -- or --Local Memory = Total Memory * NoOfReplicas / N(data
nodes)
• Sizing up theMemory– Fixed size in memory – Variable sized in memory– Fixed size on disk
Binary(15)1 Byte
Padded
Binary(14)2 BytesPadded
Binary(14)2 BytesPadded
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 55: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/55.jpg)
Memory Pages
Table BTable BTable A
DataMemoryMemory Page
Table A(up to 32Kb)
IndexMemoryMemory PageTable A
(up to 8Kb)
IndexMemoryMemory Page
Table B(up to 8Kb)
DataMemoryMemory Page
Table B(up to 32Kb)MySQL Cluster Tutorial, OSSPAC 09
Singapore, © OSSCube
![Page 56: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/56.jpg)
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 57: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/57.jpg)
HANDLING DATA IN MySQL HANDLING DATA IN MySQL
CLUSTERCLUSTER
![Page 58: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/58.jpg)
Disk Data Objects
Log File Group
(Only One per Server)
Table Space
UndoFile
UndoFile
DataFile
DataFile
DataFile
Table Space
DataFile
DataFile
Disk Data Table
Disk Data Table
Disk Data Table
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 59: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/59.jpg)
Creating the Log File Group• Create Log File Group
CREATE LOGFILE GROUP lg_1 ADD UNDOFILE 'undo_1.dat' INITIAL_SIZE 16M UNDO_BUFFER_SIZE 2M ENGINE NDB;
• Adding Undo Files to Log File GroupALTER LOGFILE GROUP lg_1 ADD UNDOFILE 'undo_2.dat' INITIAL_SIZE 12M ENGINE NDB;
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 60: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/60.jpg)
Verifying UNDO Files are Created
• INFORMATION_SCHEMA TablesSELECT LOGFILE_GROUP_NAME, LOGFILE_GROUP_NUMBER,
EXTRA
FROM INFORMATION_SCHEMA.FILES
WHERE FILE_NAME = 'undo_1.dat';
SELECT LOGFILE_GROUP_NAME, LOGFILE_GROUP_NUMBER, EXTRA
FROM INFORMATION_SCHEMA.FILES
WHERE FILE_NAME = 'undo_2.dat';
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 61: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/61.jpg)
Creating the Tablespace• Create a Tablespace
CREATE TABLESPACE ts_1 ADD DATAFILE 'data_1.dat' USE LOGFILE GROUP lg_1 INITIAL_SIZE 32M ENGINE NDB;
• Add an Additional Data FileALTER TABLESPACE ts_1 ADD DATAFILE 'data_2.dat' INITIAL_SIZE 48M ENGINE NDB;
• Verifying Data Files are CreatedSELECT FILE_NAME, LOGFILE_GROUP_NAME, EXTRAFROM INFORMATION_SCHEMA.FILESWHERE TABLESPACE_NAME = 'ts_1' AND FILE_TYPE = 'DATAFILE';
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 62: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/62.jpg)
Create a Disk Data Table• Non-Indexed Columns Stored on Disk in Tablespace CREATE TABLE dt_1 (
memberId INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
lName VARCHAR(50) NOT NULL, fName VARCHAR(50) NOT NULL,
dob DATE NOT NULL, joined DATE NOT NULL,
INDEX(lName, fName)
) TABLESPACE ts_1 STORAGE DISK ENGINE NDB;
• Alter Existing Non-Cluster TablesALTER TABLE city TABLESPACE ts1 STORAGE DISK ENGINE=NDB;
• View Table StatusSHOW TABLE STATUS LIKE 'city'\G
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 63: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/63.jpg)
Monitoring Free Space
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 64: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/64.jpg)
Dropping Cluster Tables
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 65: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/65.jpg)
MySQL CLUSTER MySQL CLUSTER
MANAGEMENTMANAGEMENT
![Page 66: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/66.jpg)
MySQL Cluster’s Native Backup Tool
• Backup Data– .ctl– .log– .data
• Abort Backupndb_mgm> ABORT BACKUP 6Abort of backup 6 orderedNode 2: Backup 10 started from 1 has been aborted. Error: 1321
Data Node
Data Node
Data Node
Data Node
Backup-1.2.ctlBackup-1.2.logBackup-1.0.2.DataBackup-1.1.2.Data
Backup-1.3.ctlBackup-1.3.logBackup-1.0.3.DataBackup-1.1.3.Data
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 67: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/67.jpg)
MySQLdump
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 68: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/68.jpg)
Restoring Backups• Recovering MySQL Cluster's Native Backup Files (1/3)
– Verify Management Node is Runningshell> ndb_mgm -e "SHOW"
– Start and Empty the Data Nodes• Start each data node with the --initial option.
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 69: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/69.jpg)
Restoring Backups
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 70: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/70.jpg)
Restoring Backups
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 71: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/71.jpg)
Restoring MySQLdump Files
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 72: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/72.jpg)
OptimizationOptimization
![Page 73: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/73.jpg)
EXPLAIN
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 74: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/74.jpg)
Full Table Scan
• Without Condition Pushdown• With Condition Pushdown
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 75: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/75.jpg)
Parallel full table scan ( WHERE condition
processed in SQL node)
Data node
Data nodeMySQL Server
rows
SQL Query
Many RowsFew Rows
Where Condition
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 76: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/76.jpg)
Parallel full table scan ( WHERE condition processed in data
node)
Data node
Data nodeMySQL Server
rows
SQL Query
Few Rows
Where Condition
Where Condition
Few Rows
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 77: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/77.jpg)
Index Statistics
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 78: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/78.jpg)
MySQL Cluster Query Cache
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 79: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/79.jpg)
Data Size/Usage Issues
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 80: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/80.jpg)
Query Design
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
![Page 81: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/81.jpg)
MySQL Cluster ReplicationMySQL Cluster Replication
![Page 82: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/82.jpg)
MySQL ServerMaster
MySQL ServerSlave
MySQL ServerSlave
IO threadSQL thread
Binlog
Relaylog
Relaylog Binlog
Application W
MySQL Replication
![Page 83: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/83.jpg)
Cluster
Data node Data node
Data node Data node
MySQLd MySQLd
Update
Update
Ndb API Ndb API
Update
Update
![Page 84: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/84.jpg)
NDB Injector Thread
•A thread inside MySQL server•Responsible for injecting rows in binlog and produces “Single connical binlog for cluster”
• not just one MySQL Server•It contains everything written on all ndbApi program including MySQLd connected to cluster
![Page 85: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/85.jpg)
NdbClsuter Handler IO thread
Binlog
Relaylog
Binlog
MySQLd(Master)
MySQL Cluster Replication
Cluster
Data node Data node
Data node Data node
Replication
MySQLd(slave)
NdbClsuter Handler
Apply thread
Cluster
Data node Data node
Data node Data node
![Page 86: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/86.jpg)
Thank you for your time and attention
MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
For more information, please feel free to drop in a line to [email protected] or visit http://www.osscube.com
www.osscube.com
![Page 87: OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09](https://reader038.fdocuments.in/reader038/viewer/2022102922/54b6ead64a795908448b45cc/html5/thumbnails/87.jpg)
Q n A