If you have deployed an OceanBase cluster on your server and want to deploy a new OceanBase cluster on the same server, you must first clear the old cluster.
This topic is organized into three scenarios. Choose the one that best fits your cluster.
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 copy that you can restore or migrate when needed 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
If you manually deployed the cluster on your server using the command line, you can perform the cleanup procedures outlined in this topic.
Step 1: Stop and uninstall the service
Stop the old observer process and make sure it has stopped. Then, uninstall the related 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 the data to be backed up 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 OceanBase Database RPM package that has been installed.
rpm -qa|grep oceanbaseRun the following command to uninstall the OceanBase Database RPM package.
sudo rpm -e $rpm_nameIn this example,
$rpm_nameis the name of the software package to be uninstalled.You can run the following command to check whether the RPM package has been uninstalled.
rpm -ql $rpm_nameRepeat 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
The following deletion operations are irreversible, that is, the deleted files and directories cannot be restored. Therefore, make sure that the data in the target directory is no longer used before you perform the following commands.
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/*Repeat steps 1 to 3 until all old database files in all OBServer nodes are deleted.
Scenario 2: OceanBase cluster deployed using obd
If the cluster was deployed using the obd command, you can follow the steps below to delete 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.
In 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 contains only the sys tenant and no standby tenant. 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 contains a standby tenant, 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. Note that after the cluster is destroyed, the standby tenants will not be available. Whether to perform either operation depends on your business scenario.
For more information, see Decouple a primary tenant from its standby tenant.
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 this example, the test cluster is used. You need to modify the cluster name to the actual one.
obd cluster destroy test -f [--igs]-fspecifies to forcibly stop the running process in the working directory and then destroy the cluster.--igsspecifies to forcibly destroy the cluster when a standby tenant exists in another cluster.
Scenario 3: OceanBase cluster deployed using systemd
If the cluster is deployed using systemd on your server, you can follow the instructions in this section to perform the cleanup.
Stop OceanBase Database.
[admin@test001 ~]$ sudo systemctl stop oceanbaseUninstall OceanBase Database.
Delete the OceanBase Database software package.
If OceanBase Database is installed online, you can run the following command:
[admin@test001 ~]$ sudo yum erase packageReplace
packagewith the name of the package to be deleted. You can use theyum list | grep oceanbasecommand to view the package name.If OceanBase Database is installed offline, you can run the following command:
[admin@test001 ~]$ sudo rpm -e packageReplace
packagewith the name of the package to be deleted. You can use therpm -qa | grep oceanbasecommand to view the package name.(Optional) Delete the data of OceanBase Database.
Note
After you uninstall OceanBase Database, the data of OceanBase Database will still exist in your environment. If you redeploy OceanBase Database, you can view and manage the data of the OceanBase Database. By deleting the data of OceanBase Database, it will be completely uninstalled. Therefore, make sure that the data to be deleted is not being used.
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 you manage the OceanBase cluster using OceanBase Cloud Platform (OCP), you can directly delete the cluster in the OCP console. For more information, see Delete a cluster.
If you deploy OceanBase Database in a Kubernetes environment, you can use ob-operator to manage the OceanBase cluster. For more information, see Delete a cluster.