github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/docs/user_docs/kubeblocks-for-redis/configuration/configuration.md (about) 1 --- 2 title: Configure cluster parameters 3 description: Configure cluster parameters 4 keywords: [redis, parameter, configuration, reconfiguration] 5 sidebar_position: 1 6 --- 7 8 # Configure cluster parameters 9 10 The KubeBlocks configuration function provides a set of consistent default configuration generation strategies for all the databases running on KubeBlocks and also provides a unified parameter configuration interface to facilitate managing parameter configuration, searching the parameter user guide, and validating parameter effectiveness. 11 12 From v0.6.0, KubeBlocks supports `kbcli cluster configure` and `kbcli cluster edit-config` to configure parameters. The difference is that KubeBlocks configures parameters automatically with `kbcli cluster configure` but `kbcli cluster edit-config` provides a visualized way for you to edit parameters directly. 13 14 ## View parameter information 15 16 View the current configuration file of a cluster. 17 18 ```bash 19 kbcli cluster describe-config redis-cluster --component=redis 20 ``` 21 22 From the meta information, the cluster `redis-cluster` has a configuration file named `redis.cnf`. 23 24 You can also view the details of this configuration file and parameters. 25 26 * View the details of the current configuration file. 27 28 ```bash 29 kbcli cluster describe-config redis-cluster --component=redis --show-detail 30 ``` 31 32 * View the parameter description. 33 34 ```bash 35 kbcli cluster explain-config redis-cluster --component=redis |head -n 20 36 ``` 37 38 * View the user guide of a specified parameter. 39 40 ```bash 41 kbcli cluster explain-config redis-cluster --component=redis --param=acllog-max-len 42 ``` 43 44 <details> 45 <summary>Output</summary> 46 47 ```bash 48 template meta: 49 ConfigSpec: redis-replication-config ComponentName: redis ClusterName: redis-cluster 50 51 Configure Constraint: 52 Parameter Name: acllog-max-len 53 Allowed Values: [1-10000] 54 Scope: Global 55 Dynamic: true 56 Type: integer 57 Description: 58 ``` 59 60 </details> 61 62 * Allowed Values: It defines the valid value range of this parameter. 63 * Dynamic: The value of `Dynamic` in `Configure Constraint` defines how the parameter configuration takes effect. There are two different configuration strategies based on the effectiveness type of modified parameters, i.e. **dynamic** and **static**. 64 * When `Dynamic` is `true`, it means the effectiveness type of parameters is **dynamic** and can be updated online. Follow the instructions in [Configure dynamic parameters](#configure-dynamic-parameters). 65 * When `Dynamic` is `false`, it means the effectiveness type of parameters is **static** and a pod restarting is required to make configuration effective. Follow the instructions in [Configure static parameters](#configure-static-parameters). 66 * Description: It describes the parameter definition. 67 68 ## Configure parameters 69 70 ### Configure parameters with configure command 71 72 The example below configures `acllog-max-len`. 73 74 1. View the current values of `acllog-max-len`. 75 76 ```bash 77 kbcli cluster connect redis-cluster 78 ``` 79 80 ```bash 81 127.0.0.1:6379> config get parameter acllog-max-len 82 1) "acllog-max-len" 83 2) "128" 84 ``` 85 86 2. Adjust the values of `acllog-max-len`. 87 88 ```bash 89 kbcli cluster configure redis-cluster --component=redis --set=acllog-max-len=256 90 ``` 91 92 :::note 93 94 Make sure the value you set is within the Allowed Values of this parameter. If you set a value that does not meet the value range, the system prompts an error. For example, 95 96 ```bash 97 kbcli cluster configure redis-cluster --set=acllog-max-len=1000000 98 > 99 error: failed to validate updated config: [failed to cue template render configure: [configuration."acllog-max-len": 2 errors in empty disjunction: 100 configuration."acllog-max-len": conflicting values 128 and 1000000: 101 20:43 102 155:16 103 configuration."acllog-max-len": invalid value 1000000 (out of bound <=10000): 104 20:32 105 ] 106 ] 107 ``` 108 109 ::: 110 111 3. View the status of the parameter configuration. 112 113 `Status.Progress` and `Status.Status` shows the overall status of the parameter configuration and `Conditions` show the details. 114 115 When the `Status.Status` shows `Succeed`, the configuration is completed. 116 117 ```bash 118 kbcli cluster describe-ops redis-cluster-reconfiguring-zjztm -n default 119 ``` 120 121 <details> 122 <summary>Output</summary> 123 124 ```bash 125 Spec: 126 Name: redis-cluster-reconfiguring-zjztm NameSpace: default Cluster: redis-cluster Type: Reconfiguring 127 128 Command: 129 kbcli cluster configure redis-cluster --components=redis --config-spec=redis-replication-config --config-file=redis.conf --set acllog-max-len=256 --namespace=default 130 131 Status: 132 Start Time: Apr 17,2023 17:22 UTC+0800 133 Duration: 10s 134 Status: Running 135 Progress: 0/1 136 OBJECT-KEY STATUS DURATION MESSAGE 137 138 Conditions: 139 LAST-TRANSITION-TIME TYPE REASON STATUS MESSAGE 140 Apr 17,2023 17:22 UTC+0800 Progressing OpsRequestProgressingStarted True Start to process the OpsRequest: redis-cluster-reconfiguring-zjztm in Cluster: redis-cluster 141 Apr 17,2023 17:22 UTC+0800 Validated ValidateOpsRequestPassed True OpsRequest: redis-cluster-reconfiguring-zjztm is validated 142 Apr 17,2023 17:22 UTC+0800 Reconfigure ReconfigureStarted True Start to reconfigure in Cluster: redis-cluster, Component: redis 143 Apr 17,2023 17:22 UTC+0800 ReconfigureRunning ReconfigureRunning True Reconfiguring in Cluster: redis-cluster, Component: redis, ConfigSpec: redis-replication-config 144 ``` 145 146 </details> 147 148 4. Connect to the database to verify whether the parameter is configured as expected. 149 150 The whole searching process has a 30-second delay since it takes some time for kubelet to synchronize modifications to the volume of the pod. 151 152 ```bash 153 kbcli cluster connect redis-cluster 154 ``` 155 156 ```bash 157 127.0.0.1:6379> config get parameter acllog-max-len 158 1) "acllog-max-len" 159 2) "256" 160 ``` 161 162 ### Configure parameters with edit-config command 163 164 For your convenience, KubeBlocks offers a tool `edit-config` to help you to configure parameter in a visulized way. 165 166 For Linux and macOS, you can edit configuration files by vi. For Windows, you can edit files on notepad. 167 168 1. Edit the configuration file. 169 170 ```bash 171 kbcli cluster edit-config redis-cluster 172 ``` 173 174 :::note 175 176 If there are multiple components in a cluster, use `--component` to specify a component. 177 178 ::: 179 180 2. View the status of the parameter configuration. 181 182 ```bash 183 kbcli cluster describe-ops xxx -n default 184 ``` 185 186 3. Connect to the database to verify whether the parameters are configured as expected. 187 188 ```bash 189 kbcli cluster connect redis-cluster 190 ``` 191 192 :::note 193 194 1. For the `edit-config` function, static parameters and dynamic parameters cannot be edited at the same time. 195 2. Deleting a parameter will be supported later. 196 197 ::: 198 199 ## View history and compare differences 200 201 After the configuration is completed, you can search the configuration history and compare the parameter differences. 202 203 View the parameter configuration history. 204 205 ```bash 206 kbcli cluster describe-config redis-cluster --component=redis 207 ``` 208 209 <details> 210 <summary>Output</summary> 211 212 ```bash 213 ConfigSpecs Meta: 214 CONFIG-SPEC-NAME FILE ENABLED TEMPLATE CONSTRAINT RENDERED COMPONENT CLUSTER 215 redis-replication-config redis.conf true redis7-config-template redis7-config-constraints redis-cluster-redis-redis-replication-config redis redis-cluster 216 217 History modifications: 218 OPS-NAME CLUSTER COMPONENT CONFIG-SPEC-NAME FILE STATUS POLICY PROGRESS CREATED-TIME VALID-UPDATED 219 redis-cluster-reconfiguring-zjztm redis-cluster redis redis-replication-config redis.conf Succeed restart 1/1 Apr 17,2023 17:22 UTC+0800 220 redis-cluster-reconfiguring-zrkq7 redis-cluster redis redis-replication-config redis.conf Succeed restart 1/1 Apr 17,2023 17:28 UTC+0800 {"redis.conf":"{\"databases\":\"32\",\"maxclients\":\"20000\"}"} 221 redis-cluster-reconfiguring-mwbnw redis-cluster redis redis-replication-config redis.conf Succeed restart 1/1 Apr 17,2023 17:35 UTC+0800 {"redis.conf":"{\"maxclients\":\"40000\"}"} 222 ``` 223 224 </details> 225 226 From the above results, there are three parameter modifications. 227 228 Compare these modifications to view the configured parameters and their different values for different versions. 229 230 ```bash 231 kbcli cluster diff-config redis-cluster-reconfiguring-zrkq7 redis-cluster-reconfiguring-mwbnw 232 > 233 DIFF-CONFIG RESULT: 234 ConfigFile: redis.conf TemplateName: redis-replication-config ComponentName: redis ClusterName: redis-cluster UpdateType: update 235 236 PARAMETERNAME REDIS-CLUSTER-RECONFIGURING-ZRKQ7 REDIS-CLUSTER-RECONFIGURING-MWBNW 237 maxclients 20000 40000 238 ```