Remove YugabyteDB components from nodes

As described in Eliminate an unresponsive node, when a node enters an undesirable state, you can delete the node, with YugabyteDB Anywhere clearing up all the remaining artifacts except the prometheus and yugabyte user.

You can manually remove Yugabyte components from existing server images. Before attempting this, you have to determine whether or not YugabyteDB Anywhere is operational. If it is, you either need to delete the universe or delete the nodes from the universe.

Uninstall YugabyteDB Anywhere

If you used YBA Installer to install YugabyteDB Anywhere, you can use the clean command to uninstall the software. This removes the YugabyteDB Anywhere software, but keeps any data such as PostgreSQL or Prometheus information. Refer to Clean.

To completely eliminate all traces of YugabyteDB Anywhere and configuration, you should consider reinstalling the operating system image (or rolling back to a previous image, if available).

Delete on-premises database server nodes

You can remove YugabyteDB components and configuration from on-premises provider database server nodes as follows:

  1. Log in to the server node as the yugabyte user.

  2. Navigate to the /home/yugabyte/bin directory that contains a number of scripts including yb-server-ctl.sh. The arguments set in this script allow you to perform various functions on the YugabyteDB processes running on the node.

  3. For cron-based universes, run the following commands:

    ./bin/yb-server-ctl.sh master stop
    ./bin/yb-server-ctl.sh tserver stop
    ./bin/yb-server-ctl.sh controller stop
    

    For user systemd universes, run the following commands:

    systemctl --user stop yb-master
    systemctl --user stop yb-tserver
    systemctl --user stop yb-controller
    

    For user systemd universes, run the following commands:

    sudo systemctl stop yb-master
    sudo systemctl stop yb-tserver
    sudo systemctl stop yb-controller
    
  4. If the on-premises nodes are not manually provisioned, depending on the VM image, for files in /etc/systemd/system, /usr/lib/systemd/system, or </home/yugabyte | yb_home_dir>/.config/systemd/user, do the following:

    rm <dir>/yb-clean_cores.timer
    rm <dir>/yb-clean_cores.service
    rm <dir>/yb-zip_purge_yb_logs.timer
    rm <dir>/yb-zip_purge_yb_logs.service
    rm <dir>/yb-bind_check.service
    rm <dir>/yb-collect_metrics.timer
    rm <dir>/yb-collect_metrics.service
    rm <dir>/yb-master.service
    rm <dir>/yb-tserver.service
    rm <dir>/yb-controller.service
    systemctl daemon-reload
    
  5. Delete cron job that collects metrics, cleans cores, and purges logs. Job names include, "metric collection every minute", "cleanup core files every 5 minutes", and "cleanup yb log files every 5 minutes". Note that some job files may not exist.

  6. If node exporter exists, perform the following steps:

    1. Stop the node exporter service using the following command:

      sudo systemctl stop node_exporter
      
    2. Delete node exporter service under /etc/systemd/system, /usr/lib/systemd/system, or </home/yugabyte | yb_home_dir>/.config/systemd/user using the following command:

      rm <dir>/node_exporter.service
      
  7. If otel collector service exists, perform the following steps:

    1. Stop the otel collector service using the following command:

      sudo systemctl stop otel-collector
      
    2. Delete otel collector service under /etc/systemd/system, /usr/lib/systemd/system, or </home/yugabyte | yb_home_dir>/.config/systemd/user using the following command:

      rm <dir>/otel-collector.service
      
  8. Execute the following command:

    ./bin/yb-server-ctl.sh clean-instance
    

This removes all YugabyteDB code and settings from the node, removing it from the universe.

If you cannot find the bin directory, it means YugabyteDB Anywhere already cleared it during a successful deletion of the universe.

You should also erase the data from the volume mounted under the /data subdirectory, unless this volume is to be permanently erased by the underlying storage subsystem when the volume is deleted.

To erase this data, execute the following commands using any user with access to sudo:

sudo umount /data
sudo dd if=/dev/zero of=/dev/sdb bs=1M

The preceding commands assume the data volume is attached to the server as /dev/sdb.

If there is a requirement to remove the yugabyte user, execute the following command:

sudo userdel -r yugabyte

If there is a requirement to remove the prometheus user, execute the following command:

sudo rm -rf /opt/prometheus

You may now choose to reverse the system settings that you configured in Provision nodes manually.

Delete YugabyteDB Anywhere from the server

To remove YugabyteDB Anywhere and Replicated components from the host server, execute the following commands as the root user (or prepend sudo to each command):

systemctl stop replicated replicated-ui replicated-operator
service replicated stop
service replicated-ui stop
service replicated-operator stop
docker stop replicated-premkit
docker stop replicated-statsd
docker rm -f replicated replicated-ui replicated-operator replicated-premkit replicated-statsd retraced-api retraced-processor retraced-cron retraced-nsqd retraced-postgres
docker images | grep "quay.io/replicated" | awk '{print $3}' | xargs sudo docker rmi -f
docker images | grep "registry.replicated.com/library/retraced" | awk '{print $3}' | xargs sudo docker rmi -f
yum remove -y replicated replicated-ui replicated-operator
rm -rf /var/lib/replicated* /etc/replicated* /etc/init/replicated*  /etc/default/replicated* /etc/systemd/system/replicated* /etc/sysconfig/replicated* /etc/systemd/system/multi-user.target.wants/replicated* /run/replicated*
rpm -qa | grep -i docker
yum remove docker-ce
rpm -qa | grep -i docker
yum remove docker-ce-cli

Finally, execute the following commands to delete the /opt/yugabyte directory on the node to prevent failure if later you decide to install YugabyteDB Anywhere on a node that was previously removed using the preceding instructions:

rm -rf /var/lib/containerd
rm -rf /home/replicated
rm -rf /opt/containerd
rm -rf /opt/yugabyte

Uninstall in Kubernetes environments

You can uninstall YugabyteDB Anywhere in Kubernetes, as follows:

  1. To remove YugabyteDB Anywhere, execute the following Helm command:

    helm uninstall yw-test -n yw-test
    

    -n option specifies the namespace scope for this request.

    You should see a message similar to the following, notifying you that the subject release has been removed:

    release "yw-test" uninstalled
    
  2. Execute the following command to remove the yw-test namespace:

    kubectl delete namespace yw-test
    

    You should see a message similar to the following:

    namespace "yw-test" deleted