• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
The OSSCube MySQL High Availability Tutorial
 

The OSSCube MySQL High Availability Tutorial

on

  • 4,469 views

The OSSCube MySQL High Availability Tutorial presentation given by Rakesh Kumar and Sonali Minocha at OSI Days 2010

The OSSCube MySQL High Availability Tutorial presentation given by Rakesh Kumar and Sonali Minocha at OSI Days 2010

Statistics

Views

Total Views
4,469
Views on SlideShare
4,024
Embed Views
445

Actions

Likes
4
Downloads
37
Comments
0

14 Embeds 445

http://www.osscube.com 239
http://www.osscube.in 113
http://staging.osscube.com 67
http://local.osscube.com 8
http://dev3qa.osscube.co.uk 3
http://druposs.osscube.com 3
http://localhost 2
http://dev.osscube.com 2
http://osslocal.com 2
http://dev3qa.osscube.co.in 2
http://osscube.localhost 1
http://stagingcrm.osscube.com 1
http://www.osscube.co.uk 1
http://feeds2.feedburner.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    The OSSCube MySQL High Availability Tutorial The OSSCube MySQL High Availability Tutorial Presentation Transcript

    • MySQL HA Tutorial Presented by – Sonali Minocha and Rakesh Kumar OSSCube
    • Who Am I? MySQL Cluster Tutorial © OSSCube
    • Architecture and Organization
    • What is a Cluster? MySQL Cluster Tutorial, © OSSCube
    • Single MySQL Server Architecture SQL Request MySQL Server MySQL Client MySQL Client Response MySQL Cluster Tutorial, © OSSCube
    • MySQL Cluster Architecture NDB API Call SQL Request MySQL Client Partitioning Replication Message Response Response SQL Node (MySQL server) MySQL Cluster Tutorial, © OSSCube Data Nodes
    • Components of MySQL Cluster MySQL Cluster Tutorial © OSSCube
    • Various Nodes API Node Data Node Application Management Node MySQL Cluster Tutorial, © OSSCube
    • NdbCluster Engine NdbCluster Engine (Data Nodes) MySQL Cluster Tutorial,© OSSCube NdbCluster Engine
    • Organization MySQL Cluster Tutorial,© OSSCube
    • Partition MySQL Cluster Tutorial, © OSSCube
    • Partitioning MySQL Cluster Tutorial © OSSCube
    • Fragments MySQL Cluster Tutorial© OSSCube
    • Node Groups MySQL Cluster Tutorial, © OSSCube
    • Split Brain I have full responsibility of the cluster Servers can not see each other I have full responsibility of the cluster MySQL Cluster Tutorial,© OSSCube
    • Arbitration NG 1 Network Split First Node to ask will continue while the other will be shut down MySQL Cluster Tutorial, © OSSCube
    • More Data Nodes NG 1 Network Split/ Shutdown NG 2 MySQL Cluster Tutorial, © OSSCube
    • Arbitrator Issues MySQL Cluster Tutorial, © OSSCube
    • Arbitrator Issues MySQL Cluster Tutorial, © OSSCube
    • Normal Operation Ia Al m iv e Ia Al m iv e m I a ive Al Ia A m liv e MySQL Cluster Tutorial,© OSSCube
    • Missed Heartbeats Ia Al m iv e I am Alive m I a ive Al MySQL Cluster Tutorial, © OSSCube
    • Synchronous MySQL Cluster Tutorial, © OSSCube
    • Phase One: CommitRequest Commit Commit Message Message Response Response Message Message MySQL Cluster Tutorial, © OSSCube
    • Phase Two: Successful Commit Transaction Transaction Successful Successful Commit Commit Transaction Transaction MySQL Cluster Tutorial, © OSSCube
    • Phase Two: Failure (Abort Commit) Transaction Transaction Failed Successful Rollback Rollback Transaction Transaction MySQL Cluster Tutorial, © OSSCube
    • INSTALL MySQL CLUSTER
    • 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= 2 DataDir= /var/lib/MySQL-cluster [NDB_MGMD] Hostname= ndb_mgmd.MySQL.com DataDir= /var/lib/MySQL-cluster [NDBD] HostName= ndbd_2.MySQL.com [NDBD] HostName=ndbd_3.MySQL.com [MySQLD] [MySQLD] HostName= MySQLd_5.MySQL.com MySQL Cluster Tutorial, © OSSCube
    • Management Node MySQL Cluster Tutorial, © OSSCube
    • Data Nodes • my.cnf# example additions to my.cnf for MySQL Cluster • [ndbd] connectstring=ndb_mgmd.MySQL.com MySQL Cluster Tutorial, © OSSCube
    • Data Node Configurations Options MySQL Cluster Tutorial, © OSSCube
    • 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 MySQL Cluster Tutorial, © OSSCube :1186
    • Config.ini Parameters General Parameters – Id – Hostname File and Directory Location Parameter – BackupDataDir – DataDir – FileSystemPath MySQL Cluster Tutorial, © OSSCube
    • MySQL Cluster Tutorial, © OSSCube
    • •Transaction Handling Parameters •TransactionInactiveTimeout •TransactionDeadlockDetectionTimeou t •Memory Usage Parameters •LockPagesInMainMemory •Utility Programs •ndb_size.pl Cluster Tutorial, © OSSCube MySQL
    • Monitoring the Startup Phases MySQL Cluster Tutorial, © OSSCube
    • MySQL Cluster Storage Engine --NDB
    • NDB Storage Engine MySQL Cluster Tutorial, © OSSCube
    • NDB’s Storage Method • In-Memory Storage • Disk-Based Storage – New in MySQL 5.1 – Undo Logging – Fixed-Width Columns MySQL Cluster Tutorial, © OSSCube
    • Tablespace Datafile Tablespace Datafile Datafile Datafile Log File group Redo log Undo Log MySQL Cluster Tutorial, © OSSCube
    • Indexes MySQL Cluster Tutorial, © OSSCube
    • 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 .... MySQL Cluster Tutorial, © OSSCube
    • 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 Hidden Field Code_Hash 1351 1785 1943 2031 2345 Code CHE CHN FIN GOR SKO Name Switzerland China Finland United Kingdom South Korea Continent Europe Asia Europe Europe Asia Ordered Index Hidden Table MySQL Cluster Tutorial, © OSSCube
    • Second Node/Second Fragment • • Same as First Node/Fragment setup Contains the remaining data Hidden Field Code Hash 1231 1853 2145 2197 Code BRA ESP IND MOR Name Brazil Spain India Morocco Continent South America Europe Asia Africa Ordered Index Hidden Table MySQL Cluster Tutorial, © OSSCube
    • Unique Key Lookup Primary Key Lookup may UniqueKey Lookup network hop require another PK values Function() Hash Look up row Data node Data node Look up row Data node Data node MySQL Server MySQL Cluster Tutorial, © OSSCube
    • Parallel Ordered Index Scan Data node Data node TTTree Tree Index Index rows MySQL Server Data node Data node MySQL Cluster Tutorial, © OSSCube TTTree Tree Index Index
    • Parallel full table scan Data node Data node rows MySQL Server Data node Data node MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    • Parallel full table scan ( WHERE condition processed in SQL node) SQL Query Data node Data node Few Rows Few Rows Many Rows rows Rows Many MySQL Server Where Conditi on MySQL Cluster Tutorial, © OSSCube Data node Data node
    • Parallel full table scan ( WHERE condition processed in data node) SQL Query Where Conditi Fewrows on Rows Few Rows Few Rows Few Rows Data node Data node MySQL Server Where Conditi on MySQL Cluster Tutorial, © OSSCube Data node Data node
    • Storage of Indexes MySQL Cluster Tutorial, © OSSCube
    • Characteristics of NDB storage Engine MySQL Cluster Tutorial, © OSSCube
    • Durability MySQL Cluster Tutorial, © OSSCube
    • 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, © OSSCube
    • Local Check Point MySQL Cluster Tutorial, © OSSCube
    • Memory - RAM • Memory Allocation Total Memory = N(data nodes)* Local Memory / NoOfReplicas -- or -Local Memory = Total Memory * NoOfReplicas / N(data nodes) • Sizing up the Memory – Fixed size in memory – Variable sized in memory – Fixed size on disk MySQL Cluster Tutorial, © OSSCube
    • Memory Pages MySQL Cluster Tutorial, © OSSCube
    • MySQL Cluster Tutorial, © OSSCube
    • HANDLING DATA IN MySQL CLUSTER
    • Disk Data Objects MySQL Cluster Tutorial, © OSSCube
    • 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 Group ALTER LOGFILE GROUP lg_1 ADD UNDOFILE 'undo_2.dat' INITIAL_SIZE 12M ENGINE NDB; MySQL Cluster Tutorial, © OSSCube
    • Verifying UNDO Files are Created • INFORMATION_SCHEMA Tables SELECT 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, © OSSCube
    • 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 File ALTER TABLESPACE ts_1 ADD DATAFILE 'data_2.dat' INITIAL_SIZE 48M ENGINE NDB; • Verifying Data Files are Created SELECT FILE_NAME, LOGFILE_GROUP_NAME, EXTRA FROM INFORMATION_SCHEMA.FILES WHERE TABLESPACE_NAME = 'ts_1' AND FILE_TYPE = 'DATAFILE'; MySQL Cluster Tutorial, © OSSCube
    • 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 Tables ALTER TABLE city TABLESPACE ts1 STORAGE DISK ENGINE=NDB; • View Table Status SHOW TABLE STATUS LIKE 'city'G MySQL Cluster Tutorial, © OSSCube
    • Monitoring Free Space MySQL Cluster Tutorial, © OSSCube
    • Dropping Cluster Tables MySQL Cluster Tutorial, © OSSCube
    • MySQL CLUSTER MANAGEMENT
    • MySQL Cluster’s Native Backup Tool • Backup Data – .ctl – .log – .data Data Node • Abort Backup Data Node Backup-1.2.ctl Backup-1.2.log Backup-1.0.2.Data Backup-1.1.2.Data Backup-1.3.ctl Backup-1.3.log Backup-1.0.3.Data Backup-1.1.3.Data Data Data ndb_mgm> ABORT BACKUP 6 Node Node Abort of backup 6 ordered Node 2: Backup 10 started from 1 has been aborted. Error: 1321 MySQL Cluster Tutorial, © OSSCube
    • MySQLdump MySQL Cluster Tutorial, © OSSCube
    • 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. MySQL Cluster Tutorial, © OSSCube
    • Restoring Backups MySQL Cluster Tutorial, © OSSCube
    • Restoring Backups MySQL Cluster Tutorial, © OSSCube
    • Restoring MySQLdump Files MySQL Cluster Tutorial, © OSSCube
    • Optimization
    • EXPLAIN MySQL Cluster Tutorial, © OSSCube
    • Full Table Scan • Without Condition Pushdown • With Condition Pushdown MySQL Cluster Tutorial, © OSSCube
    • Parallel full table scan ( WHERE condition processed in SQL node) SQL Query Few Rows Where Condition Data node Many rows Rows MySQL Server MySQL Cluster Tutorial, © OSSCube Data node
    • Parallel full table scan ( WHERE condition processed in data node) SQL Query Where Condition Data node Few Rows Few Rows rows MySQL Server MySQL Cluster Tutorial, © OSSCube Where Data Condition node
    • Index Statistics MySQL Cluster Tutorial, © OSSCube
    • MySQL Cluster Query Cache MySQL Cluster Tutorial, © OSSCube
    • Data Size/Usage Issues MySQL Cluster Tutorial, © OSSCube
    • Query Design MySQL Cluster Tutorial, © OSSCube
    • MySQL Cluster Replication
    • MySQL Replication MySQL Server Slave Application W MySQL Server Master Binlog Relaylog IO thread SQL thread MySQL Server Slave Relaylog MySQL Cluster Tutorial, © OSSCube Binlog
    • mysqld mysqld Update Data node Update Data node Cluster Data node Data node Update Update Ndb API Ndb API MySQL Cluster Tutorial, © OSSCube
    • 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 MySQL Cluster Tutorial, © OSSCube
    • MySQL Cluster Replication MySQLd(slave) MySQLd(Master) Replication NdbClsuter Handler IO thread Binlog Data node Cluster Data node Data node Data node Binlog NdbClsuter Handler Relaylog Apply thread Data node Data node Cluster Data node Data node MySQL Cluster Tutorial, © OSSCube
    • QnA
    • Thank you for your time and attention For more information, please feel free to drop in a line to sales@osscube.com or visit http://www.osscube.com Or call us at 1-888-9OSSCube (Toll Free for USA) 1-919-791-5472 (From outside USA) MySQL Cluster Tutorial, © OSSCube