MySQL Cluster- initial backup and recovery test

Reference document   http://blog.chinaunix.net/uid-20639775-id-1617795.html
 http://xxtianxiaxing.iteye.com/blog/563063
 http://dev.mysql.com/doc/refman/5.0/ EN / MySQL-Cluster-SINGLE-User-mode.html
 http://www.mysqlab.net/knowledge/kb/detail/topic/backup/id/8309

 

 

 

 

In  http://blog.csdn.net/mchdba/article/details/10544585  extended test section inside the eighth

 

 

8.1 sql above input data node:  establishing a test database tables and


 the CREATE DATABASE BG;

 the CREATE TABLE BGT1 (the INT ID, `name` VARCHAR (20 is), a PRIMARY KEY (` id`)) ENGINE = NDBCLUSTER;

 the INSERT the INTO BGT1 the VALUES (. 1 , 'zhang1'), (2 , 'zhang2'), (3, 'zhang3'), (4, 'zhang4');

 

 

  

 8.2 管理节点上面,开始备份
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 reinserted several data (in order to maintain and formal environment as close as possible, the insertion of intermediate data interspersed flush logs operation!)

The INTO BGT1 the VALUES the INSERT (. 5, 'zhang5'), (. 6, 'zhang6'); 
the flush logs;
the INSERT the INTO BGT1 the VALUES (. 7, 'zhang7'), (. 8, 'zhang8');
     
8.4 SQL delete node data .
mysql> drop database bg;

Query OK, 2 rows affected (6.16 sec)

 

 

8.5 关闭MYSQLD服务器。[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
  [确定]
[1]+  Done                    /usr/local/mysql/bin/mysqld_safe
[root@banggo data]# 
[root@banggo data]# /etc/rc.d/init.d/mysqld stop
Shutting down MySQL....                                    [确定]
[root@banggo data]# 

8.6 重新启动节点
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-the NDB 7.2.4


8.7 Restart data node
ndbd - --initial   


8.8 above to recover 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 / BACKUP-1 /

 

 

Which backup_path below the root directory of the default data node (look for a long time, first thought in the configuration file inside)

 

 

 

第一步骤 -m操作   [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/BACKUP-1/
Nodeid = 4
Backup Id = 1
backup path = /var/lib/mysql-cluster/BACKUP/BACKUP-1/
Opening file '/var/lib/mysql-cluster/BACKUP/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 `bgt1`
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 第二步骤 -r操作(如果有N个node,则需要执行N次)
[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/BACKUP-1/
Nodeid = 4
Backup Id = 1
backup path = /var/lib/mysql-cluster/BACKUP/BACKUP-1/
Opening file '/var/lib/mysql-cluster/BACKUP/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/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)
Error the Temporary: 1220: REDO log Files Overloaded (Increase FragmentLogFileSize)
the Temporary error: 1220: REDO log Files Overloaded (Increase FragmentLogFileSize)
in the implementation of the operation error -r

[ok] Phenom Big Brother is due to REDO log file is too small to add big, does not affect the recovery effect. This reference to the above http://bugs.mysql.com/bug.php?id=19651 people say so.



MySQL> Show Databases;
+ -------------------- +
| Database |
+ ------------------- - +
| information_schema |
| MySQL |
| the NDB |
| ndbinfo |
| performance_schema |
| the Test |
+ -------------------- +
6 rows in the SET (0.00 sec)
- no library? It seems to rebuild the


mysql> create database bg; - reconstruction
The OK Query, Row affected. 1 (0.06 sec)


MySQL> BG use
Database changed
MySQL> Show Tables; - OK, see table
+ -------------- +
| Tables_in_bg |
+ - + ------------
| BGT1 |
+ -------------- +
1 Row in the SET (0.00 sec)


MySQL> the SELECT * from BGT1; - data recovered a
+ ---- + -------- +
| the above mentioned id | name |
+ ---- + -------- +
| 3 | zhang3 |
| 1 | zhang1 |
| 2 | zhang2 |
| 4 | zhang4 |
+ ---- + -------- +
4 rows in the SET (0.01 sec)


8.10 mysqld to find a node in the management node into single-user mode, and then start the sql node, start the mysqld nodes and log in to find the maximum value of the epoch of
the ndb_mgm> the ENTER the USER the MODE SINGLE 10;
Single the User entered the MODE
IS granted for the API Node Access 10 only.
The ndb_mgm> 

MySQL> the SELECT @LASTEPOCH: = MAX (Epoch) the FROM mysql.ndb_apply_status;
+ ---------------------- - +
| @LASTEPOCH: = MAX (Epoch) |
+ ------------------------ +
| 793,593,992,183,807 |
+ ------- + -----------------
. 1 in Row SET (0.04 sec)

depending on the value of the epoch, to find the location and file name of the binary log


MySQL> the SELECT the pOSITION, @FIRSTFILE: the fILE =
- > 
-> the FROM mysql.ndb_binlog_index
-> 
-> the WHERE Epoch> @LASTEPOCH
-> 
-> the ORDER BY ASC Epoch
-> 
-> LIMIT 1;
Empty the SET (0.03 sec)

8.11 based on recovery point in time
to find out when the need to use recovery other binary log files except the first log file
SELECT DISTINCT file 
Mysql.ndb_binlog_index the FROM
the WHERE Epoch> @LASTEPOCH 
the AND File <> @FIRSTFILE 
the ORDER BY File;


then the binary log recovery:
the mysqlbinlog -H the --set-charset = "UTF8" --start -D-position = 829 ./mysql -bin.000012 | grep -v "RELOAD DATABASE" | BG MySQL
mysqlbinlog -H --set-charset = "utf8" -D --stop-datetime = "2012-07-18 13:30:00" ./mysql -bin.0000013 | grep -v "RELOAD DATABASE" | mysql bg


after the recovery is complete, exit single-user mode, and start another node sql
the ndb_mgm> eXIT sINGLE the uSER the mODE;
Exiting the mODE sINGLE in the user Progress.
the Use ALL to the STATUS or SHOW SINGLE the when the User has the MODE See the Exited been.
the ndb_mgm>


to enter the mysql node, found the data has been restored.

Guess you like

Origin blog.csdn.net/csdnhsh/article/details/91410799