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 how to clear an OceanBase cluster by using the CLI.
Applicability
This topic applies only to OceanBase clusters that are deployed following the steps of deploying OceanBase Database Enterprise Edition.
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 for backup.
Procedure
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. That is, the deleted files and directories cannot be recovered. Therefore, before you run the following commands, make sure that the data in the directories is backed up or no longer needed.
Run the following command to remove files on the operational 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.
References
If you are using OceanBase Cloud Platform (OCP) to manage an OceanBase cluster, you can delete a cluster as prompted. For more information, see Delete a cluster.