ClickHouse Variables and Parameters

This article summarizes the variables that are most frequently changed and most likely to affect the results among the public capabilities of clickhouse_ansible, to help you quickly locate the configuration entry before deployment, backup, and recovery.

1. General variables

File: playbooks/vars/common_config.yml

VariableDefault valueFunction
clickhouse_version23.6.1ClickHouse version, supports three or four paragraph writing
clickhouse_install_debug_packagefalseWhether to additionally prepare and install clickhouse-common-static-dbg
clickhouse_default_passwordDbbot_default@8888default user password
clickhouse_uid / clickhouse_gid18123 / 18123Fixed UID/GID for ClickHouse users and groups
fcs_auto_download_packagestrueControl whether the node automatically downloads the ClickHouse installation package
fcs_set_hostnametrueWhether to modify the target host hostname
fcs_allow_dbbot_default_passwdfalseWhether to allow continued execution with a public default password
use_clickhouse_keeperfalsefalse uses standalone ZooKeeper, true uses ClickHouse Keeper
clickhouse_enable_sslfalseWhether to enable SSL
deploy_require_manual_confirmtrueWhether to require console confirmation before deployment

Description:

  • clickhouse_install_debug_package=false is the current recommended default and can significantly reduce download and distribution times.
  • It is recommended to unify clickhouse_uid / clickhouse_gid between the source cluster and the disaster recovery cluster to avoid permission misalignment during NFS recovery.
  • The public default password of clickhouse_default_password is Dbbot_default@8888.
  • Default fcs_allow_dbbot_default_passwd: false, so deployment, backup-, and restore-related playbooks will intercept the exposed default password in the pre_tasks stage.

2. Cluster variables

File: playbooks/vars/cluster_config.yml

VariableDefault valueFunction
clickhouse_cluster_nameexample_3shards_2replicascluster name
clickhouse_tcp_port_base9000ClickHouse TCP port baseline
clickhouse_http_port_base8123ClickHouse HTTP port baseline
clickhouse_interserver_http_port_base9009Inter-replica HTTP port baseline
clickhouse_mysql_port_base9004MySQL protocol compatible port baseline
clickhouse_postgresql_port_base9005PostgreSQL protocol compatible port baseline
clickhouse_aux_port_stride10Multi-instance protocol compatible port stride

Port calculation rules:

  • The main port increases 1 one by one according to instance_id
  • MySQL/PostgreSQL protocol compatible port by instance_id multiplied by clickhouse_aux_port_stride

3. Back up variables

File: playbooks/vars/backup_config.yml

VariableDefault valueFunction
backup_databases / backup_tables[]Backup object, set at least one item
backup_modefullBackup mode, supports full / incremental
backup_base_batch_id""Incremental backup baseline batch number
backup_storage_diskbackup_nfsClickHouse side backup disk name
backup_mount_dir/backupNFS mount directory
backup_checkpoint_modefilesafe_ts recording mode
backup_require_replicated_tablestrueWhether to block non-replicated local table backups
backup_allow_partial_clusterfalseWhether to allow --limit to back up only some nodes

Production suggestions:

  • The production environment prefers to use fixed backup_batch_id
  • Complete setup_nfs_client_mount_rc_local.yml and prepare_backup_disk.yml before backing up

4. Restore variables

File: playbooks/vars/restore_config.yml

VariableDefault valueFunction
restore_batch_id""Target recovery batch number, required
restore_manifest_file""manifest path, automatically located by default
restore_to_all_replicastrueWhether all replicas participate in recovery
restore_allow_non_empty_tablesfalseWhether to allow recovery to non-empty tables
restore_enable_two_phase_mv_compattrueWhether to enable MV two-phase compatible recovery
restore_allow_partial_clusterfalseWhether to allow --limit to restore only some nodes
restore_require_manual_confirmtrueWhether to require console confirmation before restoring
restore_mount_dir/backupRestore the target side mount directory

Be sure to do two things before restoring:

  1. Mount NFS on the recovery target cluster
  2. Execute prepare_backup_disk.yml in the recovery target cluster

5. NFS and cleaning variables

The default values of NFS server/client are written in the playbook. The core values are as follows:

VariableDefault valueFunction
nfs_server_ip198.51.100.162NFS server IP
nfs_export_dir/srv/nfs/clickhouse_backupServer export directory
nfs_mount_point/backupClient mount directory
dbbot_inventory_purposenfs_server / backupNFS server/client guard

Cleanup variables are located at: playbooks/vars/uninstall_config.yml

VariableDefault valueFunction
uninstall_require_manual_confirmtrueWhether to require confirmation before uninstalling
uninstall_purge_clickhouse_configtrueWhether to delete ClickHouse configuration
uninstall_purge_clickhouse_datatrueWhether to delete the ClickHouse data directory
uninstall_purge_clickhouse_logstrueWhether to delete the ClickHouse log directory
uninstall_remove_backup_mountfalseWhether to uninstall /backup and remove the rc.local mount script
uninstall_purge_zookeepertrueWhether to delete independent ZooKeeper services and directories

6. Restore validation variables

File: playbooks/vars/validate_restore_config.yml

VariableDefault valueFunction
validate_source_groupclickhouse_backupSource cluster group
validate_target_groupclickhouse_restoreTarget cluster group
validate_source_query_host127.0.0.1Source query address
validate_target_query_host127.0.0.1Target query address
validate_fail_on_missing_pairstrueWhether to fail when the source/target lacks a corresponding shard copy
validate_checks[]List of validation items

When using this playbook, you need to pass in two sets of inventory at the same time, for example:

ansible-playbook \
  -i ../inventory/hosts.backup.ini \
  -i ../inventory/hosts.restore.ini \
  validate_restore_consistency.yml

For TTL tables, it is recommended to write the where condition of a fixed time window in validate_checks instead of directly comparing the total number of the entire table.

  1. ClickHouse cluster deployment
  2. ClickHouse Backup
  3. ClickHouse Restore
  4. ClickHouse data validation after recovery
  5. ClickHouse Uninstallation and Cleanup
  6. ClickHouse directory structure and configuration