Mysql cluster数据备份和恢复
首先在管理节点备份数据,备份数据存放在每个数据节点$datadir/BACKUP目录下:
ndb_mgm> start backup 20121019 nowait;
ndb_mgm> Node 2: Backup 20121019 started from node 1
Node 2: Backup 20121019 started from node 1 completed
StartGCP: 25569 StopGCP: 25572
#Records: 2155 #LogRecords: 0
Data: 90892 bytes Log: 0 bytes
ndb_mgm> shutdown
Node 2: Cluster shutdown initiated
Node 3: Cluster shutdown initiated
3 NDB Cluster node(s) have shutdown.
Disconnecting to allow management server to shutdown.
Node 3: Node shutdown completed.
ndb_mgm> quit
[root@vmhost02 ~]# ndb_mgmd -f /var/lib/mysql/config.ini --reload
MySQL Cluster Management Server mysql-5.5.27 ndb-7.2.8
[root@vmhost02 ~]# ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: 192.168.163.110:1186
Cluster Configuration
---------------------
[ndbd(NDB)]2 node(s)
id=2@192.168.163.140(mysql-5.5.27 ndb-7.2.8, Nodegroup: 0, Master)
id=3@192.168.163.170(mysql-5.5.27 ndb-7.2.8, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1@192.168.163.110(mysql-5.5.27 ndb-7.2.8)
[mysqld(API)]3 node(s)
id=4 (not connected, accepting connect from 192.168.163.160)
id=5 (not connected, accepting connect from 192.168.163.110)
id=6 (not connected, accepting connect from any host)
id=7 (not connected, accepting connect from any host)
在一个数据节点开始数据恢复
[root@vmhost05 BACKUP-20121019]# ndbd --ndb-connectstring=192.168.163.110:1186 --initial
2012-10-19 10:24:25 [ndbd] INFO-- Angel connected to '192.168.163.110:1186'
2012-10-19 10:24:25 [ndbd] INFO-- Angel allocated nodeid: 2
[root@vmhost05 BACKUP-20121019]# ndb_restore -c 192.168.163.110:1186 -n 2 -b 20121019 -m -r --backup-path=/var/lib/mysql/data/BACKUP/BACKUP-20121019/
Nodeid = 2
Backup Id = 20121019
backup path = /var/lib/mysql/data/BACKUP/BACKUP-20121019/
Opening file '/var/lib/mysql/data/BACKUP/BACKUP-20121019/BACKUP-20121019.2.ctl'
File size 109284 bytes
Backup version in files: ndb-6.3.11 ndb version: mysql-5.5.27 ndb-7.2.8
Stop GCP of Backup: 25571
Connected to ndb!!
Successfully restored table `mysql/def/ndb_db_backup`
Successfully restored table event REPL$mysql/ndb_db_backup
Successfully restored table `mysql/def/ndb_user_backup`
Successfully restored table event REPL$mysql/ndb_user_backup
Successfully restored table `jiqun2/def/tb1`
Successfully restored table event REPL$jiqun2/tb1
Successfully restored table `mysql/def/ndb_procs_priv_backup`
Successfully restored table event REPL$mysql/ndb_procs_priv_backup
Successfully restored table `mysql/def/ndb_columns_priv_backup`
Successfully restored table event REPL$mysql/ndb_columns_priv_backup
Successfully restored table `mysql/def/ndb_apply_status`
Successfully restored table event REPL$mysql/ndb_apply_status
Successfully restored table `mysql/def/ndb_tables_priv_backup`
Successfully restored table event REPL$mysql/ndb_tables_priv_backup
Successfully restored table `jiqun/def/tb1`
Successfully restored table event REPL$jiqun/tb1
Successfully restored table `jiqun/def/tb2`
Successfully restored table event REPL$jiqun/tb2
Successfully restored table `mysql/def/ndb_host_backup`
Successfully restored table event REPL$mysql/ndb_host_backup
Successfully restored table `mysql/def/ndb_schema`
Successfully restored table event REPL$mysql/ndb_schema
Successfully restored table `mysql/def/ndb_proxies_priv_backup`
Successfully restored table event REPL$mysql/ndb_proxies_priv_backup
Successfully created index `PRIMARY` on `ndb_columns_priv_backup`
Successfully created index `Grantor` on `ndb_procs_priv_backup`
Successfully created index `PRIMARY` on `ndb_user_backup`
Successfully created index `PRIMARY` on `ndb_tables_priv_backup`
Successfully created index `PRIMARY` on `ndb_host_backup`
Successfully created index `PRIMARY` on `ndb_proxies_priv_backup`
Successfully created index `PRIMARY` on `ndb_procs_priv_backup`
Successfully created index `Grantor` on `ndb_tables_priv_backup`
Successfully created index `User` on `ndb_db_backup`
Successfully created index `PRIMARY` on `ndb_db_backup`
Successfully created index `Grantor` on `ndb_proxies_priv_backup`
Opening file '/var/lib/mysql/data/BACKUP/BACKUP-20121019/BACKUP-20121019-0.2.Data'
File size 43784 bytes
_____________________________________________________
Processing data in table: mysql/def/user(34) fragment 0
_____________________________________________________
Processing data in table: mysql/def/ndb_db_backup(18) fragment 0
_____________________________________________________
Processing data in table: mysql/def/NDB$BLOB_34_41(38) fragment 0
_____________________________________________________
Processing data in table: mysql/def/NDB$BLOB_34_33(35) fragment 0
_____________________________________________________
Processing data in table: mysql/def/ndb_index_stat_sample(8) fragment 0
_____________________________________________________
Processing data in table: mysql/def/NDB$BLOB_34_34(36) fragment 0
_____________________________________________________
Processing data in table: mysql/def/ndb_user_backup(12) fragment 0
_____________________________________________________
Processing data in table: jiqun2/def/tb1(56) fragment 0
_____________________________________________________
Processing data in table: mysql/def/NDB$