Mysqlcluster installation instructions 1. This document describes how to plan, install, configure, and run a MySQL cluster. Ii. Mysql Cluster Structure and terminology? Management Nodes: these nodes manage other nodes in the MySQL cluster, such as providing configuration data, starting and stopping nodes, and running backups. This type of node is responsible
Mysql cluster installation instructions 1. This document describes how to plan, install, configure, and run a MySQL cluster. Ii. Mysql Cluster Structure 3. Glossary? Management Nodes: these nodes manage other nodes in the MySQL cluster, such as providing configuration data, starting and stopping nodes, and running backups. This type of node is responsible
Mysql cluster installation instructions
I. Description
This document describes how to plan, install, configure, and run a MySQL cluster.
Ii. Mysql Cluster Structure
Iii. Glossary
?Management node:These nodes manage other nodes in the MySQL cluster, such as providing configuration data, starting and stopping nodes, and running backups. Because these nodes are responsible for managing the configurations of other nodes, they should be started before other nodes are started.
?Data Node:These nodes are used to save the data of the cluster. The number of data nodes is related to the number of copies, which is a multiple of the segments. For example, if two copies have two segments, each of them has four data nodes. There is no need for more than one copy. Data nodes use commandsNdbdStarted.
?SQL node:This is the node used to access cluster data. For MySQL clusters, client nodes are traditional MySQL servers that use the NDB Cluster Storage engine.
Iv. installation environment 1. Operating System
Linux version2.6.18-164. el5
2. Installation Structure
3. Deployment list
Name |
Ip |
(MGM) Management Node (NDBD) Data Node 1 |
192.168.10.10 192.168.10.20 |
(NDBD) Data Node 2 |
192.168.10.40 |
SQL Node 1 |
192.168.10.30 |
SQL Node 2 |
192.168.10.50 |
5. Install software
MySQL-Cluster-gpl-management-7.1.29-1.rhel5.x86_64.rpm
MySQL-Cluster-gpl-storage-7.1.29-1.rhel5.x86_64.rpm
MySQL-Cluster-gpl-tools-7.1.29-1.rhel5.x86_64.rpm
MySQL-Cluster-gpl-client-7.1.29-1.rhel5.x86_64.rpm
MySQL-Cluster-gpl-server-7.1.29-1.rhel5.x86_64.rpm
: Http://www.mysql.com/downloads/cluster/7.1.html
Vi. Installation Steps 1. Management node Installation
Upload
MySQL-Cluster-gpl-management-7.1.29-1.rhel5.x86_64.rpm, MySQL-Cluster-gpl-tools-7.1.29-1.rhel5.x86_64.rpm to server 192.168.10.10
Installation:
[root@192.168.10.10 ]# rpm -ivh MySQL-Cluster-gpl-management-7.1.29-1.rhel5.x86_64.rp[root@192.168.10.10 ]# rpm -ivh MySQL-Cluster-gpl-tools-7.1.29-1.rhel5.x86_64.rpm[root@192.168.10.10 ]# mkdir /var/lib/mysql-cluster[root@192.168.10.10 ]# vi /var/lib/mysql-cluster/config.ini
Modify config. ini
[ndbd default]NoOfReplicas=2DataMemory=80MIndexMemory=18M[tcp default]SendBufferMemory=2MReceiveBufferMemory=2M[NDB_MGMD DEFAULT]PortNumber=1186datadir=/var/lib/mysql-cluster[ndb_mgmd]NodeId=1hostname=192.168.10.10[ndbd]NodeId=2hostname=192.168.10.20datadir=/var/lib/mysql-data[ndbd]NodeId=4hostname=192.168.10.40datadir=/var/lib/mysql-data[mysqld]NodeId=3hostname=192.168.10.30[mysqld]NodeId=5hostname=192.168.10.50
Note: The number of NoOfReplicas must be the same as the number of data nodes!
2. Data Node Installation
Upload MySQL-Cluster-gpl-storage-7.1.29-1.rhel5.x86_64.rpm to server 192.168.10.20 and 192.168.10.40 respectively
Run
[Root@192.168.10.20] # rpm-ivh MySQL-Cluster-gpl-storage-7.1.29-1.rhel5.x86_64.rpm outputs the following successfully Preparing... ######################################## ### [100%] 1: mySQL-Cluster-gpl-stora ################################# ######### [100%] [root@192.168.10.20] # mkdir/var/lib/mysql-data [root@192.168.10.20] # chmod 777/var/lib/mysql-data -R [root@192.168.10.20] # vi/etc/my. cnf
Modify my. cnf
Install 192.168.10.40 as above
3. SQL node Installation
Upload MySQL-Cluster-gpl-client-7.1.29-1.rhel5.x86_64.rpm
MySQL-Cluster-gpl-server-7.1.29-1.rhel5.x86_64.rpm to the server 192.168.10.30 and 192.168.10.50 respectively
Run
[Root@192.168.10.30] # rpm-ivh MySQL-Cluster-gpl-server-7.1.29-1.rhel5.x86_64.rpm outputs the following successfully Preparing... ######################################## ### [100%] 1: mySQL-Cluster-gpl-serve ################################# ######### [100%] please remember to set a password for the MySQL root USER! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin-u root password 'new-password'/usr/bin/mysqladmin-u root-h localhost. localdomain password 'new-password' Alternatively you can run:/usr/bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default. this isstronugly recommended for production serv Ers. See the manual for more instructions. Please report any problems with the/usr/bin/mysqlbug script! [Root@192.168.10.30] # rpm-ivh MySQL-Cluster-gpl-client-7.1.29-1.rhel5.x86_64.rpm -- nodeps-force output the following success Preparing... ######################################## ### [100%] 1: mySQL-Cluster-gpl-clien ################################# ######### [100%] [root@192.168.10.30] # vi/etc/my. cnf
Modify my. cnf
[mysqld]ndbclusterndb-connectstring=192.168.10.10:1186[mysql_cluster]ndb-connectstring=192.168.10.10:1186
Install 192.168.10.50 as above
VII. Start a Mysql Cluster
The startup sequence is management nodes, data nodes, and SQL nodes.
1. Management node startup
// Manage node startup // The first startup [root@192.168.10.10] # ndb_mgmd-f/var/lib/mysql-cluster/config. ini // start [root@192.168.10.10] # ndb_mgmd later // config. ini modify to start [root@192.168.10.10] # ndb_mgmd-f/var/lib/mysql-cluster/config. ini // boot successful: MySQL Cluster Management Server mysql-5.1.72 ndb-7.1.29 root@192.168.10.10 // view the status [] # ndb_mgmndb_mgm> show the following information, the status of each node [ndbd (NDB)] 2 node (s) id = 2 @ 192.168.10.20 (mysql-5.1.72 ndb-7.1.29, Nodegroup: 0, *) id = 4 @ 192.168.10.40 (mysql-5.1.72, Nodegroup: 0) [ndb_mgmd (MGM)] 1 node (s) id = 1 @ 192.168.10.10 (mysql-5.1.72 ndb-7.1.29) [mysqld (API)] 2 node (s) id = 3 (not connected, accepting connect from 192.168.10.30) id = 5 (not connected, accepting connect from 192.168.10.50)
2. Data Node startup
// Data node start the first data node start with-initial other do not need [root@192.168.10.20] # ndbd-initial // output the following success 23:36:23 [ndbd] INFO -- Angel connected' 192. 168.10.10: 1186 '2017-12-25 23:36:23 [ndbd] INFO -- Angel allocated nodeid: 2
Same as 192.168.10.40
3. SQL node startup
// SQL node start [root@192.168.10.20] # mysqld_safe // output as follows success 131226 01:02:43 mysqld_safe Logging to '/var/lib/mysql/localhost. localdomain. err '. 131226 01:02:43 mysqld_safe Starting mysqld daemon with databases from/var/lib/mysql
192.168.10.50 is the same as above
If the following prompt appears during startup
// SQL node starts 131226 01:01:50 mysqld_safe Logging to '/var/lib/mysql/localhost. localdomain. err'. 131226 01:01:51 mysqld_safe A mysqld process already exists
Manually kill mysql process and restart
8. Verification
Create a database on one of the SQL nodes and create a test table to insert data. Then, log on to the other SQL node to check whether the synchronization is successful. Otherwise, the synchronization fails.
9. Disable the Cluster
1. To disable Management Nodes and data nodes, run the following command in the management node:
[root@192.168.10.10]# ndb_mgm -e shutdownNode 2: Cluster shutdown initiatedNode 4: Cluster shutdown initiatedNode 4: Node shutdown completed.Node 2: Node shutdown completed.3 NDB Cluster node(s) have shutdown.Disconnecting to allow management server to shutdown.
2. Then close the SQL node and run it in two nodes:
[root@192.168.10.30]# service mysql stop
10. Important Notes
1. When creating a table, you must use ENGINE = NDB or ENGINE = NDBCLUSTER to specify the NDB Cluster Storage ENGINE or use the ALTERTABLE option to change the table storage ENGINE.
2. The NDB table must have a primary key. Therefore, the primary key must be defined during table creation. Otherwise, the NDB storage engine will automatically generate an implicit primary key.
3. the user permission table of the SQL node is still saved using the MYISAM storage engine. Therefore, MySql users created on an SQL node can only access this node. If the same user is used to access other SQL nodes, the user needs to be appended to the corresponding SQL node.
XI. Others
First, let's see what packages are installed:
If an error occurs during installation, delete the reinstallation.
Rpm-qa | grep MySQL
And unmount these packages.
Rpm-e MySQL-server *
Rpm-e MySQL-client *