OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    2 Favorites

    OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09 - Presentation Transcript

    1. MySQL Cluster Tutorial Presented by – Sonali Minocha
    2. Who Am I? MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    3. Architecture and Organization
    4. What is a Cluster? MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    5. Single MySQL Server Architecture MySQL Client SQL Request Response MySQL Server
    6. MySQL Cluster Architecture MySQL Client SQL Request Response SQL Node (MySQL server) Data Nodes Response NDB API Call Partitioning Replication Message
    7. Components of MySQL Cluster MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    8. Various Nodes Application API Node Data Node Management Node MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    9. (Data Nodes) MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube NdbCluster Engine MySQL Server NdbCluster Engine MySQL Server NdbCluster Engine MySQL Server
    10. Organization MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    11. Partition MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    12. Partitioning MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    13. Fragments MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    14. Node Groups MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    15. 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
    16. Arbitration Network Split NG 1 MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube First Node to ask will continue while the other will be shut down
    17. More Data Nodes NG 1 Network Split/ Shutdown MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube NG 2
    18. Arbitrator Issues MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    19. Arbitrator Issues MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    20. Normal Operation I am Alive I am Alive I am Alive I am Alive MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    21. Missed Heartbeats I am Alive I am Alive I am Alive MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    22. Synchronous MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    23. Phase One: Commit-Request MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    24. Phase Two: Successful Commit MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    25. Phase Two: Failure (Abort Commit) MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    26. INSTALL MySQL CLUSTER
    27. 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, OSSPAC 09 Singapore, © OSSCube
    28. Management Node MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    29. 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
    30. Data Node Configurations Options MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    31. 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
    32. Config.ini Parameters
      • General Parameters
        • Id
        • Hostname
        • File and Directory Location Parameter
        • BackupDataDir
        • DataDir
        • FileSystemPath
      MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    33.  
      • Transaction Handling Parameters
        • TransactionInactiveTimeout
        • TransactionDeadlockDetectionTimeout
      • Memory Usage Parameters
        • LockPagesInMainMemory
      • Utility Programs
        • ndb_size.pl
    34. Monitoring the Startup Phases MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube. http://osscube.com/technology/mysql
    35. MySQL Cluster Storage Engine --NDB MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    36. NDB Storage Engine MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    37. 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
    38. Tablespace Tablespace Log File group Datafile Datafile Datafile Datafile Redo log Undo Log
    39. Indexes MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    40. 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, OSSPAC 09 Singapore, © OSSCube
    41. 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
      MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    42. Second Node/Second Fragment
      • Same as First Node/Fragment setup
      • Contains the remaining data
      MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    43. Primary Key Lookup PK values Function() Hash Data node Look up row Data node MySQL Server Unique Key Lookup Look up row Unique Key Lookup may require another network hop MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    44. Parallel Ordered Index Scan Data node Data node MySQL Server rows T- Tree Index T- Tree Index MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    45. Parallel full table scan Data node Data node MySQL Server rows MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    46. Parallel full table scan ( WHERE condition processed in SQL node) Data node Data node MySQL Server rows SQL Query Many Rows Few Rows Where Condition MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    47. Parallel full table scan ( WHERE condition processed in data node) Data node Data node MySQL Server rows SQL Query Few Rows Few Rows Where Condition Where Condition MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    48. Storage of Indexes MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    49. Characteristics of NDB storage Engine MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    50. Durability MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    51. 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
    52. Local Check Point MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    53. 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, OSSPAC 09 Singapore, © OSSCube
    54. Memory Pages MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    55. MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    56. HANDLING DATA IN MySQL CLUSTER
    57. Disk Data Objects MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    58. 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, OSSPAC 09 Singapore, © OSSCube
    59. 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, OSSPAC 09 Singapore, © OSSCube
    60. 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, OSSPAC 09 Singapore, © OSSCube
    61. 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, OSSPAC 09 Singapore, © OSSCube
    62. Monitoring Free Space MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    63. Dropping Cluster Tables MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    64. MySQL CLUSTER MANAGEMENT
    65. MySQL Cluster’s Native Backup Tool
      • Backup Data
        • .ctl
        • .log
        • .data
      • Abort Backup
        • ndb_mgm> ABORT BACKUP 6
        • Abort of backup 6 ordered
        • Node 2: Backup 10 started from 1 has been aborted. Error: 1321
      MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    66. MySQLdump MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    67. 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, OSSPAC 09 Singapore, © OSSCube
    68. Restoring Backups MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    69. Restoring Backups MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    70. Restoring MySQLdump Files MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    71. Optimization
    72. EXPLAIN MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    73. Full Table Scan
      • Without Condition Pushdown
      • With Condition Pushdown
      MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    74. Parallel full table scan ( WHERE condition processed in SQL node) Data node Data node MySQL Server rows SQL Query Many Rows Few Rows Where Condition MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    75. Parallel full table scan ( WHERE condition processed in data node) Data node Data node MySQL Server rows SQL Query Few Rows Where Condition Where Condition Few Rows MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    76. Index Statistics MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    77. MySQL Cluster Query Cache MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    78. Data Size/Usage Issues MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    79. Query Design MySQL Cluster Tutorial, OSSPAC 09 Singapore, © OSSCube
    80. MySQL Cluster Replication
    81. MySQL Server Master MySQL Server Slave MySQL Server Slave IO thread SQL thread Binlog Relaylog Relaylog Binlog Application W MySQL Replication
    82. Cluster Data node Data node Data node Data node MySQLd MySQLd Update Update Ndb API Ndb API Update Update
    83. 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
    84. 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
      • 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_address] or visit http://www.osscube.com www.osscube.com
    85. Q n A

    + OSSCube LLC A Global Open Source Enterprise for Open Source SolutionsOSSCube LLC A Global Open Source Enterprise for Open Source Solutions, 8 months ago

    custom

    1173 views, 2 favs, 2 embeds more stats

    Sonali from OSSCube presents on MySQL Cluster Tutor more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1173
      • 1163 on SlideShare
      • 10 from embeds
    • Comments 0
    • Favorites 2
    • Downloads 53
    Most viewed embeds
    • 6 views on http://osscube.com
    • 4 views on http://www.osscube.com

    more

    All embeds
    • 6 views on http://osscube.com
    • 4 views on http://www.osscube.com

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories