If you have ever deployed an OceanBase cluster on your machine and now want to deploy a new OceanBase cluster, clean up the old cluster before you deploy the new one.
This topic describes two scenarios. Choose the one that matches your environment.
Considerations
Before you clean up an old OceanBase cluster environment, we recommend that you back up your data first. This helps ensure data integrity and safety, and gives you a copy you can use later for restore or migration if needed.
For more information about backing up an OceanBase cluster, see Preparations for backup.
Scenario 1: OceanBase cluster deployed by using the command line
If the cluster on your machine was deployed manually from the command line, follow this section to clean it up.
Step 1: Stop and uninstall services
Stop the old observer processes and make sure they are no longer running. Then uninstall the related database software. The steps are as follows:
Notice
After the observer processes are stopped, OceanBase Database will be unavailable. Before you run the following steps, confirm again that the cluster is no longer in use and that any data you need has been backed up. Proceed with caution to avoid data loss or system unavailability.
Run the following command to check whether an 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 list the installed OceanBase Database RPM package names.
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 package to uninstall.You can run the following command to verify that the RPM package has been removed.
rpm -ql $rpm_nameRepeat steps 1 through 4 until services on all OBServer nodes are 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 delete operations are irreversible: deleted files and directories cannot be recovered. Before you run the commands, confirm that the data under the directories to delete is no longer needed.
Run the following command to delete files on the observer process runtime log disk.
sudo rm -rf /home/admin/oceanbase/*Run the following command to delete files on the observer process log disk.
sudo rm -rf /data/log1/*Run the following command to delete files on the observer process data disk.
sudo rm -rf /data/1/*Repeat steps 1 through 3 until old database files are removed on all OBServer nodes.
Scenario 2: OceanBase cluster deployed by using obd
If the cluster on your machine was deployed with obd, follow this section to clean it up.
View cluster status
obd cluster listSample output is as follows. For a detailed description of the status fields, 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 whether a standby tenant exists
This section uses the
testcluster as an example. Replace the cluster name with your actual cluster name.obd cluster tenant show test -gSample output is as follows, indicating that no standby tenant exists and the cluster has only the
systenant. If a tenant in the cluster has a standby tenant, for detailed descriptions of the output and field meanings, see Create a 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 primary and standby tenants
If a tenant in the cluster has a standby tenant, destroying the cluster may report an error. You can decouple the primary and standby tenants first, or run a forced destroy command. After the cluster is destroyed with force, the standby tenant will no longer be usable. Perform this step only if it fits your scenario.
For detailed steps, see Decouple primary and standby tenants.
Destroy the cluster
Notice
The
obd cluster destroycommand is irreversible: it stops observer processes and removes database files. Before you run the following command, confirm that the cluster is no longer in use and that any data you need has been backed up.This section uses the
testcluster as an example. Replace the cluster name with your actual cluster name.obd cluster destroy test -f [--igs]-fmeans that if a running process is found under the working directory, the process is stopped by force and the cluster is destroyed.--igsmeans that if a tenant in the cluster has a standby tenant in another cluster, theobd cluster destroycommand is executed by force.
References
If you use OceanBase Cloud Platform (OCP) to manage OceanBase clusters, delete a cluster from the console as prompted. For details, see Delete a cluster.
