ClickHouse Uninstall and Cleanup

clickhouse_ansible already contains the official cleanup playbook: playbooks/uninstall_cluster.yml. It is suitable for environment recycling after the drill is completed, and for clearing the site before repeated reinstallation.

1. Scope of application

  • Uninstall the source cluster: inventory/hosts.deploy.ini
  • Uninstall the disaster recovery cluster: inventory/hosts.dr_deploy.ini

Requirements:

  • dbbot_inventory_purpose=deploy for inventory
  • Manual confirmation is required by default

2. Standard commands

Uninstall the source cluster:

cd /usr/local/dbbot/clickhouse_ansible/playbooks
ansible-playbook \
  -i ../inventory/hosts.deploy.ini \
  uninstall_cluster.yml

Uninstall the disaster recovery cluster:

cd /usr/local/dbbot/clickhouse_ansible/playbooks
ansible-playbook \
  -i ../inventory/hosts.dr_deploy.ini \
  uninstall_cluster.yml

3. What will be cleaned by default?

File: playbooks/vars/uninstall_config.yml

Enabled by default:

  • Stop and disable ClickHouse service
  • Delete ClickHouse configuration directory
  • Delete ClickHouse data directory
  • Delete ClickHouse log directory
  • Delete quick login configuration
  • Removed ClickHouse binary
  • Delete standalone ZooKeeper (if ZooKeeper is used in the current mode)

Off by default:

  • Uninstall /backup mount
  • Removed NFS client mount script

In other words, NFS client mounting traces will not be cleared by default to avoid accidentally deleting the shared backup disk.

4. Commonly used variables

VariableDefault valueFunction
uninstall_require_manual_confirmtrueWhether to require confirmation before uninstalling
uninstall_purge_clickhouse_configtrueWhether to delete the configuration directory
uninstall_purge_clickhouse_datatrueWhether to delete the data directory
uninstall_purge_clickhouse_logstrueWhether to delete the log directory
uninstall_remove_clickhouse_binariestrueWhether to remove ClickHouse binaries
uninstall_remove_backup_mountfalseWhether to uninstall /backup and remove the mount script
uninstall_purge_zookeepertrueWhether to clean up independent ZooKeeper

5. If you want to clean up the NFS client mount

cd /usr/local/dbbot/clickhouse_ansible/playbooks
ansible-playbook \
  -i ../inventory/hosts.deploy.ini \
  uninstall_cluster.yml \
  -e "uninstall_remove_backup_mount=true"

This will try:

  • Removed the mount entry in rc.local
  • Uninstall /backup
  • Delete mounting scripts and logs

6. Precautions

  1. This is a high-risk cleanup action and requires manual input of a confirmation phrase by default.
  2. If the target host has other business dependencies on /backup, do not directly turn on uninstall_remove_backup_mount=true.
  3. If your goal is just to “reinstall ClickHouse”, there is usually no need to clean up the NFS server at the same time.