Instance management

2025-08-04 08:34:56  Updated

Create a binlog instance

You can create a binlog instance for a tenant with the binlog service enabled. The new binlog instance will not inherit the parameter settings of existing binlog instances. In other words, you must explicitly specify the parameters in the SQL statement for creating the binlog instance.

Note

For information about how to enable the binlog service for a tenant, see the Create a binlog task section in the Task management topic.

Syntax

CREATE BINLOG INSTANCE instance_name 
       FOR cluster.tenant cluster_url [, binlog_instance_option [, binlog_instance_option...]];

binlog_instance_option: 
    obcdc_option
  | binlog_option

obcdc_option: 
    START_TIMESTAMP
  | ROOTSERVER_LIST
  | CLUSTER_USER
  | CLUSTER_PASSWORD
  | EXTRA_OBCDC_CFG

binlog_option:
    MASTER_SERVER_ID
  | MASTER_SERVER_UUID
  | SERVER_ID
  | SERVER_UUID
  | BINLOG_EXPIRE_LOGS_SECONDS
  | BINLOG_EXPIRE_LOGS_SIZE
  | MAX_BINLOG_SIZE
  | AUTO_START_OBCDC
  | ACTIVE_STATE_AFTER_BOOT
  | FAILOVER
  | _INITIAL_OB_TXN_ID
  | _INITIAL_OB_TXN_GTID_SEQ

Parameters

Parameter Description
instance_name The name of the binlog instance, which must be unique in the binlog cluster.
cluster.tenant The name of the tenant for which the binlog instance is to be created, and the name of the cluster to which the tenant belongs.
cluster_url The ConfigUrl of the OceanBase cluster, which must be enclosed in quotation marks. You can execute the SHOW PARAMETERS LIKE 'obconfig_url'; statement to query the value of this parameter.
binlog_instance_option Optional. Options of the binlog instance, which are separated with commas (,). Separate the options and cluster_url with a comma (,). Valid values:
  • obcdc_option: OceanBase Change Data Capture (obcdc) options. For more information about obcdc parameters, see obcdc parameters.
  • binlog_option: binlog instance options.

Examples

  • Create a binlog instance named binlog1 for the test1 tenant in the obdemo cluster.

    CREATE BINLOG INSTANCE binlog1 FOR obdemo.test1 CLUSTER_URL='http://10.10.10.1:8080/services?Action=ObRootServiceInfo&ObCluster=obdemo';
    
  • Create a binlog instance named binlog2 for the test1 tenant in the obdemo cluster and specify obcdc parameters.

    CREATE BINLOG INSTANCE binlog2 FOR obdemo.test1 CLUSTER_URL='http://10.10.10.1:8080/services?Action=ObRootServiceInfo&ObCluster=obdemo',EXTRA_OBCDC_CFG = 'memory_limit=6G progress_limit_sec_for_dml=30';
    

Query one or more binlog instances

You can query information about one or more binlog instances. If no record meeting the specified conditions exists, an empty result set is returned.

Syntax

SHOW BINLOG INSTANCES {
      FOR cluster.tenant 
    | [instance_name [, instance_name...]]
};

The following table describes the parameters.

Parameter Description
cluster.tenant The name of the tenant whose binlog instances are to be queried, and the name of the cluster to which the tenant belongs.
instance_name The name of the binlog instance to be queried. Separate multiple instance names with commas (,).

Examples

  • Query information about binlog instances in the test1 tenant of the obdemo cluster.

    SHOW BINLOG INSTANCES FOR obdemo.test1;
    
  • Query information about specified binlog instances.

    SHOW BINLOG INSTANCES `eo46r4f2e8`,`gldwt7bnco`;
    

The command output is as follows:

+------------+------------+-----------+---------------+------+------+--------+-------+---------+---------+---------------+-------------+--------------+-----------------+---------------+-------------+-------------+--------------+---------+------------------------------------------------+----------+
| name       | ob_cluster | ob_tenant | ip            | port | zone | region | group | running | state   | obcdc_running | obcdc_state | service_mode | convert_running | convert_delay | convert_rps | convert_eps | convert_iops | dumpers | version                                        | odp_addr |
+------------+------------+-----------+---------------+------+------+--------+-------+---------+---------+---------------+-------------+--------------+-----------------+---------------+-------------+-------------+--------------+---------+------------------------------------------------+----------+
| eo46r4f2e8 | obdemo     | test1     | 10.10.10.1    | 8104 |      |        |       | Yes     | Running | Yes           | Running     | enabled      | Yes             |           578 |           1 |           0 |            0 |       0 | 4.0.1-92748c6c59534426d187977b13b61b7cdf4fa200 | NULL     |
| gldwt7bnco | obdemo     | test1     | 10.10.10.1    | 8103 |      |        |       | Yes     | Running | Yes           | Running     | enabled      | Yes             |           478 |           1 |           0 |            0 |       0 | 4.0.1-92748c6c59534426d187977b13b61b7cdf4fa200 | NULL     |
+------------+------------+-----------+---------------+------+------+--------+-------+---------+---------+---------------+-------------+--------------+-----------------+---------------+-------------+-------------+--------------+---------+------------------------------------------------+----------+

The following table describes the columns in the result set.

Column Description
name The name of the binlog instance.
ob_cluster The name of the OceanBase cluster.
ob_tenant The name of the tenant whose binlog instances are queried.
ip The IP address of the node where the binlog instance resides.
port The MySQL service port of the binlog instance. The value 0 indicates that no service port has been allocated.
zone The zone where the binlog instance resides.
region The region where the binlog instance resides.
group The logical group to which the binlog instance belongs.
running Indicates whether the binlog instance is running. Valid values: Yes and No.
state The status of the binlog instance.
obcdc_running Indicates whether obcdc is running. Valid values: Yes and No.
obcdc_state The status of obcdc.
service_mode The external servicing status of the binlog instance. Valid values: enabled and disabled.
convert_running Indicates whether the log format conversion process of the binlog instance is running. Valid values: Yes and No.
convert_delay The log conversion delay of the binlog instance. Unit: milliseconds.
convert_rps The number of records converted per second by the binlog instance.
convert_eps The number of events generated by the binlog instance per second.
convert_iops The size of events generated by the binlog instance per second. Unit: bytes.
dumpers The number of dumpers for the binlog instance.
version The version number of obbinlog.
odp_addr Reserved for future use.

Modify a binlog instance

You can modify the parameter settings of the specified binlog instance.

Syntax

ALTER BINLOG INSTANCE instance_name
    SET binlog_instance_option [, binlog_instance_option...];

The following table describes the parameters.

Parameter Description
instance_name The name of the binlog instance whose parameters are to be modified.
binlog_instance_option The parameter to be modified. Valid values:
  • BINLOG_EXPIRE_LOGS_SECONDS: the validity period of binlog files. The default value is 259200 seconds. A binlog file automatically becomes invalid after the validity period elapses.
  • BINLOG_EXPIRE_LOGS_SIZE: the maximum size of a binlog file. The default value is 53687091200 bytes.
  • FAILOVER: specifies whether to automatically recover the binlog instance after it fails. The default value is 1, which indicates automatic recovery.
  • EXTRA_OBCDC_CFG: the obcdc parameter settings of the binlog instance.

Examples

Change the validity period of binlog files of the binlog1 instance to 6 days (518,400 seconds).

ALTER BINLOG INSTANCE binlog1 SET BINLOG_EXPIRE_LOGS_SECONDS = 518400;

Stop a binlog instance

You can stop the specified binlog instance.

Syntax

STOP BINLOG INSTANCE instance_name;

instance_name specifies the name of the binlog instance to be stopped.

Examples

Stop the binlog instance named eo46r4f2e8.

STOP BINLOG INSTANCE eo46r4f2e8;

After the binlog instance is stopped, you can execute the SHOW BINLOG INSTANCES eo46r4f2e8; statement to view its status. In the output, the value of state is changed to Stop. Here is an example:

+------------+------------+-----------+---------------+------+------+--------+-------+---------+---------+---------------+-------------+--------------+-----------------+---------------+-------------+-------------+--------------+---------+------------------------------------------------+----------+
| name       | ob_cluster | ob_tenant | ip            | port | zone | region | group | running | state   | obcdc_running | obcdc_state | service_mode | convert_running | convert_delay | convert_rps | convert_eps | convert_iops | dumpers | version                                        | odp_addr |
+------------+------------+-----------+---------------+------+------+--------+-------+---------+---------+---------------+-------------+--------------+-----------------+---------------+-------------+-------------+--------------+---------+------------------------------------------------+----------+
| eo46r4f2e8 | obdemo     | test1     | 10.10.10.1    | 8106 |      |        |       | No      | Stop    | No            | Stop        | disabled     | No              |          NULL |        NULL |        NULL |         NULL |    NULL | 4.0.1-92748c6c59534426d187977b13b61b7cdf4fa200 | NULL     |
+------------+------------+-----------+---------------+------+------+--------+-------+---------+---------+---------------+-------------+--------------+-----------------+---------------+-------------+-------------+--------------+---------+------------------------------------------------+----------+

Start a binlog instance

You can start the specified binlog instance.

Syntax

START BINLOG INSTANCE instance_name;

instance_name specifies the name of the binlog instance to be started.

Examples

Start the binlog instance named eo46r4f2e8.

START BINLOG INSTANCE eo46r4f2e8;

Switch the primary binlog instance

You can switch the primary binlog instance of the specified tenant.

Syntax

SWITCH MASTER INSTANCE TO instance_name FOR TENANT cluster.tenant [FULL]

The following table describes the parameters.

Parameter Description
instance_name The name of the binlog instance to be switched to become the primary binlog instance.
cluster.tenant The name of the tenant to which the binlog instance to be switched to become the primary binlog instance belongs, and the name of the cluster to which the tenant belongs.
FULL Optional. Specifies whether to terminate existing subscription connections of the original primary binlog instance. You do not need to specify a value for this parameter. If you specify this parameter, existing subscription connections are terminated.

Examples

Switch the primary binlog instance for the test1 tenant in the obdemo cluster.

  1. Query the node where the primary binlog instance resides.

    SHOW BINLOG SERVER FOR TENANT obdemo.test1;
    

    The output is as follows, indicating that the primary binlog instance resides on the server with the IP address 10.10.10.1 and port number 8103.

    +---------+--------+------------+------+--------+-------+
    | cluster | tenant | ip         | port | status | cause |
    +---------+--------+------------+------+--------+-------+
    | obdemo  | test1  | 10.10.10.1 | 8103 | OK     |  NULL |
    +---------+--------+------------+------+--------+-------+
    
  2. Switch the primary binlog instance.

    SWITCH MASTER INSTANCE TO eo46r4f2e8 FOR TENANT obdemo.test1;
    
  3. Query the node where the primary binlog instance resides again.

    SHOW BINLOG SERVER FOR TENANT obdemo.test1;
    

    The output is as follows, indicating that the primary binlog instance resides on the server with the IP address 10.10.10.1 and port number 8106.

    +---------+--------+------------+------+--------+-------+
    | cluster | tenant | ip         | port | status | cause |
    +---------+--------+------------+------+--------+-------+
    | obdemo  | test1  | 10.10.10.1 | 8106 | OK     |  NULL |
    +---------+--------+------------+------+--------+-------+
    

Release a binlog instance

You can drop the specified binlog instance, as well as its binlog files.

Syntax

DROP BINLOG INSTANCE instance_name [FORCE]

Parameters

Parameter Description
instance_name The name of the binlog instance to be dropped.
FORCE Optional. Specifies whether to forcibly drop the binlog instance. If you specify this parameter, you can drop a running binlog instance. If you do not specify this parameter and the specified binlog instance is not stopped, an error is returned when you execute the DROP BINLOG INSTANCE statement.

Examples

Forcibly drop the binlog instance named binlog2.

DROP BINLOG INSTANCE binlog2 FORCE;
Contact Us