4.7.4restore cluster命令

restore cluster
    {--backupid=|-I }backup_id
    [--disable-indexes|-x]
    [--disable-metadata|-M]
    [--epoch|-e]
    [--exclude-databases=db_name]
    [--exclude-intermediate-sql-tables]
    [--exclude-missing-columns]
    [--exclude-missing-tables]
    [--exclude-tables=db_name.tbl_name[,db_name.tbl_name][,...]]
    [--include-databases=db_name]
    [--include-stored-grants]
    [--include-tables=db_name.tbl_name[,db_name.tbl_name][,...]]
    [--lossy-conversions]
    [--no-binlog|-l]
    [--no-restore-disk-objects]
    [{--parallelism=|-p }#]
    [--privilege-tables|-P]
    [--progress-frequency]
    [--promote-attributes]
    [--rewrite-database]
    [--skip-broken-objects]
    [{--skip-nodeid=|-s }id_list]
    [--skip-table-check]
    [--skip-unknown-objects]
    cluster_name

此命令将集群从具有指定备份 ID(--backupid 选项;缩写形式 :)的备份还原-I到名为 的 MySQL NDB 集群cluster_name。在其最简单的形式中,它可以如下所示使用,将命名的集群恢复mycluster到备份 ID 为 3 的备份中保存的状态:

mcm> restore cluster --backupid=3 mycluster;
+--------------------------------+
| Command result                 |
+--------------------------------+
| Restore completed successfully |
+--------------------------------+
1 row in set (18.60 sec)

如果要将现有集群恢复到已知的良好状态,则必须先擦除所有现有数据。使用 停止集群 stop cluster,然后使用 选项重新启动它start cluster--initial这会导致数据节点文件系统被清除。(请注意,对于 MySQL NDB Cluster 7.5 及更早版本,必须手动删除磁盘数据文件。)在此之后,您可以使用restore cluster.

重要的

In order to restore a backup using restore cluster, the cluster must have an unused slot for an ndbapi process in its configuration. Otherwise, the command fails with the error Unable to perform restore - no vacant ndbapi slots in config for cluster cluster_name. See Adding Free Processes, for information on how to add a free ndbapi slot to your cluster.

Additional options that can be employed with this command include:

--disable-indexes and --disable-metadata To cause indexes to be ignored when restoring the table data, use the --disable-indexes option (short form: -x; only for MySQL Cluster Manager 1.4.7 and earlier). Doing this can decrease the time required to restore a large data set, particularly where many indexes were in use. Similarly, you can cause metadata to be ignored during the restoration process by using the --disable-metadata option (short form: -M).

--epoch When the --epoch option (short form: -e) is used, epoch information is restored to the cluster replication status table (mysql.ndb_apply_status), which can be useful for replicas in MySQL NDB Cluster replication.

--exclude-databases and --exclude-tables Prevent one or more databases or tables from being restored using the options --exclude-databases and --exclude-tables. --exclude-databases takes a comma-delimited list of one or more databases that should not be restored. --exclude-tables takes a comma-delimited list of one or more tables (using the database.table format) that should not be restored. When --exclude-databases or --exclude-tables is used, only those databases or tables named by the option are excluded; all other databases and tables are restored.

--exclude-missing-columns When this option is used, restore cluster ignores any columns missing from tables being restored as compared to the versions of those tables found in the backup.

--exclude-missing-tables When this option is used, restore cluster ignores any tables from the backup that are not found in the target database.

--exclude-intermediate-sql-tables[=TRUE|FALSE] When performing ALTER TABLE operations, mysqld creates intermediate tables (whose names are prefixed with #sql-). When TRUE, the --exclude-intermediate-sql-tables option keeps restore cluster from restoring such tables that may have been left over from such operations. This option is TRUE by default.

--include-databases and --include-tables Use the --include-databases option or the --include-tables option for restoring only specific databases or tables, respectively. --include-databases takes a comma-delimited list of databases to be restored. --include-tables takes a comma-delimited list of tables (in the database.table format) to be restored. When --include-databases or --include-tables is used, only those databases or tables named by the option are restored; all other databases and tables are excluded by restore cluster, and are not restored.

--include-stored-grants When managing NDB Cluster 8.0.19 and later, the restore cluster command does not restore shared users and grants to the mysql.ndb_sql_metadata table by default; use the --include-stored-grants option (available only for MySQL Cluster Manager 1.4.8 and later) to override this behavior and enable the restore of shared user and grant data and metadata.

--lossy-conversions Using --lossy-conversions allows lossy conversions of column values (type demotions or changes in sign) when restoring data from backup. With some exceptions, the rules governing demotion are the same as for MySQL replication; see Replication of Columns Having Different Data Types, for information about specific type conversions currently supported by attribute demotion. restore cluster reports any truncation of data that it performs during lossy conversions once per attribute and column.

--no-binlog The --no-binlog option (short form: -l) stops any SQL nodes (mysqld processes) in the cluster from writing data from the restore into their binary logs.

--no-restore-disk-objects This option stops restore cluster from restoring any MySQL NDB Cluster Disk Data objects, such as tablespaces and log file groups; see NDB Cluster Disk Data Tables, for more information about these objects.

--parallelism=# The --parallelism option (short form: -p) sets the maximum number of parallel transactions that the restore cluster command attempts to use. The default value is 128; the maximum is 1024, and the minimum is 1.

--privilege-tables The --privilege-tables option (short form: -P) causes restoration of tables required for distributed grants (see Distributed Privileges Using Shared Grant Tables).

--progress-frequency=N Print a status report each N seconds to a temporary stdout dump file mcm creates at mcm_data/clusters/cluster_name/nodeid/tmp while the backup is in progress. 0 (the default) causes no status reports to be printed. The maximum is 65535.

--promote-attributes Allow attributes to be promoted when MySQL Cluster Manager restores data from a backup. See the discussion on attribute promotion in the MySQL NDB Cluster manual for more details.

--rewrite-database=old_dbname,new_dbname This option causes a database with the name old_dbname in the backup to be restored under the name new_dbname.

--skip-nodeid The --skip-nodeid option (short form: -s) takes a comma-separated list of node IDs. The nodes whose IDs are listed may include of data nodes, SQL nodes, or both. Nodes having these IDs are skipped by the restoration process.

--skip-broken-objects This option causes restore cluster to ignore corrupt tables while reading a backup, and to continue restoring any remaining tables (that are not also corrupted). Currently, the --skip-broken-objects option works only in the case of missing blob parts tables.

--skip-table-check 可以在不恢复表元数据的情况下恢复数据。这样做的默认行为是 restore cluster如果表数据与表模式不匹配则失败并报错;这可以使用 --skip-table-check 选项覆盖。

--skip-unknown-objects 此选项会导致restore cluster在读取备份时忽略任何它无法识别的模式对象。这可用于恢复,例如,从较新版本的 MySQL NDB Cluster 制作的备份到旧版本。