Mysql-cluster is the automatic recovery function of the data after the fault node is restored to normal.
The lab environment contains two data nodes: on 46, 472 servers
Ndb_mgm> Show
Connected to Management Server at:localhost:1186
[NDBD (NDB)] 2 node (s)
id=2 @10.186.20.46 (mysql-5.6.25 ndb-7.4.7, nodegroup:0)
Id=3 @10.186.20.47 (mysql-5.6.25 ndb-7.4.7, nodegroup:0, *)
[NDB_MGMD (MGM)] 1 node (s)
Id=1 @10.186.20.45 (mysql-5.6.25 ndb-7.4.7)
[Mysqld (API)] 2 node (s)
Id=4 @10.186.20.46 (mysql-5.6.25 ndb-7.4.7)
Id=5 @10.186.20.47 (mysql-5.6.25 ndb-7.4.7)
Ndb_mgm>
The data automatic repair mentioned here refers to, after one node crashes, the other node provides services to the outside, during the crash all data changes (NDB table), can be resumed in the crash node and, if the cluster, automatically synchronize the data.
The experimental process is as follows:
1, check the current data (TEST.A table is NDB table)
46:
Mysql> select * from A;
+--+
| ID |
+--+
| 1 |
| 2 |
+--+
2 rows in Set (0.00 sec)
47:
Mysql> select * from A;
+--+
| ID |
+--+
| 1 |
| 2 |
+--+
2 rows in Set (0.01 sec)
2, stop the Sql,data node on 47
[Email protected] mysql3307]# Ps-ef|grep mysqld
Root 2216 0 12:18 pts/0 00:00:00/bin/sh./bin/mysqld_safe–defaults-file=./my.cnf
MySQL 2385 2216 1 12:18 pts/0 00:01:54/opt/mysql_s/bin/mysqld–defaults-file=./my.cnf–basedir=/opt/mysql_s/–datadir=/ opt/mysql_s/data–plugin-dir=/opt/mysql_s//lib/plugin–user=mysql–log-error=/opt/mysql_s/data/10-186-20-47.err– pid-file=/opt/mysql_s/data/10-186-20-47.pid–socket=/tmp/mysql3302.sock–port=3302
Root 4979 4641 0 12:37 pts/1 00:00:00/bin/sh./bin/mysqld_safe–defaults-file=./my.cnf
MySQL 5157 4979 0 12:37 pts/1 00:00:12/usr/local/mysql3307/bin/mysqld–defaults-file=./my.cnf–basedir=/usr/local/ mysql3307–datadir=/usr/local/mysql3307/data–plugin-dir=/usr/local/mysql3307/lib/plugin–user=mysql–log-error=/ usr/local/mysql3307/data/10-186-20-47.err–pid-file=/usr/local/mysql3307/data/10-186-20-47.pid–socket=/tmp/ mysql3307.sock–port=3307
Root 14253 4641 0 14:44 pts/1 00:00:00 grep mysqld
[[email protected] mysql3307]# kill 2385
[Email protected] mysql3307]#
[Email protected] mysql3307]# Ps-ef|grep NDB
Root 7810 1 0 13:13? 00:00:03 ndbd–ndb-connectstring=10.186.20.45:1186
Root 7811 7810 1 13:13? 00:01:28 ndbd–ndb-connectstring=10.186.20.45:1186
Root 14312 4641 0 14:44 pts/1 00:00:00 grep NDB
[[email protected] mysql3307]# kill 7811 7810
[Ro[email protected] mysql3307]#
To see if the status is not available through the Manage Node show command
Ndb_mgm> Show
[NDBD (NDB)] 2 node (s)
id=2 @10.186.20.46 (mysql-5.6.25 ndb-7.4.7, nodegroup:0, *)
Id=3 (not connected, accepting connect from 10.186.20.47)
[NDB_MGMD (MGM)] 1 node (s)
Id=1 @10.186.20.45 (mysql-5.6.25 ndb-7.4.7)
[Mysqld (API)] 2 node (s)
Id=4 @10.186.20.46 (mysql-5.6.25 ndb-7.4.7)
Id=5 (not connected, accepting connect from 10.186.20.47)
Ndb_mgm>
3, insert on 46 node, delete operation.
mysql> INSERT into a select 3;
Query OK, 1 row Affected (0.00 sec)
Records:1 duplicates:0 warnings:0
Mysql> Delete from a where id=1;
Query OK, 1 row affected (0.02 sec)
Mysql>
4, turn on the Sql,data node on 47
[Email protected] mysql_s]#./BIN/MYSQLD_SAFE–DEFAULTS-FILE=./MY.CNF &
[2] 14408
[Email protected] mysql_s]# 150825 14:46:26 mysqld_safe Logging to '/opt/mysql_s/data/10-186-20-47.err '.
150825 14:46:26 Mysqld_safe starting mysqld daemon with databases From/opt/mysql_s/data
[Email protected] mysql_s]#
[Email protected] mysql_s]#
[Email protected] mysql_s]# NDB
NDBD NDBMTD
[Email protected] mysql_s]# ndbd–ndb-connectstring=10.186.20.45:1186
2015-08-25 14:46:54 [NDBD] Info–angel connected to ' 10.186.20.45:1186 '
2015-08-25 14:46:54 [NDBD] Info–angel allocated Nodeid:3
[Email protected] mysql_s]#
5, check whether the data is synchronized on 47
Mysql> select * from A;
+--+
| ID |
+--+
| 2 |
| 3 |
+--+
2 rows in Set (0.00 sec)
The data has been automatically repaired.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Mysql-cluster Data Auto-repair (write other node data during node crash)