Help Center/ TaurusDB/ FAQs/ Log Management/ How Do I Enable and View Binlog of My GaussDB(for MySQL) Instance?
Updated on 2024-09-05 GMT+08:00

How Do I Enable and View Binlog of My GaussDB(for MySQL) Instance?

This section describes how to enable and view binlog, and the impact on GaussDB(for MySQL) performance after binlog is enabled.

Enabling Binlog

GaussDB(for MySQL) does not support enabling binlog for read replicas. For details about enabling binlog for the primary node, perform the following steps:

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and project.
  3. Click in the upper left corner of the page, choose Databases > GaussDB(for MySQL).
  4. Click the instance name to go to the Basic Information page.
  5. In the navigation pane, choose Parameters.
  6. Configure parameters as follows:

    • If the kernel version is earlier than 2.0.45.230900, search for the log-bin parameter, select ON from the drop-down list box in the Value column, and click Save. The modified parameter value is applied only after the DB instance is rebooted.
      To view the kernel version, click the instance name to go to the Basic Information page. In the DB Instance Information area, view the Kernel Version field.
      Figure 1 Viewing the kernel version

    • If the kernel version is 2.0.45.230900 or later, search for the rds_global_sql_log_bin parameter, select ON from the drop-down list box in the Value column, and click Save. The modified parameter value is applied immediately. You do not need to reboot the DB instance.

      After this parameter is changed, connect to the database and run the following command to check whether the binlog is enabled for all threads:

      select @@session.rds_sql_log_bin_inconsistent_count;

      • If the command output is 0, binlog is successfully enabled for all threads, and all statements can be recorded in binlog.
      • If the command out is not 0, run the following command to check the IDs of the threads that binlog is not enabled for:

        show warnings;

        Figure 2 Querying the IDs of the threads that binlog is not enabled for

        The statements executed in the queried thread IDs may not be recorded in binlog temporarily.

        Check your services based on the obtained thread IDs (for example, 53 in Figure 2), submit or roll back transactions and execute new transactions (for example, SELECT 1;) in a timely manner based on service requirements, or disconnect idle connections and reconnect them.

Viewing Binlog Files

  1. Connect to an instance. For details, see Connect to a DB Instance.
  2. Run the following command to view binlog files:

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

    If a message indicating that the account permissions are insufficient, use the root account.

Impact of Enabling Binlog on GaussDB(for MySQL) Performance

Enabling binlog does not affect SELECT operations, but affects INSERT, UPDATE, DELETE and other write operations.

There are no significant differences between GaussDB(for MySQL) binlog and open-source MySQL binlog. The binlog syntax of GaussDB(for MySQL) is fully compatible with that of the open-source MySQL.