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=deployfor 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
/backupmount - 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
| Variable | Default value | Function |
|---|---|---|
uninstall_require_manual_confirm | true | Whether to require confirmation before uninstalling |
uninstall_purge_clickhouse_config | true | Whether to delete the configuration directory |
uninstall_purge_clickhouse_data | true | Whether to delete the data directory |
uninstall_purge_clickhouse_logs | true | Whether to delete the log directory |
uninstall_remove_clickhouse_binaries | true | Whether to remove ClickHouse binaries |
uninstall_remove_backup_mount | false | Whether to uninstall /backup and remove the mount script |
uninstall_purge_zookeeper | true | Whether 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
- This is a high-risk cleanup action and requires manual input of a confirmation phrase by default.
- If the target host has other business dependencies on
/backup, do not directly turn onuninstall_remove_backup_mount=true. - If your goal is just to “reinstall ClickHouse”, there is usually no need to clean up the NFS server at the same time.