This topic describes how to enable the binary logging feature for a PolarDB cluster.

Prerequisites

  • If your PolarDB cluster was created after April 5, 2019, you can enable the binary logging feature.
  • If your PolarDB cluster was created before April 5, 2019, upgrade the minor version of the cluster to the latest version before you enable the binary logging feature. For more information about how to upgrade the minor version, see Upgrade versions.

Background information

PolarDB is a cloud-native database that is compatible with MySQL. By default, PolarDB uses physical logs which are more advanced than binary logs. PolarDB allows you to enable the binary logging feature. This provides improved integration with the MySQL ecosystem. After you enable the binary logging feature, you can connect to data services such as Elasticsearch andAnalyticDB. You can also synchronize data from a PolarDB for MySQL cluster to an ApsaraDB for RDS instance, from an ApsaraDB for RDS instance to a PolarDB for MySQL cluster, or between PolarDB for MySQL clusters.

Pricing

The storage that is used to store binary logs is a part of the cluster storage. You are charged for the storage that is used by binary logs. For more information, see Specifications and pricing.

Notes

  • By default, binary logs are retained for two weeks and then automatically deleted. For more information, see FAQ.
  • By default, the binary logging feature is disabled. To enable the binary logging feature, you must restart all the nodes in the cluster. This operation may interrupt your services. We recommend that you prepare other service arrangements before you restart the nodes.
  • After the binary logging feature is enabled, the write performance is compromised. However, the read performance is not affected. For more information, see FAQ.
  • We recommend that you use the Primary Endpoints of PolarDB when you pull, subscribe to, or synchronize binary logs by using a tool such as Data Transmission Service (DTS). This ensures compatibility and stability because the primary endpoint points to the primary node that generates binary logs. For information about how to query the Primary Endpoints, see View the endpoint and port.

Procedure

  1. Log on to the PolarDB console.
  2. In the upper-left corner of the console, select the region where the cluster resides.
  3. Find the cluster, and then click the cluster ID.
  4. In the left-side navigation pane, choose Settings and Management > Parameters.
  5. Find the loose_polar_log_bin parameter and click the Icon icon in the Current Value column. In the dialog box that appears, enter a new value and click OK.
    1
    Note
    • For a PolarDB cluster that uses the MySQL 5.6 database engine, enter ON_WITH_GTID.
    • For a PolarDB cluster that uses the MySQL 5.7 or MySQL 8.0 database engine, enter ON.
  6. In the upper-left corner of the page, click Apply Changes. In the Save Changes message, click OK.
    2
    Note
    • After you perform the preceding operations, you must restart the cluster for the binary logging feature to take effect. We recommend that you restart the nodes during off-peak hours and make sure that your application can automatically reconnect to the cluster.
    • If the version of your PolarDB for MySQL cluster is 8.0, you can set the innodb_fast_startup parameter to ON to accelerate the restart.
    • If the error message Custins minor version does not support current action is returned, submit a ticket to enable the binary logging feature.

FAQ

  • How long can binary logs be stored?

    By default, binary logs are retained for two weeks and then automatically deleted.

    • If the version of your PolarDB for MySQL cluster is 5.6, you can change the value of the loose_expire_logs_hours parameter to specify the retention period of binary logs. The valid values of this parameter range from 0 to 2376 hours. A value of 0 indicates that binary logs are not automatically deleted.
    • If the version of your PolarDB for MySQL cluster is 5.7 or 8.0, you can change the value of the binlog_expire_logs_seconds parameter to specify the retention period of binary logs. The valid values of this parameter range from 0 to 4294967295 seconds. A value of 0 indicates that binary logs are not automatically deleted.
  • Can I disable the binary logging feature?

    Yes, you can disable the binary logging feature after you change the value of the loose_polar_log_bin parameter to OFF and submit the modification. The existing binary logs are not deleted after the binary logging feature is disabled.

  • How is the performance of the cluster affected after the binary logging feature is enabled?

    After you enable the binary logging feature, only the write performance is affected. For example, the performance of INSERT, UPDATE, and DELETE statements is affected after binary logging is enabled. However, The performance of SELECT statements is not affected. In most cases, the cluster performance may decrease by 10% or less after you enable the binary logging feature.

  • After binary logging is enabled, the cluster automatically restarts. How much time is required to perform a restart task?

    In most cases, 5 minutes is required to perform a restart task. During a restart, the service may be disconnected for about 40 seconds. The service downtime depends on the volume of data and the number of tables. We recommend that you perform the restart during off-peak hours and make sure that your application can automatically reconnect to the cluster.

  • How do I remotely obtain and view the binary logs?

    For more information, see Remotely obtain and parse binary logs from a PolarDB for MySQL cluster.

  • Why am I unable to use the Change schemas without locking tables feature of DMS to change table schemas, for example, to add an index to a PolarDB for MySQL cluster?

    By default, the binary logging feature of the PolarDB for MySQL cluster is disabled. To use DMS to change the table structure in lock-free mode, you must first enable the binary logging feature for the PolarDB for MySQL cluster. If you do not want to enable the binary logging feature, you can run the online DDL commands to change the structure of the table.