This article first introduces the MySQL cluster and then provides an installation process.
Introduction:
MySQL cluster is a technology that applies memory database clusters in a non-shared architecture system. This non-shared architecture can make the system use very inexpensive and minimum-configuration hardware.
A MySQL cluster is a distributed design designed to achieve zero point of failure. Therefore, any component should have its own memory and disk. Any shared storage solutions such as network sharing, network file systems and SAN devices are not recommended or supported. With this redundant design, MySQL claims that the data availability can reach 99. 999%.
In fact, a MySQL cluster integrates a memory Cluster Storage engine called NDB with a standard MySQL server. It contains a group of computers, each running one or more processes, which may include a MySQL server, a data node, a Management Server, and a proprietary data access program. Shows the relationship between them:
Install
Preparation:
Machines: Install Red Hat Linux AS 5 and disable the firewall.
Software: mysql-cluster-gpl-6.3.20-linux-i686-glibc23.tar.gz
IP |
Description |
192.168.99.80 |
Management Node |
192.168.99.88 |
SQL Node |
192.168.99.89 |
Data Node |
192.168.99.90 |
Data Node |
The following IP addresses and purposes are allocated to the four machines:
The installation node has four machines and needs to be repeated four times:
- [root@candyshop ~]#groupadd mysql
- [root@candyshop ~]#useradd –g mysql mysql
- [root@candyshop ~]#tar zxvf mysql-cluster-gpl-6.3.20-linux-i686-glibc23.tar.gz
- [root@candyshop ~]#chown mysql:mysql mysql-cluster-gpl-6.3.20-linux-i686-glibc23
- [root@candyshop ~]#mv mysql-cluster-gpl-6.3.20-linux-i686-glibc23 /usr/local/mysql
The preceding command first creates a mysql group and a mysql user, assigns mysql to the mysql group, decompress the installation file, and places it in the/usr/local/mysql directory.
Configuration
Configuration Management node [192.168.99.80]:
Create the following file/usr/local/mysql/cluster-conf/config. ini and place the following content:
- # Options affecting ndbd processes on all data nodes:
- [ndbd default]
- NoOfReplicas=2 # Number of replicas
- DataMemory=80M # How much memory to allocate for data storage
- IndexMemory=18M # How much memory to allocate for index storage
- # For DataMemory and IndexMemory, we have used the
- # default values. Since the "world" database takes up
- # only about 500KB, this should be more than enough for
- # this example Cluster setup.
-
- # Management process options:
- [ndb_mgmd]
- Id=1
- Hostname=192.168.99.80 # Hostname or IP address of management node
- Datadir=/usr/local/mysql/logs # Directory for management node log files
-
- # Options for data node "A":
- [ndbd]
- Id=2
- Hostname=192.168.99.89 # Hostname or IP address
- Datadir=/usr/local/mysql/ndbdata # Directory for this data node's data files
-
- # Options for data node "B":
- [ndbd]
- Id=3
- Hostname=192.168.99.90 # Hostname or IP address
- Datadir=/usr/local/mysql/ndbdata # Directory for this data node's data files
-
- # SQL node options:
- [mysqld]
- Id=4
- Hostname=192.168.99.88 # Hostname or IP address
- # (additional mysqld connections can be
- # specified for this node for various
- # purposes such as running ndb_restore)
In this file, IDs are assigned to the four nodes, which facilitates better management and differentiation of each node. Of course, if not specified, MySQL will also dynamically allocate one. The preceding Datadir files must be manually created if they do not exist. Run the mkdir-p command.
Configure the data node [192.168.99.89, 192.168.99.90]:
Create the/etc/my. cnf file with the following content:
- # Options for mysqld process:
- [mysqld]
- Datadir=/usr/local/mysql/ndbdata
- ndbcluster # run NDB storage engine
- ndb-connectstring=192.168.99.80 # location of management server
-
- # Options for ndbd process:
- [mysql_cluster]
- ndb-connectstring=192.168.99.80 # location of management server
Configure the SQL node [192.168.99.88]
Create the/etc/my. cnf file with the following content:
- # Options for mysqld process:
- [mysqld]
- ndbcluster # run NDB storage engine
- ndb-connectstring=192.168.99.80 # location of management server
-
- # Options for ndbd process:
- [mysql_cluster]
- ndb-connectstring=192.168.99.80 # location of management server
- [root@server88 mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --ldata=/usr/local/mysql/data/
- Installing MySQL system tables...
- OK
- Filling help tables...
- OK
By now, all configurations have been completed.
Start
Start the pipe node [192.168.99.80]:
- [root@candyshop mysql]# ./bin/ndb_mgmd -f cluster-conf/config.ini
- [root@candyshop mysql]# ./bin/ndb_mgm
- -- NDB Cluster -- Management Client --
- ndb_mgm> show
- Connected to Management Server at: 192.168.99.80:1186
- Cluster Configuration
- ---------------------
- [ndbd(NDB)] 2 node(s)
- id=2 (not connected, accepting connect from 192.168.99.89)
- id=3 (not connected, accepting connect from 192.168.99.90)
-
- [ndb_mgmd(MGM)] 1 node(s)
- id=1 @192.168.99.80 (mysql-5.1.30 ndb-6.3.20)
-
- [mysqld(API)] 1 node(s)
- id=4 (not connected, accepting connect from 192.168.99.88)
We can see that the status of the cluster has not been started, and the status is not connected.
- [root@candyshop mysql]# ./bin/ndb_mgmd -f cluster-conf/config.ini
- [root@candyshop mysql]# ./bin/ndb_mgm
- -- NDB Cluster -- Management Client --
- ndb_mgm> show
- Connected to Management Server at: 192.168.99.80:1186
- Cluster Configuration
- ---------------------
- [ndbd(NDB)] 2 node(s)
- id=2 (not connected, accepting connect from 192.168.99.89)
- id=3 (not connected, accepting connect from 192.168.99.90)
-
- [ndb_mgmd(MGM)] 1 node(s)
- id=1 @192.168.99.80 (mysql-5.1.30 ndb-6.3.20)
-
- [mysqld(API)] 1 node(s)
- id=4 (not connected, accepting connect from 192.168.99.88)
Start the data node [192.168.99.89, 192.168.99.90]:
- [root@server89 ~]#cd /usr/local/mysql
- [root@server89 mysql]#./bin/ndbd
Start the SQL node [192.168.99.88]:
- [root@server88 mysql]# ./bin/mysqld_safe &
Now, all nodes have been started. Let's check the system status:
- ndb_mgm> show
- Connected to Management Server at: localhost:1186
- Cluster Configuration
- ---------------------
- [ndbd(NDB)] 2 node(s)
- id=2 @192.168.99.89 (mysql-5.1.30 ndb-6.3.20, Nodegroup: 0, Master)
- id=3 @192.168.99.90 (mysql-5.1.30 ndb-6.3.20, Nodegroup: 0)
-
- [ndb_mgmd(MGM)] 1 node(s)
- id=1 @192.168.99.80 (mysql-5.1.30 ndb-6.3.20)
-
- [mysqld(API)] 1 node(s)
- id=4 @192.168.99.88 (mysql-5.1.30 ndb-6.3.20)
So far, the installation is complete
Edit recommendations]