If you have deployed an OceanBase cluster on your server and want to deploy a new OceanBase cluster on the same server, clean up the old cluster before you deploy the new one.
This topic describes the process of cleaning up an old cluster in two scenarios. Choose the one that suits your needs.
We recommend that you clear out old clusters.
Before you clear the old cluster environment, we recommend that you back up the data. This ensures the integrity and security of the data and provides a data copy that you can restore or migrate in the future.
For more information about how to back up data from an OceanBase cluster, see Prepare for a backup.
Scenario 1: Deploy an OceanBase cluster using the CLI
You can use the CLI to deploy an OceanBase cluster and manage it.
If you manually deployed the cluster on your machine through the CLI, you can perform the cleanup procedure outlined in this topic.
Step 1: Stop and uninstall the service
Stop the old observer process and make sure that it is no longer running. Then, uninstall the relevant database software. The steps are as follows:
Notice
After the observer process is stopped, OceanBase Database will become unavailable. Therefore, before you perform the following operations, make sure that the cluster is no longer in use and all necessary data has been backed up. Proceed with caution to avoid 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 your server has an observer process, run the following command to stop the old observer process:
kill -9 `pidof observer`
- Run the following command to view the name of the RPM package of OceanBase Database that has been installed.
rpm -qa|grep oceanbase
- Run the following command to uninstall the OceanBase Database RPM package.
sudo rpm -e $rpm_name
In this case, $rpm_name is the name of the software package to be uninstalled.
You can use the following command to check whether the RPM package has been uninstalled.
rpm -ql $rpm_name
- Repeat steps 1 to 4 until the services on all OBServer nodes are stopped and uninstalled.
Step 2: Clear database files
Delete the old database files, including data files, log files, and temporary files.
Notice
Once a file or directory is deleted, it cannot be restored. Therefore, make sure that the data in the target directory is no longer used before you perform the following operations.
- Run the following command to delete the log disk file of the observer process.
sudo rm -rf /home/admin/oceanbase/*
- Run the following command to delete the log disk file of the observer process.
sudo rm -rf /data/log1/*
- Run the following command to delete the data disk file of the observer process.
sudo rm -rf /data/1/*
Scenario 2: OceanBase cluster deployed using OBD
If the cluster in your machine was deployed using OBD commands, you can follow the instructions in this section to clear it.
Check the status of the cluster.
obd cluster listIn the following sample output, for more information about the status, see obd cluster list.
+--------------------------------------------------------+ | Cluster List | +------+-------------------------------+-----------------+ | Name | Configuration Path | Status (Cached) | +------+-------------------------------+-----------------+ | test | /home/admin/.obd/cluster/odp | running | | demo | /home/admin/.obd/cluster/demo | running | +------+-------------------------------+-----------------+Check whether the cluster has a standby tenant.
For this example, the test cluster is used. You need to modify the cluster name to the actual one.
obd cluster tenant show test -gIf the following output is returned, the cluster has no standby tenants and only the sys tenant is present. For more information, see Deploy primary and standby tenants using OBD.
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | 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 primary and standby tenants.
If the cluster has standby tenants, an error will be returned when you attempt to destroy the cluster. In this case, you can decouple the primary and standby tenants or forcibly destroy the cluster. If you forcibly destroy the cluster, the standby tenants will become unavailable after the cluster is destroyed. You can choose either option based on your business needs.
For more information, see Decouple primary and standby tenants.
Destroy the cluster.
Notice
The
obd cluster destroycommand cannot be reversed. It will clear the database files while stopping the observer process. Therefore, before you run the following command, make sure that the cluster is no longer in use and all the data that needs to be backed up has been backed up.In the following example, the test cluster is destroyed. You need to modify the cluster name to the actual one.
obd cluster destroy test -f [--igs]-fspecifies to forcibly stop the running processes in the working directory before destroying the cluster.--igsspecifies to forcibly destroy the cluster when it is found that the cluster contains tenants that have standby tenants in other clusters.
References
If you are using OceanBase Cloud Platform (OCP) to manage the OceanBase cluster, you can directly delete the cluster in the OCP console. For more information, see Delete a cluster.
If you have deployed OceanBase Database in a Kubernetes environment, you can use ob-operator to manage the OceanBase cluster. For more information, see Delete a cluster.