PolarDB-X provides global binary logs for business scenarios in which you consume or subscribe to data. This topic describes how to query global binary log files in PolarDB-X.

Limits

  • If global transaction identifiers (GTIDs) are enabled for your PolarDB-X instance, you cannot subscribe to data.
  • You can merge distributed transactions only when the transaction policy is set to Timestamp Oracle (TSO). TSO is used to ensure strong consistency.
    Note PolarDB-X uses TSO as the default transaction policy. We recommend that you use the default transaction policy. For more information about the principles of global binary logs, see Global data change logging.

Query binary log files

  1. Connect to a PolarDB-X database. For more information about the procedure, see Connect to a database.
  2. On the client that is connected to the PolarDB-X instance, you can query binary log files based on the following sample code.
    • You can use the following syntax to query binary log files in PolarDB-X:
      SHOW BINARY LOGS;
      Note

      The following result is returned:

      +---------------+-----------+
      | LOG_NAME      | FILE_SIZE |
      +---------------+-----------+
      | binlog.000001 |         4 |
      +---------------+-----------+
    • You can use the following syntax to query the binary log files of the primary node in PolarDB-X:
      SHOW MASTER STATUS;
      Note

      The following result is returned:

      *************************** 1. row ***************************
                   FILE: binlog.000001
               POSITION: 4
           BINLOG_DO_DB:
       BINLOG_IGNORE_DB:
      EXECUTED_GTID_SET:
    • You can use the following syntax to query the events in global binary log files:
      SHOW BINLOG EVENTS
      Note

      The following result is returned:

      +---------------+------+------------+-----------+-------------+--------------------------------------------------------+
      | LOG_NAME      | POS  | EVENT_TYPE | SERVER_ID | END_LOG_POS | INFO                                                   |
      +---------------+------+------------+-----------+-------------+--------------------------------------------------------+
      | binlog.000001 |  745 | Query      |         1 |         807 | BEGIN                                                  |
      | binlog.000001 |  807 | Table_map  |         1 |         868 | table_id: 258 (transfer_test.accounts)                 |
      | binlog.000001 |  868 | Write_rows |         1 |         912 | table_id: 258 flags: STMT_END_F                        |
      | binlog.000001 |  912 | Table_map  |         1 |         973 | table_id: 367 (transfer_test.accounts)                 |
      | binlog.000001 |  973 | Write_rows |         1 |        1017 | table_id: 367 flags: STMT_END_F                        |
      | binlog.000001 | 1017 | Table_map  |         1 |        1078 | table_id: 366 (transfer_test.accounts)                 |
      | binlog.000001 | 1078 | Write_rows |         1 |        1122 | table_id: 366 flags: STMT_END_F                        |
      | binlog.000001 | 1122 | Table_map  |         1 |        1183 | table_id: 365 (transfer_test.accounts)                 |
      | binlog.000001 | 1183 | Write_rows |         1 |        1227 | table_id: 365 flags: STMT_END_F                        |
      | binlog.000001 | 1227 | Table_map  |         1 |        1288 | table_id: 365 (transfer_test.accounts)                 |
      | binlog.000001 | 1288 | Write_rows |         1 |        1332 | table_id: 365 flags: STMT_END_F                        |
      | binlog.000001 | 1332 | Xid        |         1 |        1363 | COMMIT /* xid=1 */                                     |
      | binlog.000001 | 1363 | Rows_query |         1 |        1441 | 677707399066754342413081391897447014400000000000132369 |
      +---------------+------+------------+-----------+-------------+--------------------------------------------------------+