content_image/795166.jpg
5. You can now start the cluster restoration process on the replica using the ndb_restore  command for each backup file in turn. For the first of these, it is necessary to include the -m  option to restore the cluster metadata, as shown here: 

shell R > ndb_restore -c replica_host : port  -n node-id  \ -b backup-id  -m -r dir 

dir  is the path to the directory where the backup files have been placed on the replica. For the ndb_restore  commands corresponding to the remaining backup files, the -m  option should not  be used. 

For restoring from a source cluster with four data nodes (as shown in the figure in Section 23.6, “NDB Cluster Replication” ) where the backup files have been copied to the directory /var/BACKUPS/ BACKUP-1 , the proper sequence of commands to be executed on the replica might look like this: 

shell R > ndb_restore -c replica-host:1186 -n 2 -b 1 -m \ -r ./var/BACKUPS/BACKUP-1 shell R > ndb_restore -c replica-host:1186 -n 3 -b 1 \ -r ./var/BACKUPS/BACKUP-1 shell R > ndb_restore -c replica-host:1186 -n 4 -b 1 \ -r ./var/BACKUPS/BACKUP-1 shell R > ndb_restore -c replica-host:1186 -n 5 -b 1 -e \ -r ./var/BACKUPS/BACKUP-1 

<img src='content_image/795166.jpg'>

## Important 

The -e  (or --restore-epoch ) option in the final invocation of ndb_restore in this example is required to make sure that the epoch is written to the replica’s mysql.ndb_apply_status  table. Without this information, the replica cannot synchronize properly with the source. (See Section 23.4.23, “ndb_restore — Restore an NDB Cluster Backup” .) 

6. Now you need to obtain the most recent epoch from the ndb_apply_status  table on the replica (as discussed in Section 23.6.8, “Implementing Failover with NDB Cluster Replication” ): 

mysql R > SELECT @latest:=MAX(epoch) FROM mysql.ndb_apply_status; 

7. Using @latest  as the epoch value obtained in the previous step, you can obtain the correct starting position @pos  in the correct binary log file @file  from the mysql.ndb_binlog_index  table on the source. The query shown here gets these from the next_position  and next_file  columns from the last epoch applied before the logical restore position: 

mysql S > SELECT -> @file:=SUBSTRING_INDEX(next_file, ’/’, -1), -> @pos:=next_position -> FROM mysql.ndb_binlog_index -> WHERE epoch < @latest -> ORDER BY epoch ASC LIMIT 1; 

In the event that there is currently no replication traffic, you can get similar information by running SHOW MASTER STATUS  on the source and using the value shown in the Position  column of the output for the file whose name has the suffix with the greatest value for all files shown in the File  column. In this case, you must determine which file this is and supply the name in the next step manually or by parsing the output with a script. 

