After you delete a binlog server, you can clear the binlog instances on the host based on the description of this topic.
Prerequisites
- The binlog server on the host has been deleted from the OceanBase Cloud Platform (OCP) console and the deletion task has been completed.
- The host will be pulled offline, or binlog-related content on the host needs to be completely cleared.
- At least one binlog instance replica exists on the host and the binlog instance is still needed later. You can confirm whether a binlog instance exists on a host by using either of the following ways:
- Method 1: Log on to the OCP console, go to the
Binlog Cluster Overview page, and view the instance information in theBinlog Instance List section. - Method 2: Log on to the host and run the
ps -ef | grep binlog_instancecommand. In the output, one binlog instance replica corresponds to one binlog_instance process.
- Method 1: Log on to the OCP console, go to the
Procedure
In the following procedure, the host where the binlog server to delete resides is referred to as the host.
Step 1: Query the number of binlog instance replicas
Query on the OCP console
Log on to the OCP console.
In the left-side navigation pane, click
Binlog Service . TheCluster List tab automatically appears.On the
Cluster List page, find the target binlog cluster and click its name to go to theBinlog Cluster Overview page.In the
Binlog Instance List section, view the number of binlog instance replicas, which equals the number of node IP addresses in theNode IP Address column.
Query on the CLI
Log on to any host and execute the following statement to check whether the number of binlog instance replicas to be operated exceeds 1. In the sample output, tenant1 has two binlog instance records, which means two replicas.
MySQL [(none)]> SHOW BINLOG INSTANCES FOR cluster.tenant;
+------------+------------+-----------+----------------+------+------+--------+-------+---------+---------+---------------+-------------+--------------+-----------------+---------------+-------------+-------------+--------------+----------+
| 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 | odp_addr |
+------------+------------+-----------+----------------+------+------+--------+-------+---------+---------+---------------+-------------+--------------+-----------------+---------------+-------------+-------------+--------------+----------+
| ad6tev7wc6 | ob0709 | tenant1 | xxx.xxx.xxx.xxx | 8100 | | | | Yes | Running | Yes | Running | enabled | Yes | 804 | 1 | 0 | 0 | NULL |
| c5410cbup4 | ob0709 | tenant1 | xxx.xxx.xxx.xxx | 8100 | | | | Yes | Running | Yes | Running | enabled | Yes | 607 | 1 | 0 | 0 | NULL |
+------------+------------+-----------+----------------+------+------+--------+-------+---------+---------+---------------+-------------+--------------+-----------------+---------------+-------------+-------------+--------------+----------+
2 rows in set (0.12 sec)
Step 2: Create a binlog instance replica (skip this step if two or more replicas exist)
Execute the following statement to create a new binlog instance replica on another host:
CREATE BINLOG INSTANCE `binlog_instance_name` FOR `ob_cluster_name`. `ob_tenant_name` CLUSTER_URL = ?, CLUSTER_USER = ?, CLUSTER_PASSWORD = ?, IP = ?;
The parameters in the statement are described as follows:
binlog_instance_name: the name of the new binlog instance, which must be unique in the binlog cluster.ob_cluster_name: the name of the OceanBase cluster.ob_tenant_name: the name of the OceanBase Database tenant.CLUSTER_URL: the ConfigUrl of the cluster to which the tenant with the binlog service enabled belongs. You can view the ConfigUrl of a cluster on itsOverview page. For more information, see View the details of a cluster.CLUSTER_USER: the user of the cluster. We recommend that you use thecdcrouser created by OCP in the sys tenant when the binlog service is enabled for a tenant, or another user with the same permissions as thecdcrouser.CLUSTER_PASSWORD: the password of the user specified byCLUSTER_USER.IP: the IP address of the binlog server where the new instance replica is to be created.
Step 3: Switch another instance to the PRIMARY role if the binlog instance on the host is a primary instance
Check whether the binlog instance on the current host is a primary instance.
Log on to any host and execute the following statement to query the primary instance on the host. The instance name is indicated by
binlog_instancein thestatussection. Check whether the binlog instance on the current host is a primary instance based on the return result. You can view the instance name based onStep 1 .MySQL [(none)]> SHOW BINLOG STATUS FOR TENANT cluster.tenant *************************** 1. row *************************** cluster: ob0709 tenant: tenant1 status: {"binlog_instance":" ad6tev7wc6","resources_metrics": {"client_id":" /home/admin/binlogservice/run/ad6tev7wc6","fd_count":83,"pid":370592,"cpu_status": {"cpu_count":22,"cpu_used_ratio":0.0009103322518058121},"disk_status": {"disk_total_size_mb":500923,"disk_usage_size_process_mb":0,"disk_used_ratio":0.0,"disk_used_size_mb":32945},"memory_status": {"mem_total_size_mb":178796,"mem_used_ratio":0.005386026576161385,"mem_used_size_mb":963},"network_status": {"network_rx_bytes":25383,"network_wx_bytes":25026}},"binlog_files": [{"binlog_name":" mysql-bin.000001","binlog_size":155}]} 1 row in set (0.01 sec)If the binlog instance on the current host is a primary instance, execute the
SWITCH MASTER INSTANCE TO new_master_instance_name FOR TENANT cluster_name.tenant_namestatement to switch another instance to the PRIMARY role. The parameters in the statement are described as follows:new_master_instance_name: the name of the instance to be switched to the PRIMARY role.cluster_name: the name of the OceanBase cluster.tenant_name: The name of the tenant.
MySQL [(none)]> SWITCH MASTER INSTANCE TO c5410cbup4 FOR TENANT ob0709.tenant1 ; Query OK, 0 rows affected (0.01 sec)
Step 4: Delete the binlog instance replica from the host
Execute the DROP BINLOG INSTANCE instance_name FORCE statement to delete the binlog instance replica from the host.
MySQL [(none)]> DROP BINLOG INSTANCE c5410cbup4 FORCE;
Query OK, 0 rows affected (0.00 sec)