A MySQL cluster requires a group of computers. The roles of each computer may be different. MySQL clusters have three types of nodes: Management node, data node, and SQL node. A
A MySQL cluster requires a group of computers. The roles of each computer may be different. MySQL clusters have three types of nodes: Management node, data node, and SQL node. A
Introduction to Mysql Clusters
Data nodes are used to store data.
Shows the relationship between three cluster nodes and applications:
1. Configure the environment:
MySQL: mysql-cluster-gpl-7.2.12-linux2.6-x86_64.tar.gz
Node Configuration:
Hostname IP address application service
DB1 172.16.10.160 MGM
DB2 172.16.10.161 NDBD1, MYSQLD
DB3 172.16.10.162 NDBD2, MYSQLD
DB4 172.16.10.254 MYSQLD
2. Management Nodes:
(1) install the management node MGM
# Groupadd mysql
# Useradd mysql-g mysql
# Music mysql-cluster-gpl-7.0.8a-linux-i686-glibc23.tar.gz/usr/local/
# Cd/usr/local/
# Tar zxvfmysql-cluster-gpl-7.0.8a-linux-i686-glibc23.tar.gz
# Rm -fmysql-cluster-gpl-7.0.8a-linux-i686-glibc23.tar.gz
# Music mysql-cluster-gpl-7.0.8a-linux-i686-glibc23mysql
# Chown-R mysql: mysql
(2) configuration and management node MGM
# Mkdir/var/lib/mysql-cluster
# Cd/var/lib/mysql-cluster
[Ndbd default]
NoOfReplicas = 2 # Number of replicas. The default value is 2.
DataMemory = 600 M # Memory allocated to data in each data node
IndexMemory = 100 M # Memory allocated to the index for each data node
BackupMemory: 20 M
Nodeid = 1
[NDBD]
HostName = 172.16.10.162
DataDir =/usr/local/mysql/data
HostName = 172.16.10.161
[Mysqld]
HostName = 172.16.10.162
[Mysqld]
HostName = 172.16.10.254
[Mysqld] # We recommend that you retain an SQL node configuration port.
(3) Start related services and Test on management nodes:
#/Usr/local/mysql/bin/ndb_mgmd-f/var/lib/mysql-cluster/config. ini
# Netstat-lntpu
Tcp 0 0 0.0.0.0: 1186 0.0.0.0: * LISTEN 22907/ndb_mgmd
If Port 1186 is enabled, the startup is normal.
Ndb_mgmd-f/var/lib/mysql-cluster/config. ini -- initial
#/Usr/local/mysql/bin/ndb_mgm-e show
Close the management node as follows:
#/Usr/local/mysql/bin/ndb_mgm-e shutdown
Iii. Data nodes and SQL nodes:
# Groupadd mysql
# Useradd mysql-g mysql
Export mvmysql-cluster-gpl-7.0.8a-linux-i686-glibc23.tar.gz/usr/local/
# Cd/usr/local/
# Tar zxvfmysql-cluster-gpl-7.0.8a-linux-i686-glibc23.tar.gz
# Rm -fmysql-cluster-gpl-7.0.8a-linux-i686-glibc23.tar.gz
# Music mysql-cluster-gpl-7.0.8a-linux-i686-glibc23mysql
# Chown-R mysql: mysql
# Cd mysql
# Scripts/mysql_install_db -- user = mysql
# Cp support-files/my-medium.cnf/etc/my. cnf
# Cp support-files/mysql. server/etc/init. d/mysqld
(2) configure data nodes and SQL nodes
[Mysqld]
(3) data nodes and SQL node services:
Start a Data Node
#/Usr/local/mysql/bin/ndbd-initial #/usr/local/mysql/bin/ndbd
Start an SQL Node
Service mysqld start
,