All Products
Search
Document Center

PolarDB:SHOW BINARY LOGS

Last Updated:Aug 21, 2024

This topic describes how to execute the SHOW BINARY LOGS statement to view the binary log files of a PolarDB-X instance.

Syntax

SHOW BINLOG EVENTS
   [WITH 'stream_name']
   [IN 'log_name']
   [FROM pos]
   [LIMIT [offset,] row_count]

Usage notes

  • Before you execute the preceding SQL statement, make sure that your account is granted the SUPER or REPLICATION CLIENT permission. For information about how to manage permissions, see Manage accounts and permissions.

  • If a WITH clause is not added to the SQL statement, you can view the binary log files generated in single-stream mode.

  • If a WITH clause is added to the SQL statement, you can view the binary log files whose stream name is specified and that are generated in multi-stream mode. The stream_name parameter specifies the name of a stream.

  • For PolarDB-X instances whose kernel version is V5.4.18 or later, you can specify the FULL parameter to query more details about the binary log files.

  • For more information about the SQL statement, see SHOW BINARY LOGS.

Example 1

Execute the following statement to view the binary log files generated in single-stream mode:

SHOW BINARY LOGS;

The following result is returned:

+---------------+-----------+
| LOG_NAME      | FILE_SIZE |
+---------------+-----------+
| binlog.000001 |         4 |
+---------------+-----------+

Example 2

Execute the following statement to view the binary log files whose stream name is group1_stream_0 and that are generated in multi-stream mode:

SHOW BINARY LOGS WITH 'group1_stream_0';

The following result is returned:

+-------------------------------+-----------+
| LOG_NAME                      | FILE_SIZE |
+-------------------------------+-----------+
| group1_stream_0#binlog.000001 |   3626808 |
+-------------------------------+-----------+ 

Example 3

Execute the following statement:

show full binary logs \G;

The following result is returned:

*************************** 1. row ***************************
        LOG_NAME: binlog.000001
       FILE_SIZE: 20968
     CREATE_TIME: 2024-04-15 21:34:47
LAST_MODIFY_TIME: 2024-04-15 21:36:01
FIRST_EVENT_TIME: 2024-04-15 21:35:46
 LAST_EVENT_TIME: 2024-04-15 21:35:54
        LAST_TSO: 718563192765363001617166971431561502720000000000000000
   UPLOAD_STATUS: SUCCESS
   FILE_LOCATION: REMOTE
         EXTINFO: 

The following parameters are returned:

  • CREATE_TIME: the creation time of the binary log files.

  • LAST_MODIFY_TIME: the last modification time of the binary log files.

  • FIRST_EVENT_TIME: the execution time of the SQL statement for the first event in the binary log files.

  • LAST_EVENT_TIME: the execution time of the SQL statement for the last event in the binary log files.

  • LAST_TSO: the TSO of the last transaction in the binary log files.

  • UPLOAD_STATUS: the upload status of the binary log files. The value SUCCESS indicates that the binary log files are successfully uploaded to the remote storage for archiving.

  • FILE_LOCATION: the location of the binary log files.

    • LOCAL: The binary log files are stored on a local disk. If the value of UPLOAD_STATUS is SUCCESS, the binary log files are also stored in the remote storage.

    • REMOTE: The binary log files are stored in the remote storage, not on a local disk.