If you have previously deployed an OceanBase cluster on your machine and now want to deploy a new one, clean up the old cluster before deploying the new one.
This topic describes several scenarios. You can choose the appropriate scenario based on your own cluster situation.
Suggestions for cleaning up an old cluster
Before cleaning up the old cluster environment, it is recommended that you back up the data first. This ensures data integrity and security, and ensures that you have a copy of the data for restoration or migration if needed in the future.
For information about backing up OceanBase cluster data, see Prepare for backup.
Scenario 1: OceanBase cluster deployed using the command line
If the cluster on your machine was manually deployed using the command line, you can refer to this section for cleanup.
Step 1: Stop and uninstall the service
Stop the old observer processes and ensure they are no longer running. Then, uninstall the related database software. The procedure is as follows:
Notice
After stopping the observer processes, OceanBase Database will be unavailable. Therefore, before proceeding to the following steps, please confirm again that the cluster is no longer in use and that all data requiring backup has been backed up. Proceed with caution to avoid data loss or system unavailability.
Run the following command to check if the observer process exists.
ps -ef|grep observer(Optional) Stop the observer process.
If an observer process exists on your machine, run the following command to stop the old observer process:
kill -9 `pidof observer`Run the following command to view the name of the installed OceanBase Database RPM package.
rpm -qa|grep oceanbaseRun the following command to uninstall the installed OceanBase Database RPM package.
sudo rpm -e $rpm_nameHere,
$rpm_nameis the name of the software package to be uninstalled.You can run the following command to check if the RPM package has been uninstalled.
rpm -ql $rpm_nameRepeat steps 1 through 4 until all services on all OBServer nodes have been stopped and uninstalled.
Step 2: Clean up database files
Delete old database files, including data files, log files, and other temporary files.
Notice
The following deletion operations are irreversible, meaning the deleted files and directories cannot be restored. Therefore, before executing the following commands, ensure that the data in the directory to be deleted is no longer in use.
Use the following command to delete the observer process runtime log disk file.
sudo rm -rf /home/admin/oceanbase/*Use the following command to delete the observer process log disk file.
sudo rm -rf /data/log1/*Use the following command to delete the observer process data disk file.
sudo rm -rf /data/1/*Repeat steps 1 through 3 until all old database files on the OBServer nodes are deleted.
Scenario 2: OceanBase cluster deployed using OBD
If the cluster on your machine was deployed using OBD commands, you can refer to this section for cleanup.
Check the cluster status.
obd cluster listThe output is as follows. For detailed status information, see obd cluster list.
+---------------------------------------------------------+ | Cluster List | +------+--------------------------------+-----------------+ | Name | Configuration Path | Status (Cached) | +------+--------------------------------+-----------------+ | test | /home/admin/.obd/cluster/test | running | | demo | /home/admin/.obd/cluster/demo | running | +------+--------------------------------+-----------------+Check if a standby tenant exists.
This example uses the test cluster; modify the cluster name according to your actual situation.
obd cluster tenant show test -gThe output indicates no standby tenants exist, and the cluster contains only the sys tenant. If a standby tenant exists in the cluster, refer to Create a standby tenant for the output content and detailed field meanings.
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | 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 a standby tenant exists in the cluster, an error will be reported when destroying the cluster. In this case, you can choose to decouple the primary and standby tenants or forcibly execute the destruction command, which will render the standby tenant unusable after the cluster is destroyed. Decide whether to perform this step based on your actual scenario.
For detailed operations on decoupling primary and standby tenants, see Decouple primary and standby tenants.
Destroy the cluster.
Note
The
obd cluster destroycommand is irreversible. It stops the observer process and clears the database files. Before executing the following command, ensure the cluster is no longer in use and all data that needs backup has been backed up.This example uses the test cluster; modify the cluster name according to your actual situation.
obd cluster destroy test -f [--igs]-fforces the termination of any running processes in the working directory before destroying the cluster.--igsforcibly executes theobd cluster destroycommand if it detects that a tenant's standby tenant exists in another cluster.
Scenario 3: OceanBase cluster deployed using systemd
If the cluster on your machine is deployed using systemd, you can refer to this section for cleanup.
Stop OceanBase Database.
[admin@test001 ~]$ sudo systemctl stop oceanbaseUninstall OceanBase Database.
Remove 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 removed. You can view the package name by running theyum list | grep oceanbasecommand.For offline installation, run the following command:
[admin@test001 ~]$ sudo rpm -e packageReplace
packagewith the name of the package to be removed. You can view the package name by running therpm -qa | grep oceanbasecommand.(Optional) Delete OceanBase Database data.
Note
After the package is deleted, OceanBase Database is uninstalled from your environment, but the data remains. If you redeploy OceanBase Database later, you can still view and operate this data. After executing this step to delete OceanBase Database data, the deployed OceanBase Database will be completely uninstalled. Therefore, before running the following commands, ensure that the data in the directory to be deleted is no longer in use.
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 are managing an OceanBase cluster using OceanBase Cloud Platform (OCP), simply follow the prompts on the relevant operation interface to delete the cluster. For detailed operations, see Delete a cluster.
If you have deployed OceanBase Database in a Kubernetes environment, you can manage the OceanBase cluster using ob-operator. For detailed operations on deleting a cluster, see Delete a cluster.
