文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

MySQL 8.4 参考手册 / 15 条 SQL 语句 / 15.1 数据定义语句 / 15.1.16 创建日志文件组语句
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

15.1.16 CREATE LOGFILE GROUP 语句15.1.16 CREATE LOGFILE GROUP Statement

CREATE LOGFILE GROUP logfile_group
    ADD UNDOFILE 'undo_file'
    [INITIAL_SIZE [=] initial_size]
    [UNDO_BUFFER_SIZE [=] undo_buffer_size]
    [REDO_BUFFER_SIZE [=] redo_buffer_size]
    [NODEGROUP [=] nodegroup_id]
    [WAIT]
    [COMMENT [=] 'string']
    ENGINE [=] engine_name

此语句创建一个名为 logfile_group 的新日志文件组,该组包含一个名为 'undo_file' 的撤消文件。CREATE LOGFILE GROUP 语句只能包含一个 ADD UNDOFILE 子句。有关日志文件组命名规则,请参见 第 11.2 节,“模式对象名称”。This statement creates a new log file group named logfile_group having a single undo file named 'undo_file'. A CREATE LOGFILE GROUP statement has one and only one ADD UNDOFILE clause. For rules covering the naming of log file groups, see Section 11.2, “Schema Object Names”.

Note

所有 NDB 集群磁盘数据对象共享相同的命名空间。这意味着 每个磁盘数据对象 必须具有唯一名称(而不仅仅是每种类型的磁盘数据对象)。例如,不能具有同名的表空间和日志文件组,或者同名的表空间和数据文件。All NDB Cluster Disk Data objects share the same namespace. This means that each Disk Data object must be uniquely named (and not merely each Disk Data object of a given type). For example, you cannot have a tablespace and a log file group with the same name, or a tablespace and a data file with the same name.

在任何给定时间,每个 NDB 集群实例只能有一个日志文件组。There can be only one log file group per NDB Cluster instance at any given time.

可选的 INITIAL_SIZE参数设定撤销文件的初始大小;如果未指定,默认为 128M(128 MB)。可选的 UNDO_BUFFER_SIZE 参数决定撤销缓冲区用于日志文件组的大小;UNDO_BUFFER_SIZE为 8M(8 MB);该值不能超过系统可用的内存容量。这两个参数均以字节表示。你可以选择在其中一个或两个参数后面加上一个字母缩写,表示数量级,类似于 my.cnf。通常,这包括字母 M(兆字节)或 G(GBThe optional INITIAL_SIZE parameter sets the undo file's initial size; if not specified, it defaults to 128M (128 megabytes). The optional UNDO_BUFFER_SIZE parameter sets the size used by the undo buffer for the log file group; The default value for UNDO_BUFFER_SIZE is 8M (eight megabytes); this value cannot exceed the amount of system memory available. Both of these parameters are specified in bytes. You may optionally follow either or both of these with a one-letter abbreviation for an order of magnitude, similar to those used in my.cnf. Generally, this is one of the letters M (for megabytes) or G (for gigabytes).

用于 UNDO_BUFFER_SIZE 的内存来自全局池,该池的大小由 SharedGlobalMemory 数据节点配置参数的值决定。这包括由 InitialLogFileGroup 数据节点配置参数设置所暗示的此选项的任何默认值。Memory used for UNDO_BUFFER_SIZE comes from the global pool whose size is determined by the value of the SharedGlobalMemory data node configuration parameter. This includes any default value implied for this option by the setting of the InitialLogFileGroup data node configuration parameter.

)。UNDO_BUFFER_SIZE容量为 629145600(600 MB)。The maximum permitted for UNDO_BUFFER_SIZE is 629145600 (600 MB).

在 32 位系统上,INITIAL_SIZE 支持的最大值为 4294967296(4 GB)。(Bug #29186)On 32-bit systems, the maximum supported value for INITIAL_SIZE is 4294967296 (4 GB). (Bug #29186)

INITIAL_SIZE为 1048576(1 MB)。The minimum allowed value for INITIAL_SIZE is 1048576 (1 MB).

ENGINE选项决定该日志文件组使用的存储引擎,engine_name为存储引擎名称。这必须是 NDB或 NDBCLUSTER如果 ENGINE未设置,MySQL 尝试使用由服务器系统变量 default_storage_engine 服务器系统变量指定的引擎。无论如何,如果引擎未指定为 NDB 或 NDBCLUSTERCREATE LOGFILE GROUP 语句看似成功,但实际上未能创建日志文件组,如图所示:The ENGINE option determines the storage engine to be used by this log file group, with engine_name being the name of the storage engine. This must be NDB (or NDBCLUSTER). If ENGINE is not set, MySQL tries to use the engine specified by the default_storage_engine server system variable. In any case, if the engine is not specified as NDB or NDBCLUSTER, the CREATE LOGFILE GROUP statement appears to succeed but actually fails to create the log file group, as shown here:

mysql> CREATE LOGFILE GROUP lg1
    ->     ADD UNDOFILE 'undo.dat' INITIAL_SIZE = 10M;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> SHOW WARNINGS;
+-------+------+------------------------------------------------------------------------------------------------+
| Level | Code | Message                                                                                        |
+-------+------+------------------------------------------------------------------------------------------------+
| Error | 1478 | Table storage engine 'InnoDB' does not support the create option 'TABLESPACE or LOGFILE GROUP' |
+-------+------+------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> DROP LOGFILE GROUP lg1 ENGINE = NDB;
ERROR 1529 (HY000): Failed to drop LOGFILE GROUP

mysql> CREATE LOGFILE GROUP lg1
    ->     ADD UNDOFILE 'undo.dat' INITIAL_SIZE = 10M
    ->     ENGINE = NDB;
Query OK, 0 rows affected (2.97 sec)

CREATE LOGFILE GROUP当指定了除 NDB,而是看似成功,这是一个已知问题,我们希望在未来版本的 NDB Cluster 中得到解决。The fact that the CREATE LOGFILE GROUP statement does not actually return an error when a storage engine other than NDB is specified, but rather appears to succeed, is a known issue which we hope to address in a future version of NDB Cluster.

REDO_BUFFER_SIZE, NODEGROUP, WAIT,以及COMMENT被解析但会被忽略,因此在 MySQL 8.4 中没有效果。这些选项是为将来的扩展而设计的。REDO_BUFFER_SIZE, NODEGROUP, WAIT, and COMMENT are parsed but ignored, and so have no effect in MySQL 8.4. These options are intended for future expansion.

当与 ENGINE [=] NDB时,每个集群数据节点都会创建一个日志文件组及相关的撤销日志文件。您可以通过查询信息模式FILES。例如:When used with ENGINE [=] NDB, a log file group and associated undo log file are created on each Cluster data node. You can verify that the undo files were created and obtain information about them by querying the Information Schema FILES table. For example:

mysql> SELECT LOGFILE_GROUP_NAME, LOGFILE_GROUP_NUMBER, EXTRA
    -> FROM INFORMATION_SCHEMA.FILES
    -> WHERE FILE_NAME = 'undo_10.dat';
+--------------------+----------------------+----------------+
| LOGFILE_GROUP_NAME | LOGFILE_GROUP_NUMBER | EXTRA          |
+--------------------+----------------------+----------------+
| lg_3               |                   11 | CLUSTER_NODE=3 |
| lg_3               |                   11 | CLUSTER_NODE=4 |
+--------------------+----------------------+----------------+
2 rows in set (0.06 sec)

CREATE LOGFILE GROUP仅适用于 NDB 集群的磁盘数据存储。参见 第 25.6.11 节,“NDB 集群磁盘表”。CREATE LOGFILE GROUP is useful only with Disk Data storage for NDB Cluster. See Section 25.6.11, “NDB Cluster Disk Data Tables”.