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_default_user_allowed_networks127.0.0.1, ::1Manually configured trusted source IPs/CIDRs for the default user
clickhouse_default_user_auto_include_cluster_nodestrueWhether to append exact ClickHouse node IPs from inventory automatically
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.
  • clickhouse_default_password may contain XML- and shell-significant characters. dbbot XML-escapes it in generated files and does not pass it in managed clickhouse-client process arguments.
  • Each instance keeps automation credentials in /etc/clickhouse-server[-N]/dbbot-client.xml with root:root ownership and mode 0600. The separate fast-login file for the ClickHouse OS account remains mode 0600 under that account.

Trusted sources for the default user

The default configuration declares only the loopback addresses manually. During deployment, dbbot also extracts and deduplicates every ansible_host from the clickhouse_cluster inventory group before writing the effective list to users.xml:

clickhouse_default_user_allowed_networks:
  - "127.0.0.1"
  - "::1"
clickhouse_default_user_auto_include_cluster_nodes: true

Cluster mode appends the exact IP of every ClickHouse node so that distributed queries through remote_servers can continue using the default user. Standalone mode appends only the current physical host IP and does not automatically trust other independent standalone hosts in the same inventory.

To trust a DBA management subnet or a bastion host, extend the list. Automatically discovered cluster node IPs are still appended:

clickhouse_default_user_allowed_networks:
  - "127.0.0.1"
  - "::1"
  - "10.20.30.0/24"
  - "10.40.50.60"
clickhouse_default_user_auto_include_cluster_nodes: true

For a fully manual allowlist, disable automatic inclusion and list every trusted source explicitly:

clickhouse_default_user_allowed_networks:
  - "127.0.0.1"
  - "::1"
  - "10.10.10.11"
  - "10.10.10.12"
  - "10.10.10.13"
clickhouse_default_user_auto_include_cluster_nodes: false

To explicitly restore the previous allow-from-anywhere behavior:

clickhouse_default_user_allowed_networks:
  - "::/0"
clickhouse_default_user_auto_include_cluster_nodes: false

::/0 permits connections from any network and is not recommended where untrusted hosts can reach ClickHouse. Every list item must be an IP address or CIDR. When automatic inclusion is enabled, each deployment inventory ansible_host must also be an IP address.

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_include_config_filesfalseWhether to apply config snapshots; enabling it requires SHA-256 verification before extraction
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

The config snapshot SHA-256 comes from the backup manifest. Missing checksum metadata or a mismatch with the archive on NFS blocks config apply before extraction.

5. NFS and cleaning variables

The NFS server/client defaults are defined in the playbooks. setup_nfs_server.yml is for lab/test use only and is not a production NFS delivery entry. The core values are:

VariableDefault valueFunction
nfs_server_ip198.51.100.162NFS server IP
nfs_export_dir/srv/nfs/clickhouse_backupServer export directory
nfs_export_mode0770Lab NFS export directory mode
nfs_export_uid / nfs_export_gid18123 / 18123Numeric UID/GID for the lab export, matching the default ClickHouse runtime account
nfs_export_optsrw,sync,no_subtree_check,no_root_squashLab compatibility policy; do not use for production NFS
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

Before deletion, uninstall requires ClickHouse and managed ZooKeeper to be stopped and checks for processes using the current instance config path. A stop failure or remaining process blocks deletion.

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