clickhouse-backup 命令的身份验证

Authentication for clickhouse-backup commands

我有一个 clickhouse 实例 运行ning,我在其中安装了 clickhouse-backup。我已经连接到它并且没有问题 运行ning clickhouse-client 与这样的自定义用户:

clickhouse-client -u fred --password 12345

但是当我执行 clickhouse-backup tables 我得到

can't connect to clickhouse: code: 516, message: default: Authentication failed: password is incorrect or there is no user with such name. 

如何以我的自定义用户 'fred' 运行 命令 clickhouse-backup tables

它需要在 config.yml 文件中定义这些凭据:

..
clickhouse:
  username: fred              # CLICKHOUSE_USERNAME
  password: 12345             # CLICKHOUSE_PASSWORD
..

默认配置文件位于/etc/clickhouse-backup/config.yml.

要定义自定义位置,请将其传入 --config 参数。


作为替代方法,可以通过环境变量传递所需的参数。将 运行 clickhouse-backup 视为 docker-container:

# generate a backup plan

sudo docker run --rm -it --network host -v "/var/lib/clickhouse:/var/lib/clickhouse" \
    -e CLICKHOUSE_FREEZE_BY_PART=true \
    -e CLICKHOUSE_USERNAME=user \
    -e CLICKHOUSE_PASSWORD=passw \
    \
    alexakulov/clickhouse-backup:latest create --tables="db.table1_local" "table1 [shard-01]"


# start a backup process

sudo docker run --rm -it --network host -v "/var/lib/clickhouse:/var/lib/clickhouse" \
    -e CLICKHOUSE_USERNAME=user \
    -e CLICKHOUSE_PASSWORD=passw \
    -e REMOTE_STORAGE=gcs \
    -e GCS_BUCKET=gcs-clickhouse-backup-bucket \
    -e GCS_CREDENTIALS_JSON='_credentials_json_' \
    \
    alexakulov/clickhouse-backup:latest upload "table1 [shard-01]"


# remove the local copy of backup

sudo docker run --rm -it --network host -v "/var/lib/clickhouse:/var/lib/clickhouse" \
    \
    alexakulov/clickhouse-backup:latest delete local "table1 [shard-01]"