MySQL Variables session_track_gtids 数据库 参数变量解释及正确配置使用
本站中文解释
MySQL参数变量及用途session_track_gtids用于控制会话是否跟踪 MySQL Global Transaction IDs (GTID) 信息。
在MySQL 8.0及以上,可以设置session_track_gtids变量。可以设置为OFF,ON/OWN_GTID和ALL_GTIDS三个值。
OFF表示禁用GTID追踪功能,ON/OWN_GTID表示只跟踪当前会话的GTID,ALL_GTIDS表示跟踪所有的GTID。
设置session_track_gtids的方式:
1、在mysql终端中,使用以下命令来设置session_track_gtids:
SET SESSION session_track_gtids=value;
其中,value代表OFF、ON/OWN_GTID或ALL_GTIDS三个值中的一个。
2、修改my.cnf文件,重启MySQL服务器。在my.cnf文件中增加如下配置:
session-track-gtids=value
其中,value代表OFF、ON/OWN_GTID或ALL_GTIDS三个值中的一个。
官方英文解释
session_track_gtids
Command-Line Format | --session-track-gtids=value |
---|---|
System Variable | session_track_gtids |
Scope | Global, Session |
Dynamic | Yes |
Type | Enumeration |
Default Value | OFF |
Valid Values |
|
Controls whether the server returns GTIDs to the client,
enabling the client to use them to track the server state.
Depending on the variable value, at the end of executing each
transaction, the server’s GTIDs are captured and returned to
the client as part of the acknowledgement. The possible values
for session_track_gtids
are
as follows:
-
OFF
: The server does not return GTIDs
to the client. This is the default. -
OWN_GTID
: The server returns the GTIDs
for all transactions that were successfully committed by
this client in its current session since the last
acknowledgement. Typically, this is the single GTID for
the last transaction committed, but if a single client
request resulted in multiple transactions, the server
returns a GTID set containing all the relevant GTIDs. -
ALL_GTIDS
: The server returns the
global value of its
gtid_executed
system
variable, which it reads at a point after the transaction
is successfully committed. As well as the GTID for the
transaction just committed, this GTID set includes all
transactions committed on the server by any client, and
can include transactions committed after the point when
the transaction currently being acknowledged was
committed.
session_track_gtids
cannot be
set within transactional context.
For more information about session state tracking, see
Section 5.1.15, “Server Tracking of Client Session State”.