MySQL NDB cluster backup database and restore DATABASE methods _mysql

Source: Internet
Author: User
Tags localhost mysql create database

1, on the management node for backup.
ndb_mgm> Start Backup nowait
Ndb_mgm> Node 3:backup 4 started from Node 1
Node 3:backup 4 started from Node 1 completed
startgcp:43010 stopgcp:43013
#Records: 2138 #LogRecords: 0
data:53068 bytes log:0 bytes

ndb_mgm> shutdown
Node 3:cluster shutdown initiated
Node 4:cluster shutdown initiated
Node 4:node shutdown completed.
Node 3:node shutdown completed.
NDB Cluster node (s) have shutdown.
Disconnecting to allow Management Server to shutdown.
Ndb_mgm> exit
2, delete the SQL node data.
DROP DATABASE Test_cluster;
, and shut down the MYSQLD server.
[root@localhost bin]# service mysqld Stop
Shutting down MySQL ... success!
3, restart all nodes in order.
[Root@localhost mysql]#/usr/local/mysql/ndb_mgmd-f/etc/config.ini
[Root@localhost data]#/usr/local/mysql/bin/ndbd--initial
I find that if you do not take this--initial option, the recovery will fail.
[root@localhost bin]# Service mysqld start
Starting MySQL success!
4, on the NDBD node to restore. (Each node has to be executed once because the data is dispersed over two nodes)
First node:
[Root@localhost backup]#/usr/local/mysql/bin/ndb_restore-n3-b4-r-M--backup_path=/usr/local/mysql/data/backup/ backup-4/
The-r switch is a collection of records.
-M is meta data. is the schema of tables and libraries.
Nodeid = 3
Backup Id = 4
Backup Path =/usr/local/mysql/data/backup/backup-4/
NDB version in Backup Files:version 5.1.21
Connected to ndb!!
Successfully restored table ' Test_cluster/def/lk4_test '
...
Successfully created index ' PRIMARY ' on ' lk4_test '
...
_____________________________________________________
Processing data in Table:test_cluster/def/lk4_test54) fragment 1
_____________________________________________________
...
Restored Notoginseng tuples and 0 log entries

ndbt_programexit:0-OK
Second node:
[Root@localhost backup-1]#/usr/local/mysql/bin/ndb_restore-n4-b4-r--backup_path=/usr/local/mysql/data/backup/ backup-4/
Nodeid = 4
Backup Id = 4
Backup Path =/usr/local/mysql/data/backup/backup-4/
NDB version in Backup Files:version 5.1.21
Connected to ndb!!
_____________________________________________________
Processing data in Table:sys/def/ndb$events_0 (1) Fragment 1
_____________________________________________________
Processing data in Table:mysql/def/ndb_apply_status (4) Fragment 1
_____________________________________________________
Processing data in Table:mysql/def/ndb$blob_2_3 (3) Fragment 1
_____________________________________________________
Processing data in table:test/def/t11 (5) Fragment 1
_____________________________________________________
Processing data in Table:sys/def/systab_0 (0) Fragment 1
_____________________________________________________
Processing data in Table:mysql/def/ndb_schema (2) Fragment 1
Restored 2 tuples and 0 log entries

ndbt_programexit:0-OK

Done here.
5, to see if there is data, for security reasons.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| Information_schema |
| MySQL |
| Test |
+--------------------+
Rows in Set (0.00 sec)
Database not recovered?
MySQL now has to re-establish the schema.

mysql> CREATE DATABASE Test_cluster;
Query OK, 1 row affected (0.33 sec)

mysql> use Test_cluster;
Database changed
Mysql> Show tables;
+------------------------------+
| Tables_in_test_cluster |
+------------------------------+
| Lk4_test |
| ... |
+------------------------------+
Rows in Set (0.11 sec)

Mysql> select * from Cs_comment;
Empty Set (0.00 sec)

However, MySQL's backup program can now only have a full backup.
[Root@localhost backup]# Du-h
K./backup-2
K./backup-6
K./backup-4
K./backup-3
K./backup-1
K./backup-5
K.
6, in the NDBD node to recover when there is a need to pay attention to the problem.
Because the NDBD node does not automatically delete the Undo and data files (that is, the table data that is saved to disk) when it is started in--initial mode, you have to manually perform RM operations on each NDBD node:

[root@node239 ndb_6_fs]# RM-RF *.dat

Then start the backup.
The-m switch is added when backing up on master.
On the slave to add-D and do not-m switch.

The specific steps are as follows:
MASTER:

[Root@localhost ndb_3_fs]#/usr/local/mysql/bin/ndb_restore-n3-b1-r-M--backup_path=/usr/local/mysql/data/backup/ backup-1/
Nodeid = 3
Backup Id = 1
Backup Path =/usr/local/mysql/data/backup/backup-1/
NDB version in Backup Files:version 5.1.21
Connected to ndb!!
Creating logfile Group:lg_1...done
Creating Tablespace:ts_1...done
Creating datafile "Data_1.dat" ... done
Creating Undofile "Undo_1.dat" ... done
Successfully restored table ' test/def/t11 '
Successfully restored table event repl$test/t11
_____________________________________________________
Processing data in Table:sys/def/ndb$events_0 (1) Fragment 0
_____________________________________________________
Processing data in Table:mysql/def/ndb$blob_2_3 (3) Fragment 0
_____________________________________________________
Processing data in Table:sys/def/systab_0 (0) fragment 0
_____________________________________________________
Processing data in Table:mysql/def/ndb_schema (2) Fragment 0
_____________________________________________________
Processing data in Table:mysql/def/ndb_apply_status (4) Fragment 0
_____________________________________________________
Processing data in table:test/def/t11 (a) fragment 0
Restored tuples and 0 log entries

ndbt_programexit:0-OK

Other actions on the slave:

[root@node239 ndb_6_fs]#/usr/local/mysql/bin/ndb_restore-n6-b1-r-D--backup_path=/usr/local/mysql/data/backup/ backup-1/
Nodeid = 6
Backup Id = 1
Backup Path =/usr/local/mysql/data/backup/backup-1/
NDB version in Backup Files:version 5.1.21
Connected to ndb!!
_____________________________________________________
Processing data in Table:sys/def/ndb$events_0 (1) Fragment 3
_____________________________________________________
Processing data in Table:mysql/def/ndb$blob_2_3 (3) Fragment 3
_____________________________________________________
Processing data in Table:sys/def/systab_0 (0) Fragment 3
_____________________________________________________
Processing data in Table:mysql/def/ndb_schema (2) Fragment 3
_____________________________________________________
Processing data in Table:mysql/def/ndb_apply_status (4) Fragment 3
_____________________________________________________
Processing data in table:test/def/t11 (a) Fragment 3
Restored tuples and 0 log entries

ndbt_programexit:0-OK


The-D switch means:
-D,--no-restore-disk-objects
Dont Restore disk objects (Tablespace/logfilegroups etc)
Ignore both table and grouping spaces

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.