Create a binlog task
You can enable the binlog service for the specified OceanBase Database tenant. Then, the binlog server will asynchronously create N binlog instances for the tenant. After you execute the CREATE BINLOG statement, resources will be allocated. If the resource allocation is successful, an OK message is immediately returned. If less than N binlog instances are successfully created, a warning message is returned.
Syntax
CREATE BINLOG [IF NOT EXISTS] FOR TENANT cluster.tenant
[FROM timestamp] [TO USER user PASSWORD pwd]
WITH CLUSTER URL cluster_url [, binlog_option [, binlog_option...]];
binlog_option:
INITIAL_TRX_XID
| INITIAL_TRX_GTID_SEQ
| REPLICATE NUM
| SERVER UUID
Parameters
| Parameter | Description |
|---|---|
| IF NOT EXISTS | Optional. If you specify IF NOT EXISTS and the binlog task to be created already exists, the system does not report an error or create the task again. If you do not specify this parameter and the binlog task to be created already exists, the system reports an error. |
| cluster.tenant | The name of the tenant for which the binlog task is to be created, and the name of the cluster to which the tenant belongs. |
| timestamp | Optional. The startup timestamp. If you do not specify this parameter, the binlog task starts from the current timestamp. |
| user | Optional. The username of a user in the sys tenant of the OceanBase cluster. If you have specified the username and password of a user in the sys tenant when you start the binlog server, skip this parameter. |
| pwd | Optional. The password of the user specified by user in the sys tenant. If you have specified the username and password of a user in the sys tenant when you start the binlog server, skip this parameter. |
| cluster_url | The ConfigUrl of the OceanBase cluster, which must be enclosed in quotation marks. You can obtain the value of this parameter by executing the SHOW PARAMETERS LIKE 'obconfig_url'; statement. |
| binlog_option | Optional. Options of the binlog task, which are separated with commas (,). Separate the options and the ConfigUrl with a comma (,). Valid values:
|
Example
Create a binlog task for the test1 tenant in the obdemo cluster and create three binlog instances for the tenant.
CREATE BINLOG FOR TENANT `obdemo`.`test1`
TO USER `root` PASSWORD `********`
WITH CLUSTER URL `http://10.10.10.1:8080/services?Action=ObRootServiceInfo&ObCluster=demo`
, REPLICATE NUM 3;
Query a binlog task
You can query the binlog files and resource metrics of the primary binlog instance in a binlog task. If the primary binlog instance is unavailable, an empty result set is returned.
Syntax
SHOW BINLOG STATUS [FOR TENANT cluster.tenant];
cluster.tenant specifies the name of the tenant whose binlog task is to be queried and the name of the cluster to which the tenant belongs. If you directly execute SHOW BINLOG STATUS without specifying FOR TENANT cluster.tenant, which is optional, information about the primary binlog instances of all binlog tasks is returned. If you specify FOR TENANT cluster.tenant, information about the primary binlog instance of the specified tenant is returned. Here is an example:
SHOW BINLOG STATUS FOR TENANT obdemo.test1;
The output is as follows:
+-----------+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| cluster | tenant | status |
+-----------+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| obdemo | test1 | {"binlog_instance":"gldwt7bnco","resources_metrics":{"client_id":"/home/admin/oblogproxy/run/gldwt7bnco","fd_count":78,"pid":12058,"cpu_status":{"cpu_count":8,"cpu_used_ratio":0.006535947788506746},"disk_status":{"disk_total_size_mb":307048,"disk_usage_size_process_mb":0,"disk_used_ratio":0.0,"disk_used_size_mb":78830},"memory_status":{"mem_total_size_mb":63882,"mem_used_ratio":0.016514824703335763,"mem_used_size_mb":1055},"network_status":{"network_rx_bytes":288853,"network_wx_bytes":289725}},"binlog_files":[{"binlog_name":"mysql-bin.000001","binlog_size":155}]} |
+-----------+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
The following table describes the columns in the result set.
| Column | Description |
|---|---|
| cluster | The name of the cluster. |
| tenant | The name of the tenant. |
| status | Information about the primary binlog instance. |
Modify a binlog task
You can modify the parameter settings for all binlog instances of the specified tenant. The new settings also take effect for binlog instances created later.
Syntax
ALTER BINLOG cluster.tenant
SET binlog_instance_option [, binlog_instance_option...];
binlog_instance_option:
BINLOG_EXPIRE_LOGS_SECONDS
| BINLOG_EXPIRE_LOGS_SIZE
| FAILOVER
| EXTRA_OBCDC_CFG
Parameters
| Parameter | Description |
|---|---|
| cluster.tenant | The name of the tenant for which the binlog instance parameter settings are to be modified, and the name of the cluster to which the tenant belongs. |
| binlog_instance_option | The binlog instance parameters to be modified, which are separated with commas (,). Valid values:
|
Example
ALTER BINLOG obdemo.test1 SET BINLOG_EXPIRE_LOGS_SECONDS = 518400;
Release a binlog task
You can stop all binlog instances of the specified tenant and drop generated binlog files.
Syntax
DROP BINLOG [IF EXISTS] FOR TENANT cluster.tenant;
cluster.tenant specifies the name of the tenant whose binlog task is to be released and the name of the cluster to which the tenant belongs.
Examples
Release the binlog task of the test1 tenant in the obdemo cluster.
DROP BINLOG FOR TENANT obdemo.test1;