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 three scenarios. Choose the one that suits your situation.
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 can be restored or migrated 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 have manually deployed a cluster on your server through the CLI, you can perform the cleanup operations described in this topic.
Step 1: Stop and uninstall the service
Stop the old observer process and make sure 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, make sure that the cluster is no longer in use and the data to be backed up has been backed up before you proceed. 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 machine 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 oceanbaseRun the following command to uninstall the OceanBase Database RPM package.
sudo rpm -e $rpm_nameIn this command,
$rpm_nameis 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_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 operations are irreversible, that is, files and directories deleted cannot be restored. Therefore, make sure that the data in the directory to be deleted 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/*Repeat steps 1 to 3 until all old database files in all OBServer nodes are deleted.
Scenario 2: OceanBase cluster deployed using OBD
If your cluster was deployed using the OBD commands, follow the steps in this section to clear it.
View the status of the cluster.
obd cluster listThe command output is as follows. For more information about the states, 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 a standby tenant exists.
This example uses the test cluster. You must modify the cluster name to the actual one in your situation.
obd cluster tenant show test -gIf the output shows that there are no standby tenants and the cluster contains only the sys tenant, proceed to the next step. For more information, see Deploy a primary/standby tenant 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 standby tenants, an error will occur when you attempt to delete the cluster. In this case, you can decouple the primary and standby tenants, or you can forcibly delete the cluster. Note that the standby tenants will become unavailable after the cluster is deleted. Whether you perform this step depends on your business scenario.
For more information, see Decouple a primary tenant from a standby tenant.
Destroy the cluster.
Notice
The
obd cluster destroycommand is irreversible. It will stop the observer process and clear the database files. Therefore, make sure that the cluster is no longer in use and all the data to be backed up has been backed up before you execute this command.This example uses the test cluster. You must modify the cluster name according to the actual situation.
obd cluster destroy test -f [--igs]The
-foption specifies to forcibly stop the running processes in the working directory and destroy the cluster.The
--igsoption specifies that theobd cluster destroycommand be executed when a tenant in the cluster has a standby tenant in another cluster.
Scenario 3: OceanBase cluster deployed using systemd
If the cluster in your machine is deployed using systemd, 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 package.
If you installed OceanBase Database 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 you installed OceanBase Database 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 remain 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 no longer 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 use 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 deploy OceanBase Database in a Kubernetes environment, you can use ob-operator to manage the OceanBase cluster. For more information, see Delete a cluster.