It is possible using MySQL Cluster Manager to perform a partial restore of a MySQL NDB Cluster—that is, to restore from a backup in which backup images from one or more data nodes are not available. This is required if we wish to restoremycluster to backup number 6, since an image for this backup is available only for node 1, as can be seen in the output oflist backups in themcm client :
mcm> list backups mycluster;+----------+--------+---------+---------------------+--------+---------+| BackupId | NodeId | Host | Timestamp | Parts | Comment |+----------+--------+---------+---------------------+--------+---------+| 1 | 1 | tonfisk | 2020-12-04 12:03:52 | 1 | || 1 | 2 | tonfisk | 2020-12-04 12:03:52 | 1 | || 2 | 1 | tonfisk | 2020-12-04 12:04:15 | 1 | || 2 | 2 | tonfisk | 2020-12-04 12:04:15 | 1 | || 3 | 1 | tonfisk | 2020-12-04 12:17:41 | 1 | || 3 | 2 | tonfisk | 2020-12-04 12:17:41 | 1 | || 4 | 1 | tonfisk | 2020-12-12 14:24:35 | 1 | || 4 | 2 | tonfisk | 2020-12-12 14:24:35 | 1 | || 5 | 1 | tonfisk | 2020-12-12 14:31:31 | 1 | || 5 | 2 | tonfisk | 2020-12-12 14:31:31 | 1 | || 6 | 1 | tonfisk | 2020-12-12 14:32:09 | 1 | |+----------+--------+---------+---------------------+--------+---------+11 rows in set (0.08 sec) To perform a restore of only those nodes for which we have images (in this case, node 1 only), we can use the--skip-nodeid option when executing arestore cluster command. This option causes one or more nodes to be skipped when performing the restore. Assuming thatmycluster has been cleared of data (as described earlier in this section), we can perform a restore that skips node 2 as shown here:
mcm> restore cluster --backupid=6 --skip-nodeid=2 mycluster;+--------------------------------+| Command result |+--------------------------------+| Restore completed successfully |+--------------------------------+1 row in set (17.06 sec) Because we excluded node 2 from the restore process, no data has been distributed to it. To cause MySQL NDB Cluster data to be distributed to any such excluded or skipped nodes following a partial restore, it is necessary to redistribute the data manually by executing anALTER ONLINE TABLE ... REORGANIZE PARTITION statement in themysql client for eachNDB table in the cluster. To obtain a list ofNDB tables from themysql client, you can use multipleSHOW TABLES statements or a query such as this one:
SELECT CONCAT('' TABLE_SCHEMA, '.', TABLE_NAME) FROM INFORMATION_SCHEMA.TABLES WHERE ENGINE='ndbcluster';You can generate the necessary SQL statements using a more elaborate version of the query just shown, such the one employed here:
mysql> SELECT -> CONCAT('ALTER ONLINE TABLE `', TABLE_SCHEMA, -> '`.`', TABLE_NAME, '` REORGANIZE PARTITION;') -> AS Statement -> FROM INFORMATION_SCHEMA.TABLES -> WHERE ENGINE='ndbcluster';+--------------------------------------------------------------------------+| Statement |+--------------------------------------------------------------------------+| ALTER ONLINE TABLE `mysql`.`ndb_apply_status` REORGANIZE PARTITION; || ALTER ONLINE TABLE `mysql`.`ndb_index_stat_head` REORGANIZE PARTITION; || ALTER ONLINE TABLE `mysql`.`ndb_index_stat_sample` REORGANIZE PARTITION; || ALTER ONLINE TABLE `db1`.`n1` REORGANIZE PARTITION; || ALTER ONLINE TABLE `db1`.`n2` REORGANIZE PARTITION; || ALTER ONLINE TABLE `db1`.`n3` REORGANIZE PARTITION; || ALTER ONLINE TABLE `test`.`n1` REORGANIZE PARTITION; || ALTER ONLINE TABLE `test`.`n2` REORGANIZE PARTITION; || ALTER ONLINE TABLE `test`.`n3` REORGANIZE PARTITION; || ALTER ONLINE TABLE `test`.`n4` REORGANIZE PARTITION; |+--------------------------------------------------------------------------+10 rows in set (0.09 sec)