This topic describes how to use SQL statements to start, pause, reset, and rolling update the binary logs of PolarDB-X.
Usage notes
To use the SQL statements described in this topic, you must obtain the SUPER or REPLICATION CLIENT permission. For more information, see Manage accounts and permissions.
The SQL statements described in this topic are supported by instances of PolarDB-X 5.4.17 or later.
If the WITH clause is not included, the operation is performed on binary logs in single-stream mode.
If the WITH clause is included, the operation is performed on the specified binary logs in multi-stream mode.
The stream group name in the WITH clause is the stream group name that you specify when you create a multi-stream group.
START MASTER
Description
The binary log feature is automatically enabled. If the STOP MASTER statement is not executed, you do not need to execute the START MASTER statement.
After you execute the START MASTER statement, binary logs are generated.
Syntax
START MASTER [WITH stream_group_name]
Examples
Execute the following statement to enable the single-stream binary log feature:
START MASTER;
Execute the following statement to enable the multi-stream binary log feature for a stream group named group1:
START MASTER WITH group1;
STOP MASTER
Description
After you disable the binary log feature, binary logs are no longer generated.
Do not keep the binary log feature disabled for a long time. Otherwise, physical binary logs corresponding to the data node (DN) are cleared and cannot be restored after you re-enable the binary log feature. For information about how to set the retention period of binary logs corresponding to the DN, see Local log backup.
Syntax
STOP MASTER [WITH stream_group_name]
Examples
Execute the following statement to disable the single-stream binary log feature:
STOP MASTER;
Execute the following statement to disable the multi-stream binary log feature for a stream group named group1:
STOP MASTER WITH group1;
RESET MASTER
Description
Before you execute the RESET MASTER statement, you must execute the STOP MASTER statement to disable the binary log feature.
After you execute the RESET MASTER statement, existing binary log files are deleted.
After you execute the RESET MASTER statement, the binary log files are regenerated based on the current point in time. The files are numbered from 000001.
After you execute the RESET MASTER statement, you must execute the START MASTER statement to restart the binary log feature.
Syntax
RESET MASTER [WITH stream_group_name]
Examples
Execute the following statement to reset the single-stream binary log feature:
RESET MASTER;
Execute the following statement to reset the multi-stream binary log feature for a stream group named group1:
RESET MASTER WITH group1;
FLUSH LOGS
Description
After you execute the FLUSH LOGS statement, logs stop being written to the binary log file with the largest number and a new file is generated for log writing.
This feature is supported only for binary logs in single-stream mode.
syntax
FLUSH LOGS;
Examples
Execute the following statement to perform a rolling update on the binary log files:
FLUSH LOGS;
Before you perform the rolling update, the log file with the largest number is binlog.000004.
show binary logs; +---------------+-----------+ | LOG_NAME | FILE_SIZE | +---------------+-----------+ | binlog.000001 | 20968 | | binlog.000002 | 10489381 | | binlog.000003 | 10486003 | | binlog.000004 | 361752 | +---------------+-----------+
After you perform the rolling update, the log file with the largest number changes to binlog.000005.
show binary logs; +---------------+-----------+ | LOG_NAME | FILE_SIZE | +---------------+-----------+ | binlog.000001 | 20968 | | binlog.000002 | 10489381 | | binlog.000003 | 10486003 | | binlog.000004 | 361752 | | binlog.000005 | 260 | +---------------+-----------+