- 1 Ansible host
- 3 Clickhouse hosts
Clone this repo and run this script on Ansible host:
-
Install necessary packages:
ansible-galaxy collection install -r requirements.yml --upgrade
-
Modify
inventory.ymlfor your target hosts. Default host number is 3 but you can define more host for more replicas and shards. -
Run playbook:
ansible-playbook clickhouse_setup.yml -i inventory.yml -k -K
-
Additional: Uncomment
Uninstall ClickHouse Databasetask and comment other tasks to remove ClickHouse. -
Change to sharding:
- Modify
shardandreplicationininventory.yml - Modify
remote-servers.xml.j2 - Comment setup tasks in
clickhouse_setup.yml - Notice: After changing the config file, the old tables configs remain the same. It only affects the new tables.
- python is required
- user with permission in mariadb is required
- user with permission in clickhouse db is required
pip install clickhouse-mysql
clickhouse-mysql --src-server-id 1 --migrate-table --src-wait --nice-pause 1 --src-host=<maria-host> --src-port <maria-port> --src-user=<maria-user> --src-password=<maria-pw> --src-schemas <maria-db> --src-tables <maria-table(s)> --dst-host=<ch-host> --dst-user=<ch-user> --dst-password=<ch-pw> --with-create-database --dst-create-table --log-level=info