If you have deployed an OceanBase cluster on your machine and want to redeploy a new OceanBase cluster, clean up the old cluster before deploying the new one.
This topic describes three scenarios. You can select an appropriate scenario to refer to based on your cluster situation.
Suggestions for cleaning up old clusters
Before you clear the environment of an old 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 OceanBase cluster data backup, see Preparations for backup.
Scenario 1: OceanBase cluster deployed by using the CLI
If your cluster is manually deployed by using the CLI, refer to this section to clean it up.
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, confirm again that the cluster is no longer in use and that the data that needs to be backed up has been 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 machine, run the following command to stop it.
kill -9 `pidof observer`Run the following command to view the names of installed OceanBase Database RPM packages.
rpm -qa|grep oceanbaseRun the following command to uninstall the installed OceanBase Database RPM package.
sudo rpm -e $rpm_name$rpm_nameis the name of the package to be uninstalled.Run the following command to check whether the RPM package has been uninstalled.
rpm -ql $rpm_nameRepeat steps 1 to 4 until services on all OBServer nodes are stopped and uninstalled.
Step 2: Clean up database files
Delete the old 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 no longer needed.
Run the following command to delete files on the operational log disk of the observer process.
sudo rm -rf /home/admin/oceanbase/*Run the following command to delete files on the log disk of the observer process.
sudo rm -rf /data/log1/*Run the following command to delete files on the data disk of the observer process.
sudo rm -rf /data/1/*Repeat steps 1 to 3 until old database files are deleted from all OBServer nodes.
Scenario 2: OceanBase cluster deployed by using obd
If your cluster is deployed by using obd, refer to this section to clean it up.
View the cluster status.
obd cluster listThe output is as follows. For a detailed description of the status, see 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.
The following uses the
testcluster as an example. Replace the cluster name as needed for your environment.obd cluster tenant show test -gThe output is as follows, indicating that no standby tenant exists and the cluster contains only the sys tenant. If a tenant in the cluster has a standby tenant, for a detailed description of the output and field meanings, see Create standby tenant.
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | 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 detailed operations, see Decouple primary and standby tenants.
Destroy the cluster.
Notice
The
obd cluster destroycommand is irreversible. It stops the observer processes and clears the database files. Therefore, before you run the following commands, confirm that the cluster is no longer in use and that the data that needs to be backed up has been backed up.The following uses the
testcluster as an example. Replace the cluster name as needed for your environment.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 tenant in another cluster, theobd cluster destroycommand is forcibly executed.
Scenario 3: OceanBase cluster deployed by using systemd
If your cluster is deployed by using systemd, refer to this section to clean it up.
Stop OceanBase Database.
[admin@test001 ~]$ sudo systemctl stop oceanbaseUninstall OceanBase Database.
Delete the OceanBase Database package.
For online installation, run the following command:
[admin@test001 ~]$ sudo yum erase packageReplace
packagewith the name of the package to be deleted. You can runyum list | grep oceanbaseto view the package name.For offline installation, run the following command:
[admin@test001 ~]$ sudo rpm -e packageReplace
packagewith the name of the package to be deleted. You can runrpm -qa | grep oceanbaseto view the package name.(Optional) Delete OceanBase Database data.
Note
After the package is deleted, OceanBase Database is uninstalled but its data remains. If you redeploy OceanBase Database later, you can still view and operate that data. After you perform this step to delete OceanBase Database data, your OceanBase Database deployment will be completely uninstalled. Therefore, before you run the following commands, confirm that the data in the directories is no longer needed.
Delete the OceanBase Database installation directory.
[admin@test001 ~]$ sudo rm -rf /home/admin/oceanbaseDelete the OceanBase Database data directory.
[admin@test001 ~]$ sudo rm -rf /var/lib/oceanbase
References
If you use OceanBase Cloud Platform (OCP) to manage an OceanBase cluster, delete the cluster as prompted in the operation interface. For specific operations, see Delete a cluster.
If you deploy OceanBase Database in a Kubernetes environment, you can manage the OceanBase cluster by using ob-operator. For specific operations to delete a cluster, see Delete a cluster.