Introduction
MySQL cluster provides High availability and throughput. Unlike, other High availability environment MySQL cluster works similar to them. It is recommended to have two management node,two SQL node, two Data node for setting up MySQL cluster. In this tutorial we are using one management node to manage the Mysql cluster.
Our MySQL Setup Environment:
Package Installation
For installing MySQL cluster let first Deploy dependency package which required by MySQL cluster package.
~]# apt-get install libaio1
After that Download MySQL cluster package from this Link .
Once, completes downloading of MySQL cluster package. Use bellow command to install cluster package.
~]# dpkg -i mysql-cluster-gpl-7.4.14-debian7-x86_64.deb
Cluster Configuration
We will configure management node first. Install above packages on 5 nodes i.e. on management node, SQL node and Data node.
Main important step is to add entry of all nodes in hosts file too even if you have DNS server configured as in case your DNS server fails entry will be taken from hosts file. So I have added bellow entry's in my hosts file in all nodes.
1) Configuring Management node:
As shown, in above screenshot create config.ini file which is main configuration file for management node. Here, I have created directory /var/lib/mycluster and created config.ini file inside it. you can create in other directory too inside /var/lib/ location.
i) ndb_mgmd :- Management node details.
ii) ndbd default :- Default data node configuration.
NoofReplicas: replication nodes count.
DataMemory: Default is 80M
IndexMemory: Default is 20M but we have set 10M as its ok for testing purpose.
ServerPort: Port no of the data nodes to use if we not specify this server will use alternate port nos which difficult to add in firewalld.
iii) ndbd :- Data node details.
iv) mysqld :- SQL node details.
NoofReplicas: replication nodes count.
DataMemory: Default is 80M
IndexMemory: Default is 20M but we have set 10M as its ok for testing purpose.
ServerPort: Port no of the data nodes to use if we not specify this server will use alternate port nos which difficult to add in firewalld.
iii) ndbd :- Data node details.
iv) mysqld :- SQL node details.
To start MySQL cluster use bellow command
~]# /opt/mysql/server-5.6/bin/ndbd_mgmd -f /var/lib/mycluster/config.ini
You can add above command in /etc/rc.local file and enable it so that service will get started automatically after reboot as follows:
To enable service at after boot:
To enable service at after boot:
~]# systemctl enable rc-local.service
2) Configuring Data Nodes:
Create /etc/my.cnf file with bellow content for configuring data node.
As described above you can add above command in /etc/rc-local.service and enable this service to automatically start after reboot.
3) Configuring SQL Nodes:
For configuring SQL node create /etc/my.cnf file with bellow content:
To start SQL node use bellow command:
~]# mysqld_safe &
Above routine moves all tables related to privileges in ndbcluster format. Innodb is default cluster use by MySQL so if you create one user account in one node it will not get reflected in other node. To do that we have to run above command and convert default storage engine to ndbcluster. You can check current storage engine use by table by running bellow command.
~]# show create table mysql.user;
In the output of above command check engine equals to what that will be currently use storage engine.
This completes our MySQL cluster setup. There are various steps we need to do after setting cluster to check whether cluster is working or not.
1) Create user on one node and verify whether it reflects on other node or not.
2) Create database in one and access and add tables in that database from other SQL node or by login from client.
3) Shutdown one SQL node and check whether Our cluster still working properly or not.
4) Similarly, shutdown one data node and check cluster set up its working properly.
If above steps pass then your cluster setup has completed successfully.
Managing Nodes through Management node:
Bellow are some commands which will help us to manage our Cluster through Management node.
So this completes our MySQL cluster. You can find more details on official website of mysql.
This completes our MySQL cluster setup. There are various steps we need to do after setting cluster to check whether cluster is working or not.
1) Create user on one node and verify whether it reflects on other node or not.
2) Create database in one and access and add tables in that database from other SQL node or by login from client.
3) Shutdown one SQL node and check whether Our cluster still working properly or not.
4) Similarly, shutdown one data node and check cluster set up its working properly.
If above steps pass then your cluster setup has completed successfully.
Managing Nodes through Management node:
Bellow are some commands which will help us to manage our Cluster through Management node.
So this completes our MySQL cluster. You can find more details on official website of mysql.
Comments
Post a Comment