Skip to content

Commit

Permalink
chore: add reconfig for clickhouse
Browse files Browse the repository at this point in the history
  • Loading branch information
shanshanying committed Jan 10, 2025
1 parent 6034185 commit 3a8385b
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 8 deletions.
64 changes: 56 additions & 8 deletions examples/clickhouse/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ There are two key components in the ClickHouse cluster:
- ClickHouse Server: The ClickHouse server is responsible for processing queries and managing data storage.
- ClickHouse Keeper: The ClickHouse Keeper is responsible for monitoring the health of the ClickHouse server and performing failover operations when necessary, alternative to the Zookeeper.


## Features In KubeBlocks

### Lifecycle Management
Expand All @@ -16,15 +15,11 @@ There are two key components in the ClickHouse cluster:
|------------------|------------------------|-----------------------|-------------------|-----------|------------|-----------|--------|------------|
| standalone/cluster | Yes | Yes | Yes | Yes | Yes | Yes | No | N/A |

### Backup and Restore

| Feature | Method | Description |
|-------------|--------|------------|

### Versions

| Major Versions | Description |
|---------------|-------------|
| 22 | 22.9.4 |
| 24 | 24.8.3|

## Prerequisites
Expand Down Expand Up @@ -212,6 +207,60 @@ Increase size of volume storage with the specified components in the cluster
kubectl apply -f examples/clickhouse/volumeexpand.yaml
```

### [Reconfigure](configure.yaml)

Reconfigure parameters with the specified components in the cluster

```bash
kubectl apply -f examples/clickhouse/reconfigure.yaml
```

This example will change the `max_bytes_to_read` to `200000000000`.
To verify the configuration, you can connect to the ClickHouse server and run the following command:

```bash
# connect to the clickhouse pod
kubectl exec -it clickhouse-cluster-clickhouse-0 -- /bin/bash
```

and check the configuration:

```bash
# connect to the clickhouse server
clickhouse-client --user $CLICKHOUSE_ADMIN_USER --password $CLICKHOUSE_ADMIN_PASSWORD
> set profile='web';
> select name,value from system.settings where name like 'max_bytes%';

<details>

The `user.xml` file is an xml file that contains the configuration of the ClickHouse server.
```xml
<clickhouse>
<profiles>
<default>
<!-- The maximum number of threads when running a single query. -->
<max_threads>8</max_threads>
</default>
<web>
<max_rows_to_read>1000000000</max_rows_to_read>
<max_bytes_to_read>100000000000</max_bytes_to_read>
</web>
</profiles>
</clickhouse>
```

When updating the configuration, the key we set in the `reconfigure.yaml` file should be the same as the key in the `user.xml` file, for example:

```yaml
- key: user.xml
parameters:
- key: clickhouse.profiles.web.max_bytes_to_read
value: '200000000000'
```

To update parameter `max_bytes_to_read`, we use the full path `clickhouse.profiles.web.max_bytes_to_read` w.r.t the `user.xml` file.
</details>

### [Restart](restart.yaml)

Restart the specified components in the cluster
Expand Down Expand Up @@ -276,5 +325,4 @@ kubectl delete cluster clickhouse-cluster
# delete secret udf-account-info if exists
# kubectl delete secret udf-account-info
```

```
34 changes: 34 additions & 0 deletions examples/clickhouse/reconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: operations.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
name: ch-reconfiguring
namespace: default
spec:
# Specifies the name of the Cluster resource that this operation is targeting.
clusterName: clickhouse-cluster
# Instructs the system to bypass pre-checks (including cluster state checks and customized pre-conditions hooks) and immediately execute the opsRequest, except for the opsRequest of 'Start' type, which will still undergo pre-checks even if `force` is true. Note: Once set, the `force` field is immutable and cannot be updated.
force: false
# Specifies a component and its configuration updates. This field is deprecated and replaced by `reconfigures`.
reconfigures:
# Specifies the name of the Component.
- componentName: clickhouse
# Contains a list of ConfigurationItem objects, specifying the Component's configuration template name, upgrade policy, and parameter key-value pairs to be updated.
configurations:
# Sets the parameters to be updated. It should contain at least one item.
# The keys are merged and retained during patch operations.
- keys:
# Represents the unique identifier for the ConfigMap.
- key: user.xml
# Defines a list of key-value pairs for a single configuration file.
# These parameters are used to update the specified configuration settings.
parameters:
# Represents the name of the parameter that is to be updated.
- key: clickhouse.profiles.web.max_bytes_to_read
# Represents the parameter values that are to be updated.
# If set to nil, the parameter defined by the Key field will be removed from the configuration file.
value: '200000000000'
# Specifies the name of the configuration template.
name: clickhouse-user-tpl
# Specifies the maximum number of seconds the OpsRequest will wait for its start conditions to be met before aborting. If set to 0 (default), the start conditions must be met immediately for the OpsRequest to proceed.
preConditionDeadlineSeconds: 0
type: Reconfiguring

0 comments on commit 3a8385b

Please sign in to comment.