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
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.