问题
如何使用 API 端点启动、停止和恢复 ClickHouse 云服务?
回答
- 要从空闲状态唤醒/恢复云服务,您可以 ping 该实例
curl -X GET https://abc123.us-west-2.aws.clickhouse.cloud:8443/ping
- 要停止云服务,请使用
/state
端点以及stop
命令。语法如下所示
curl -X PATCH https://api.clickhouse.cloud/v1/organizations/<org_uuid>/services/<service_uuid>/state -u <key_id>:<key_secret> -H "Content-Type: application/json" -d ''{"command": "<stop|start>"}''
例如,以下命令会停止 2e2124ca-c5ac-459d-a6f2-abc123549d2a
服务
curl -X PATCH https://api.clickhouse.cloud/v1/organizations/123abcd0-e9b5-4f55-9e42-0fb04392445c/services/2e2124ca-c5ac-459d-a6f2-abc123549d2a/state -u abc123:ABC123 -H "Content-Type: application/json" -d '{"command": "stop"}'
输出如下所示
{"result":{"id":"2e2124ca-c5ac-459d-a6f2-abc123549d2a","name":"mars-s3","provider":"aws","regionId":"us-west-2","state":"stopping","endpoints":[{"protocol":"nativesecure","host":"abc123.us-west-2.aws.clickhouse.cloud","port":9440},{"protocol":"https","host":"abc123ntrb.us-west-2.aws.clickhouse.cloud","port":8443}],"tier":"production","idleScaling":true,"idleTimeoutMinutes":5,"minTotalMemoryGb":24,"maxTotalMemoryGb":48,"ipAccessList":[{"source":"[0.0.0.0/0](http://0.0.0.0/0)","description":"Anywhere"}],"createdAt":"2022-10-21T18:46:31Z"},"status":200}%
- 要再次启动服务,请使用
start
命令
curl -X PATCH https://api.clickhouse.cloud/v1/organizations/123abcd0-e9b5-4f55-9e42-0fb04392445c/services/2e2124ca-c5ac-459d-a6f2-abc123549d2a/state -u abc123:ABC123 -H "Content-Type: application/json" -d '{"command": "start"}'
注意
以下是服务可能处于的各种状态
"state":"stopping"
"state":"stopped"
"state":"starting"
"state":"running"
"state":"idle"
注意
处于 “空闲” 状态的云服务被视为已启动,因此 start
命令不会恢复/唤醒它。使用步骤 1 中显示的 ping
端点来唤醒服务。