MySQLCluster-backup recovery preliminary test _ MySQL

Source: Internet
Author: User
MySQLCluster-backup recovery preliminary test bitsCN.com

MySQL Cluster-backup recovery preliminary test

Data input on the SQL node:

Create a test database and table

Create database bg;

Create table bgt1 (id INT, 'name' VARCHAR (20), primary key ('id') ENGINE = NDBCLUSTER;

Insert into bgt1 VALUES (1, 'hangzhou1'), (2, 'hangzhou2'), (3, 'hangzhou3'), (4, 'hangzhou4 ');

8.2 start backup on the management node

Ndb_mgm> start backup

Waiting for completed, this may take several minutes

Node 4: Backup 1 started from node 1

Node 4: Backup 1 started from node 1 completed

StartGCP: 184725 StopGCP: 184772

# Records: 722078 # LogRecords: 0

Data: 287345616 bytes Log: 0 bytes

Ndb_mgm>

8.3 insert several data records again (to keep as close as possible to the official environment, the flush logs operation is interspersed with the inserted data !)

Insert into bgt1 VALUES (5, 'hangzhou5'), (6, 'hangzhou6 ');

Flush logs;

Insert into bgt1 VALUES (7, 'hangzhou7'), (8, 'hangzhou8 ');

8.4 delete SQL node data.

Mysql> drop database bg;

Query OK, 2 rows affected (6.16 sec)

8.5 disable the MYSQLD server.

[Root @ banggo data] #/etc/rc. d/init. d/mysqld stop

Shutting down MySQL... 120718 18:58:11 mysqld_safe mysqld from pid file/usr/local/mysql/data/banggo. local. pid ended

[OK]

[1] + Done/usr/local/mysql/bin/mysqld_safe

[Root @ banggo data] #

[Root @ banggo data] #/etc/rc. d/init. d/mysqld stop

Shutting down MySQL... [OK]

[Root @ banggo data] #

8.6 restart a node

Ndb_mgm> shutdown

Node 4: Cluster shutdown initiated

Node 4: Node shutdown completed.

2 NDB Cluster node (s) have shutdown.

Disconnecting to allow management server to shutdown.

Ndb_mgm> exit

[Root @ banggo mysql-cluster] # ndb_mgmd-f/usr/local/mysql/cluster-conf/config. ini -- reload

MySQL Cluster Management Server mysql-5.5.19 ndb-7.2.4

8.7 restart a data node

Ndbd -- initial

8.8 restore data on the data node.

/Home/mysql-cluster-gpl-7.2.4-linux2.6-x86_64/bin/ndb_restore-e-c 10.100.200.36-n 4-B 1-m -- backup_path =/var/lib/mysql-cluster/BACKUP-1/

Among them, backup_path is under the root directory of the default data node (found for a long time, initially thought in the configuration file)

Step 1-m operation

[Root @ test-db-20053 BACKUP-1] #/home/mysql-cluster-gpl-7.2.4-linux2.6-x86_64/bin/ndb_restore-e-c 10.100.200.36-n 4-B 1-m -- backup_path =/var/lib/mysql- cluster/BACKUP-1/

Nodeid = 4

Backup Id = 1

Backup path =/var/lib/mysql-cluster/BACKUP-1/

Opening file '/var/lib/mysql-cluster/BACKUP-1/BACKUP-1.4.ctl'

File size 61160 bytes

Backup version in files: ndb-6.3.11 ndb version: mysql-5.5.19 ndb-7.2.4

Stop GCP of Backup: 184771

Connected to ndb !!

Successfully restored table 'test/def/t2'

Successfully restored table event REPL $ test/t2

Successfully restored table 'bg/def/# sql-303d_2'

Successfully restored table event REPL $ bg/# sql-303d_2

Successfully restored table 'bg/def/# sql-51f0_3'

Successfully restored table event REPL $ bg/# sql-51f0_3

Successfully restored table 'test/def/t11'

Successfully restored table event REPL $ test/t11

Successfully restored table 'ndb/def/ndborder_goods'

Successfully restored table event REPL $ ndb/ndborder_goods

Successfully restored table 'bg/def/bgt1'

Successfully restored table event REPL $ bg/bgt1

Successfully restored table 'test/def/ndborder_info_history'

Successfully restored table event REPL $ test/ndborder_info_history

Successfully restored table 'MySQL/def/ndb_schema'

Successfully restored table event REPL $ mysql/ndb_schema

Successfully restored table 'MySQL/def/ndb_apply_status'

Successfully restored table event REPL $ mysql/ndb_apply_status

Successfully restored table 'ndb/def/ndbtest'

Successfully restored table event REPL $ ndb/ndbtest

Successfully created index 'primary' on 'ndborder _ info_history'

Successfully created index 'UNIQ _ order_ OS 'on 'ndborder _ goods'

Successfully created index 'is _ update' on 'ndborder _ info_history'

Successfully created index 'primary' on '# sql-51f0_3'

Successfully created index 'sku _ sn 'on 'ndborder _ goods'

Successfully created index 'primary' on 'bg1'

Successfully created index 'exchange _ from 'on 'ndborder _ goods'

Successfully created index 'addtime' on 'ndborder _ info_history'

Successfully created index 'relating _ return_sn 'on 'ndborder _ info_history'

Successfully created index 'primary' on 'ndborder _ goods'

Successfully created index 'Order _ from 'on 'ndborder _ info_history'

Successfully created index 'Order _ out_sn 'on 'ndborder _ info_history'

Successfully created index 'primary' on '# sql-303d_2'

Successfully created index 'Order _ status' on 'ndborder _ info_history'

Successfully created index 'user _ id' on 'ndborder _ info_history'

Successfully created index 'UNIQ _ order_ OS $ unique 'on 'ndborder _ goods'

Successfully created index 'Order _ sn 'on 'ndborder _ goods'

NDBT_ProgramExit: 0-OK

[Root @ test-db-20053 BACKUP-1] #

8.9 Step 2-r operation (if there are N nodes, perform N operations)

[Root @ test-db-20053 BACKUP-1] #/home/mysql-cluster-gpl-7.2.4-linux2.6-x86_64/bin/ndb_restore-e-c 10.100.200.36-n 4-B 1-r -- backup_path =/var/lib/mysql- cluster/BACKUP-1/

Nodeid = 4

Backup Id = 1

Backup path =/var/lib/mysql-cluster/BACKUP-1/

Opening file '/var/lib/mysql-cluster/BACKUP-1/BACKUP-1.4.ctl'

File size 61160 bytes

Backup version in files: ndb-6.3.11 ndb version: mysql-5.5.19 ndb-7.2.4

Stop GCP of Backup: 184771

Connected to ndb !!

Opening file '/var/lib/mysql-cluster/BACKUP-1/BACKUP-1-0.4.Data'

File size 287834112 bytes

_____________________________________________________

Processing data in table: test/def/t2 (20) fragment 0

_____________________________________________________

Processing data in table: bg/def/# sql-303d_2 (34) fragment 0

_____________________________________________________

Processing data in table: bg/def/# sql-51f0_3 (32) fragment 0

_____________________________________________________

Processing data in table: mysql/def/NDB $ BLOB_7_3 (8) fragment 0

_____________________________________________________

Processing data in table: test/def/t11 (11) fragment 0

_____________________________________________________

Processing data in table: ndb/def/ndborder_goods (12) fragment 0

_____________________________________________________

Processing data in table: ndb/def/NDB $ BLOB_12_13 (13) fragment 0

_____________________________________________________

Processing data in table: mysql/def/ndb_index_stat_head (4) fragment 0

_____________________________________________________

Processing data in table: sys/def/NDB $ EVENTS_0 (3) fragment 0

_____________________________________________________

Processing data in table: sys/def/SYSTAB_0 (2) fragment 0

_____________________________________________________

Processing data in table: mysql/def/ndb_index_stat_sample (5) fragment 0

_____________________________________________________

Processing data in table: bg/def/bgt1 (36) fragment 0

_____________________________________________________

Processing data in table: test/def/ndborder_info_history (21) fragment 0

Temporary error: 1220: REDO log files overloaded (increase FragmentLogFileSize)

Temporary error: 1220: REDO log files overloaded (increase FragmentLogFileSize)

Temporary error: 1220: REDO log files overloaded (increase FragmentLogFileSize)

Temporary error: 1220: REDO log files overloaded (increase FragmentLogFileSize)

Temporary error: 1220: REDO log files overloaded (increase FragmentLogFileSize)

Temporary error: 1220: REDO log files overloaded (increase FragmentLogFileSize)

Temporary error: 1220: REDO log files overloaded (increase FragmentLogFileSize)

Temporary error: 1220: REDO log files overloaded (increase FragmentLogFileSize)

Temporary error: 1220: REDO log files overloaded (increase FragmentLogFileSize)

Temporary error: 1220: REDO log files overloaded (increase FragmentLogFileSize)

An error is reported during the-r operation.

[OK] Feihong said that because the REDO log file is too small to be increased, it does not affect the recovery effect. Reference to http://bugs.mysql.com/bug.php? Id = 19651.

Mysql> show databases;

+ -------------------- +

| Database |

+ -------------------- +

| Information_schema |

| Mysql |

| Ndb |

| Ndbinfo |

| Performance_schema |

| Test |

+ -------------------- +

6 rows in set (0.00 sec)

-- No database? It seems that it is about to be rebuilt.

Mysql> create database bg; -- rebuilding

Query OK, 1 row affected (0.06 sec)

Mysql> use bg

Database changed

Mysql> show tables; -- OK, see the following table.

+ -------------- +

| Tables_in_bg |

+ -------------- +

| Bgt1 |

+ -------------- +

1 row in set (0.00 sec)

Mysql> select * from bgt1; -- the data is recovered.

+ ---- + -------- +

| Id | name |

+ ---- + -------- +

| 3 | zhang3 |

| 1 | zhang1 |

| 2 | zhang2 |

| 4 | zhang4 |

+ ---- + -------- +

4 rows in set (0.01 sec)

8.10 find a mysqld node, go to single-user mode on the management node, start the SQL node, start the mysqld node, and log in to find the maximum epoch value

Ndb_mgm> enter single user mode 10;

Single user mode entered

Access is granted for API node 10 only.

Ndb_mgm>

Mysql> SELECT @ LASTEPOCH: = MAX (epoch) FROM mysql. ndb_apply_status;

+ ------------------------ +

| @ LASTEPOCH: = MAX (epoch) |

+ ------------------------ +

| 1, 793593992183807 |

+ ------------------------ +

1 row in set (0.04 sec)

Locate the location and file name of the binary log based on the epoch value

Mysql> select position, @ FIRSTFILE: = FILE

->

-> FROM mysql. ndb_binlog_index

->

-> WHERE epoch> @ LASTEPOCH

->

-> Order by epoch ASC

->

-> LIMIT 1;

Empty set (0.03 sec)

8.11 restore by time point

Find the binary log files other than the first log file to be used for recovery.

Select distinct File

FROM mysql. ndb_binlog_index

WHERE epoch> @ LASTEPOCH

AND File <> @ FIRSTFILE

Order by File;

Then restore the binary log:

Mysqlbinlog-H -- set-charset = "utf8"-D -- start-position = 829./mysql-bin.000012 | grep-v "reload database" | mysql bg

Mysqlbinlog-H -- set-charset = "utf8"-D -- stop-datetime = "13:30:00"./mysql-bin.0000013 | grep-v "reload database" | mysql bg

After the restoration is complete, exit the single-user mode and start another SQL node.

Ndb_mgm> exit single user mode;

Exiting single user mode in progress.

Use all status or SHOW to see when single user mode has been exited.

Ndb_mgm>

Go to the mysql node and check that the data has been recovered.

BitsCN.com

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.