måndag 17 februari 2020

Getting started with MySQL Cluster using MySQL Cluster Manager

Creating a MySQL NDB Cluster is really easy when using MySQL Cluster Manager aka "MCM".
In this blog post we will look at how to install and configure MCM and then create a new cluster using MCM commands.

Steps to install and and setup MCM as a service is explained here.

Once you have completed the setup of MCM next step is to install MySQL NDB Cluster.
First step is to download latest Cluster 7.6 binaries from: https://dev.mysql.com/downloads/cluster/
(7.6.13 as of today)

cd /tmp
wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-7.6/mysql-cluster-gpl-7.6.13-linux-glibc2.12-x86_64.tar.gz

cd /opt
tar xzf /tmp/mysql-cluster-gpl-7.6.13-linux-glibc2.12-x86_64.tar.gz
mv mysql-cluster-gpl-7.6.13-linux-glibc2.12-x86_64 mysql-cluster-7.6.13
Now it's time to start the MCM client and create our cluster.
Start mcm: PATH=$PATH:/opt/mysql-cluster-7.6.13/bin /opt/mcm/mcm1.4.8/bin/mcm
(For future need I recommend that you set the $PATH variable:
export PATH=$PATH:/opt/mysql-cluster-7.6.13/bin:/opt/mcm/mcm1.4.7/bin)

Run commands below in mcm client (change basedir to folder with cluster binaries):
(for details on commands below look here)
create site --hosts=127.0.0.1 mysite;
add package --basedir=/opt/mysql-cluster-7.6.13 cluster7613;
create cluster --package=cluster7613 --processhosts=ndb_mgmd@127.0.0.1,ndbmtd@127.0.0.1,ndbmtd@127.0.0.1 mycluster;
add process --processhosts=mysqld@127.0.0.1,mysqld@127.0.0.1 mycluster;
add process --processhosts=ndbapi@127.0.0.1,ndbapi@127.0.0.1 mycluster;
add process --processhosts=ndbapi@127.0.0.1,ndbapi@127.0.0.1 mycluster;
set StopOnError:ndbmtd=0 mycluster;
set port:mysqld:50=3310 mycluster;
set port:mysqld:51=3311 mycluster;
start  cluster mycluster;
show status -r mycluster;
Output from last command "show status" should look like:
+--------+----------+------------+---------+-----------+-------------+
| NodeId | Process  | Host       | Status  | Nodegroup | Package     |
+--------+----------+------------+---------+-----------+-------------+
| 49     | ndb_mgmd | 127.0.0.1  | running |           | cluster7611 |
| 1      | ndbmtd   | 127.0.0.1  | running | 0         | cluster7611 |
| 2      | ndbmtd   | 127.0.0.1  | running | 0         | cluster7611 |
| 50     | mysqld   | 127.0.0.1  | running |           | cluster7611 |
| 51     | mysqld   | 127.0.0.1  | running |           | cluster7611 |

Congratulations, you have installed and created your first MySQL NDB Cluster!!

If you want to learn more:
https://github.com/wwwted/ndb-cluster-workshop
https://dev.mysql.com/doc/mysql-cluster-manager/1.4/en/
https://www.slideshare.net/ocklin/mysql-ndb-cluster-101
https://www.slideshare.net/frazerClement/mysql-cluster-80-tutorial
https://www.slideshare.net/ocklin/mysql-ndb-cluster-80-sql-faster-than-nosql
https://www.slideshare.net/datacharmer/mysql-ndb-80-clusters-in-your-laptop-with-dbdeployer
http://mikaelronstrom.blogspot.com/

Inga kommentarer:

Skicka en kommentar