Home >Database >Mysql Tutorial >How to install and configure MySQL Cluster on Linux system
MySQL Cluster is a solution for MySQL database cluster that can provide high availability, high reliability, high scalability and low latency. This article will introduce how to install and configure MySQL Cluster on Linux systems.
First, download the latest MySQL Cluster binary installation package from the official MySQL website. After unzipping, copy the tarballs of cluster-server and cluster-manager to all nodes in the cluster. The following are the steps to install MySQL Cluster:
$wget http://dev.mysql.com/get/Downloads/MySQL-Cluster-7.6/mysql-cluster-gpl-7.6.12-linux-glibc2.12-x86_64.tar.gz $tar xzf mysql-cluster-gpl-7.6.12-linux-glibc2.12-x86_64.tar.gz $cd mysql-cluster-gpl-7.6.12-linux-glibc2.12-x86_64 $cp -r bin/* /usr/local/bin/ $cp -r scripts/* /usr/local/bin/
Create the my.cnf file on each MySQL Cluster node and set the following in it Parameters to facilitate coordinated management of all nodes:
[ndbd default] NoOfReplicas = 2 DataMemory = 1024M IndexMemory = 128M DataDir = /var/mysql-cluster/ndb-data [ndb_mgmd] NodeId = 1 HostName = 172.16.0.10 DataDir = /var/mysql-cluster/ndb-data [ndbd] NodeId = 2 HostName = 172.16.0.11 [ndbd] NodeId = 3 HostName = 172.16.0.12 [mysqld] NodeId = 4 HostName = 172.16.0.13
Four nodes are set up in the above configuration file, one of which is used as a management node, and data nodes and mysql nodes are defined on other nodes.
In MySQL Cluster, the management node is used to coordinate the entire cluster. To start the management node, you need to specify the path to the my.cnf configuration file. You can use the following command to start:
ndb_mgmd -f /usr/local/mysql-cluster/my.cnf
After successful startup, you should see the following output:
ndb_mgm> show Connected to Management Server at: localhost:1186 Cluster Configuration --------------------- [ndbd(NDB)] 2 node(s) id=2 (not started, accepting connect from 172.16.0.11) id=3 (not started, accepting connect from 172.16.0.12) [ndb_mgmd(MGM)] 1 node(s) id=1 @172.16.0.10 (mysql-5.7.22 ndb-7.6.12) [mysqld(API)] 1 node(s) id=4 @172.16.0.13 (mysql-5.7.22 ndb-7.6.12)
Data nodes are the components that store data in MySQL Cluster. Before starting the data node, you need to create the data directory first, and then use the following command to start the data node:
mkdir -p /var/mysql-cluster/ndb-data ndbd --initial
The MySQL node is connected to the MySQL cluster client. To use the MySQL node, the MySQL server must be started. Before starting the MySQL server, you need to specify the corresponding MySQL Cluster node configuration information in the MySQL configuration file. The following is an example of a MySQL node configuration file:
[mysql_cluster] ndb-connectstring=172.16.0.10
You can then start the MySQL server using the following command:
mysqld_safe --defaults-file=/etc/mysql/my.cnf &
Complete the above steps Finally, you can use the following command to verify whether MySQL Cluster is running normally:
mysql -uroot -p -h172.16.0.13
You can connect to the MySQL server through the above method to verify whether MySQL Cluster is working properly.
This article describes how to install and configure MySQL Cluster on Linux systems. MySQL Cluster can provide high availability, high reliability, high scalability and low latency. After completing the above steps, MySQL Cluster will be running and ready for use.
The above is the detailed content of How to install and configure MySQL Cluster on Linux system. For more information, please follow other related articles on the PHP Chinese website!