If you have deployed an OceanBase cluster on your servers and you want to deploy a new OceanBase cluster, you must clear the old cluster before you deploy the new one.
This topic describes three scenarios. You can refer to the steps for an appropriate scenario based on the actual situation.
Considerations
Before you clear the environment of an OceanBase cluster, we recommend that you back up your data. This ensures the integrity and security of your data and provides you a data copy for restore or migration in the future.
For more information about how to back up data for an OceanBase cluster, see Preparations.
Scenario 1: Clear an OceanBase cluster deployed by using the CLI
If your cluster is manually deployed by using the CLI, perform the following steps to clear the cluster:
Step 1: Stop and uninstall services
Stop the old observer processes and ensure that they are not running. Then, uninstall the related database software. The procedure is as follows:
Notice
OceanBase Database becomes unavailable after the observer processes are stopped. Therefore, before you perform the following steps, make sure that the old OceanBase cluster is no longer in use and the data is backed up. Proceed with caution to avoid unexpected data loss or system unavailability.
Run the following command to check whether the observer process exists:
ps -ef|grep observer(Optional) Stop the observer process.
If the observer process exists on your server, run the following command to stop the observer process:
kill -9 `pidof observer`Run the following command to view the name of the installed RPM package of OceanBase Database:
rpm -qa|grep oceanbaseRun the following command to uninstall the RPM package of OceanBase Database:
sudo rpm -e $rpm_nameHere,
$rpm_nameis the name of the RPM package to be uninstalled.You can run the following command to check whether the RPM package is completely uninstalled.
rpm -ql $rpm_nameRepeat steps 1 to 4 until services on all OBServer nodes are stopped and uninstalled.
Step 2: Clean up the database files
Remove the obsolete database files, including data files, log files, and other temporary files.
Notice
The following operations are irreversible. In other words, the deleted files and directories cannot be recovered. Therefore, before you run the following commands, make sure that the data in the directories is no longer needed.
Run the following command to remove files on the runtime log disk of the observer process:
sudo rm -rf /home/admin/oceanbase/*Run the following command to remove files on the log disk of the observer process:
sudo rm -rf /data/log1/*Run the following command to remove files on the data disk of the observer process:
sudo rm -rf /data/1/*Repeat steps 1 to 3 until all database files are removed from all OBServer nodes.
Scenario 2: Clear an OceanBase cluster deployed by using obd
If your cluster is deployed by using OceanBase Deployer (obd), perform the following steps to clear the cluster:
Query the cluster status.
obd cluster listThe output is as follows. For more information, see the obd cluster list section in Cluster commands.
+--------------------------------------------------------+ | Cluster List | +------+-------------------------------+-----------------+ | Name | Configuration Path | Status (Cached) | +------+-------------------------------+-----------------+ | test | /home/admin/.obd/cluster/odp | running | | demo | /home/admin/.obd/cluster/demo | running | +------+-------------------------------+-----------------+Check whether a standby tenant exists.
We will use the
testcluster as an example. Make sure to replace it with the actual cluster name when you run the following command.obd cluster tenant show test -gThe output is as follows, indicating that no standby tenant exists and the cluster contains only the
systenant. If a tenant in the cluster has a standby tenant, you can see the Deploy primary and standby tenants by using obd topic for the output and field description.+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | tenant base info | +-------------+-------------+--------------------+--------------+---------+---------+-------------+---------------------+---------------------+---------------+-------------+-------------+ | tenant_name | tenant_type | compatibility_mode | primary_zone | max_cpu | min_cpu | memory_size | max_iops | min_iops | log_disk_size | iops_weight | tenant_role | +-------------+-------------+--------------------+--------------+---------+---------+-------------+---------------------+---------------------+---------------+-------------+-------------+ | sys | SYS | MYSQL | RANDOM | 3.0 | 3.0 | 1024M | 9223372036854775807 | 9223372036854775807 | 2048M | 3 | PRIMARY | +-------------+-------------+--------------------+--------------+---------+---------+-------------+---------------------+---------------------+---------------+-------------+-------------+(Optional) Decouple the standby tenant from the primary tenant.
If a tenant in the cluster has a standby tenant, attempting to destroy the cluster will return an error. To proceed, either decouple the standby tenant from the primary tenant first or forcibly destroy the cluster. After the cluster is forcibly destroyed, the standby tenant will be unavailable. You can determine whether to perform this step based on the actual situation.
For more information, see Switch the roles of tenants and decouple a standby tenant from the primary tenant.
Destroy the cluster.
Notice
The
destroycommand is irreversible. Data files will be cleared while the observer processes are stopped. Therefore, before you run the following commands, make sure that the cluster is no longer needed and the data has been backed up.We will use the
testcluster as an example. Make sure to replace it with the actual cluster name when you run the following command.obd cluster destroy test -f [--igs]-f: If a running process is detected in the working directory, the process is forcibly stopped and the cluster is destroyed.--igs: If a tenant in the cluster has a standby cluster in another cluster, theobd cluster destroycommand is forcibly executed.
Scenario 3: Clear an OceanBase cluster deployed by using systemd
If your cluster is deployed by using systemd, perform the following steps to clear the cluster:
Stop OceanBase Database.
[admin@test001 ~]$ sudo systemctl stop oceanbaseUninstall OceanBase Database.
Delete the package of OceanBase Database.
If you have installed OceanBase Database online, run the following command to delete the package:
[admin@test001 ~]$ sudo yum erase packageYou must replace
packagewith the actual name of the package to be deleted. To view the package name, run theyum list | grep oceanbasecommand.If you have installed OceanBase Database offline, run the following command to delete the package:
[admin@test001 ~]$ sudo rpm -e packageYou must replace
packagewith the actual name of the package to be deleted. To view the package name, run therpm -qa | grep oceanbasecommand.(Optional) Delete the data of OceanBase Database.
Note
After the package is deleted, OceanBase Database is uninstalled but its data is retained in your environment. If you deploy OceanBase Database again later, you can still view and operate the retained data. After you perform this step, the data of OceanBase Database is completely deleted. Therefore, before you run the following commands, make sure that the data in the directories is no longer needed.
Delete the installation directory of OceanBase Database.
[admin@test001 ~]$ sudo rm -rf /home/admin/oceanbaseDelete the data directory of OceanBase Database.
[admin@test001 ~]$ sudo rm -rf /var/lib/oceanbase
References
If your OceanBase cluster is managed by using OceanBase Cloud Platform (OCP), you can delete the cluster as prompted. For more information, see Delete a cluster.
If your OceanBase cluster is deployed in a Kubernetes environment, you can manage your cluster by using ob-operator. For more information about how to delete a cluster in this case, see Delete a cluster.