21.4.6 ndb_blob_tool —检查和修复 NDB 群集 table 的 BLOB 和 TEXT 列
此工具可用于从NDBtable 中检查和删除孤立的 BLOB 列 Component,以及生成列出所有孤立 Component 的文件。有时在诊断和修复包含BLOB或TEXT列的已损坏或已损坏的NDB
table 中很有用。
ndb_blob_tool的基本语法如下所示:
ndb_blob_tool [options] table [column, ...]
除非使用--help选项,否则必须通过包含一个或多个选项--check-orphans,--delete-orphans或--dump-file来指定要执行的操作。这些选项使ndb_blob_tool分别检查孤立的 BLOB 部件,删除所有孤立的 BLOB 部件并生成转储文件,其中列出了孤立的 BLOB 部件,这将在本节稍后进行详细说明。
调用ndb_blob_tool时,还必须指定 table 的名称。此外,您可以选择在 table 格名称后跟该 table 格中一个或多个BLOB或TEXT列的名称(以逗号分隔)。如果未列出任何列,则该工具可在 table 的所有BLOB和TEXT列上使用。如果需要指定数据库,请使用--database(-d
)选项。
--verbose选项在输出中提供有关工具进度的其他信息。
下 table 包含特定于ndb_blob_tool的选项。附加说明如下 table 所示。有关大多数 NDB 群集程序(包括ndb_blob_tool)共有的选项,请参见第 21.4.32 节“ NDB 群集程序的公用选项-NDB 群集程序的公用选项”。
table21.243 ndb_blob_tool 程序的命令行选项
Format | Description | 添加,不建议使用或删除 |
---|---|---|
--add-missing |
编写虚拟的 BlobComponent 来代替丢失的 Component | 添加:NDB 7.5.18,NDB 7.6.14 |
--check-missing |
检查具有内联 Component 但缺少 Componenttable 中一个或多个 Component 的斑点 | 添加:NDB 7.5.18,NDB 7.6.14 |
--check-orphans |
检查没有对应的内联 Component 的 BlobComponent | (在所有基于 MySQL 5.7 的版本中受支持) |
--database=db_name , |
||
-d |
用于在以下位置查找 table 的数据库 | (在所有基于 MySQL 5.7 的发行版中受支持) |
--delete-orphans |
删除没有对应的内联部分的 blob 部分 | (在所有基于 MySQL 5.7 的发行版中受支持) |
--dump-file=file |
将孤立密钥写入指定的文件 | (在所有基于 MySQL 5.7 的发行版中受支持) |
--verbose ,-v |
详细输出 | (在所有基于 MySQL 5.7 的版本中受支持) |
Property | Value |
---|---|
Command-Line Format | --add-missing |
Introduced | 5.7.29-ndb-7.6.14 |
Type | Boolean |
Default Value | FALSE |
对于没有对应的 BLOB 部分的 NDB 群集 table 中的每个内联部分,请写入所需长度的虚拟 BLOB 部分,该部分由空格组成。
Property | Value |
---|---|
Command-Line Format | --check-missing |
Introduced | 5.7.29-ndb-7.6.14 |
Type | Boolean |
Default Value | FALSE |
在 NDB 群集 table 中检查没有相应 BLOB 部分的内联部分。
Property | Value |
---|---|
Command-Line Format | --check-orphans |
Type | Boolean |
Default Value | FALSE |
在 NDB 群集 table 中检查没有相应内联部件的 BLOB 部件。
Property | Value |
---|---|
Command-Line Format | --database=db_name |
Type | String |
Default Value | [none] |
指定要在其中查找 table 的数据库。
Property | Value |
---|---|
Command-Line Format | --delete-orphans |
Type | Boolean |
Default Value | FALSE |
从 NDB 群集 table 中删除没有相应内联部件的 BLOB 部件。
Property | Value |
---|---|
Command-Line Format | --dump-file=file |
Type | File name |
Default Value | [none] |
将孤立的 BLOB 列 Component 列 table 写入* file
*。写入文件的信息包括每个孤立 BLOB 部件的 table 键和 BLOB 部件号。
Property | Value |
---|---|
Command-Line Format | --verbose |
Type | Boolean |
Default Value | FALSE |
在工具的输出中提供有关其进度的其他信息。
Example
首先,我们使用此处显示的CREATE TABLE语句在test
数据库中创建一个NDB
table:
USE test;
CREATE TABLE btest (
c0 BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
c1 TEXT,
c2 BLOB
) ENGINE=NDB;
然后,我们使用与此类似的一系列语句在该 table 中插入几行:
INSERT INTO btest VALUES (NULL, 'x', REPEAT('x', 1000));
当针对此 table 使用--check-orphans运行时,ndb_blob_tool生成以下输出:
shell> ndb_blob_tool --check-orphans --verbose -d test btest
connected
processing 2 blobs
processing blob #0 c1 NDB$BLOB_19_1
NDB$BLOB_19_1: nextResult: res=1
total parts: 0
orphan parts: 0
processing blob #1 c2 NDB$BLOB_19_2
NDB$BLOB_19_2: nextResult: res=0
NDB$BLOB_19_2: nextResult: res=0
NDB$BLOB_19_2: nextResult: res=0
NDB$BLOB_19_2: nextResult: res=0
NDB$BLOB_19_2: nextResult: res=0
NDB$BLOB_19_2: nextResult: res=0
NDB$BLOB_19_2: nextResult: res=0
NDB$BLOB_19_2: nextResult: res=0
NDB$BLOB_19_2: nextResult: res=0
NDB$BLOB_19_2: nextResult: res=0
NDB$BLOB_19_2: nextResult: res=1
total parts: 10
orphan parts: 0
disconnected
NDBT_ProgramExit: 0 - OK
该工具报告,即使c1
是TEXT列,也没有与c1
列关联的NDB
BLOB 列部分。这是由于以下事实:在NDBtable 中,仅BLOB或TEXT列值的前 256 个字节被内联存储,并且仅多余的(如果有的话)被单独存储;因此,如果在这些类型之一的给定列中没有使用超过 256 个字节的值,则NDB
不会为此列创建BLOB
列部分。有关更多信息,请参见第 11.7 节“数据类型存储要求”。