MySQL Cluster backup and recovery

Source: Internet
Author: User
Tags localhost mysql mysql backup

1. Back up data on the Management node.
Ndb_mgm> start backup
Ndb_mgm> shutdown
Ndb_mgm> exit
2. Delete SQL node data.
Drop database TEST_CLUSTER;
3. Disable the MYSQLD server.
[Root @ localhost bin] # service mysqld stop
Shutting down MySQL... SUCCESS!
4. Restart all nodes in sequence.
[Root @ localhost mysql] # ndb_mgmd-f/etc/config. ini -- reload
[Root @ localhost data] # ndbd -- initial
I found that if this -- initial option is not included, the restoration will fail.
[Root @ localhost bin] # service mysqld start
// I used the 7.0.8a rpm to install <B> service mysqld start </B> ,,
// [Root @ localhost ~] # Mysqld_safe &

4. Perform restoration on the NDBD node. (Each node has to be executed once because the data is distributed across two nodes)
First node:
[Root @ localhost BACKUP] #/usr/local/mysql/bin/ndb_restore-n3-b4-r-m -- backup_path =/usr/local/mysql/data/BACKUP -4/
The-r switch is a set of records.
-M is metadata. It is the SCHEMA of the table and database.
Nodeid = 3
Backup Id = 4
Backup path =/usr/local/mysql/data/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 37 tuples and 0 log entries

NDBT_ProgramExit: 0-OK
The second node:
[Root @ localhost BACKUP-1] #/usr/local/mysql/bin/ndb_restore-n4-b4-r -- backup_path =/usr/local/mysql/data/BACKUP -4/
Nodeid = 4
Backup Id = 4
Backup path =/usr/local/mysql/data/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


This is done.
5. check whether there is any data. For the sake of security.
Mysql> show databases;
+ -------------------- +
| Database |
+ -------------------- +
| Information_schema |
| Mysql |
| Test |
+ -------------------- +
3 rows in set (0.00 sec)
Database not recovered?
MYSQL must now create a SCHEMA again.

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 |
|... |
+ ------------------------------ +
27 rows in set (0.11 sec)

Mysql> select * from cs_comment;
Empty set (0.00 sec)

However, the MYSQL backup program can only perform full backup.
[Root @ localhost BACKUP] # du-h
76 K./BACKUP-2
96 K./BACKUP-6
180 K./BACKUP-4
172 K./BACKUP-3
76 K./BACKUP-1
60 K./BACKUP-5
668 K.

6. Pay attention to this issue when restoring the NDBD node.
Because the undo and data files (that is, the table data saved to the disk) are not automatically deleted when the NDBD node is started in the -- initial mode, you must manually perform the RM operation on each NDBD node:

[Root @ node239 ndb_6_fs] # rm-rf *. dat

Then start the backup.
-M should be added during backup on the MASTER.
Add-d to SLAVE and do not enable-m.

The procedure is 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 -1/
Nodeid = 3
Backup Id = 1
Backup path =/usr/local/mysql/data/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 (10) fragment 0
Restored 26 tuples and 0 log entries

NDBT_ProgramExit: 0-OK

Other operations on SLAVE:

[Root @ node239 ndb_6_fs] #/usr/local/mysql/bin/ndb_restore-n6-b1-r-d -- backup_path =/usr/local/mysql/data/BACKUP -1/
Nodeid = 6
Backup Id = 1
Backup path =/usr/local/mysql/data/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 (10) fragment 3
Restored 20 tuples and 0 log entries

NDBT_ProgramExit: 0-OK

 

-D switch means:
-D, -- no-restore-disk-objects
Dont restore disk objects (tablespace/logfilegroups etc)
Ignore tablespaces and group spaces

Exception:
[Root @ localhost ~] # Ndb_restore-n2-b2-r-m -- backup_path =/var/lib/mysql-cluster/BACKUP-2
Nodeid = 2
Backup Id = 2
Backup path =/var/lib/mysql-cluster/BACKUP-2
Opening file '/var/lib/mysql-cluster/BACKUP-2/BACKUP-2.2.ctl'
Backup version in files: ndb-6.3.11 ndb version: mysql-5.1.37 ndb-7.0.8
Stop GCP of Backup: 0
Configuration error: Error: cocould not alloc node id at 192.168.8.120 port 1186: Connection done from wrong host ip 192.168.8.121.
Failed to initialize consumers

NDBT_ProgramExit: 1-Failed
Solution: manage node configuration file Addition
[Mysqld]
// Empty Node

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.