github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/docs/user_docs/kubeblocks-for-mysql/configuration/configuration.md (about) 1 --- 2 title: Configure cluster parameters 3 description: Configure cluster parameters 4 keywords: [mysql, 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 both `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 mysql-cluster 20 ``` 21 22 From the meta information, the cluster `mysql-cluster` has a configuration file named `my.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 mysql-cluster --show-detail 30 ``` 31 32 * View the parameter description. 33 34 ```bash 35 kbcli cluster explain-config mysql-cluster | head -n 20 36 ``` 37 38 * View the user guide of a specified parameter. 39 40 ```bash 41 kbcli cluster explain-config mysql-cluster --param=innodb_buffer_pool_size --config-spec=mysql-consensusset-config 42 ``` 43 44 `--config-spec` is required to specify a configuration template since ApeCloud MySQL currently supports multiple templates. You can run `kbcli cluster describe-config mysql-cluster` to view the all template names. 45 46 <details> 47 48 <summary>Output</summary> 49 50 ```bash 51 template meta: 52 ConfigSpec: mysql-consensusset-config ComponentName: mysql ClusterName: mysql-cluster 53 54 Configure Constraint: 55 Parameter Name: innodb_buffer_pool_size 56 Allowed Values: [5242880-18446744073709552000] 57 Scope: Global 58 Dynamic: false 59 Type: integer 60 Description: The size in bytes of the memory buffer innodb uses to cache data and indexes of its tables 61 ``` 62 63 </details> 64 65 * Allowed Values: It defines the valid value range of this parameter. 66 * 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**. 67 * When `Dynamic` is `true`, it means the effectiveness type of parameters is **dynamic** and can be configured online. Follow the instructions in [Configure dynamic parameters](#configure-dynamic-parameters). 68 * 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). 69 * Description: It describes the parameter definition. 70 71 ## Configure parameters 72 73 ### Configure parameters with configure command 74 75 The example below takes configuring `max_connection` and `innodb_buffer_pool_size` as an example. 76 77 1. View the current values of `max_connection` and `innodb_buffer_pool_size`. 78 79 ```bash 80 kbcli cluster connect mysql-cluster 81 ``` 82 83 ```bash 84 mysql> show variables like '%max_connections%'; 85 > 86 +-----------------+-------+ 87 | Variable_name | Value | 88 +-----------------+-------+ 89 | max_connections | 167 | 90 +-----------------+-------+ 91 1 row in set (0.04 sec) 92 ``` 93 94 ```bash 95 mysql> show variables like '%innodb_buffer_pool_size%'; 96 > 97 +-------------------------+-----------+ 98 | Variable_name | Value | 99 +-------------------------+-----------+ 100 | innodb_buffer_pool_size | 134217728 | 101 +-------------------------+-----------+ 102 1 row in set (0.00 sec) 103 ``` 104 105 2. Adjust the values of `max_connections` and `innodb_buffer_pool_size`. 106 107 ```bash 108 kbcli cluster configure mysql-cluster --set=max_connections=600,innodb_buffer_pool_size=512M 109 ``` 110 111 :::note 112 113 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, 114 115 ```bash 116 kbcli cluster configure mysql-cluster --set=max_connections=200,innodb_buffer_pool_size=2097152 117 error: failed to validate updated config: [failed to cue template render configure: [mysqld.innodb_buffer_pool_size: invalid value 2097152 (out of bound >=5242880): 118 343:34 119 ] 120 ] 121 ``` 122 123 ::: 124 125 3. Search the status of the parameter configuration. 126 127 `Status.Progress` shows the overall status of the parameter configuration and `Conditions` show the details. 128 129 ```bash 130 kbcli cluster describe-ops mysql-cluster-reconfiguring-z2wvn -n default 131 ``` 132 133 <details> 134 135 <summary>Output</summary> 136 137 ```bash 138 Spec: 139 Name: mysql-cluster-reconfiguring-z2wvn NameSpace: default Cluster: mysql-cluster Type: Reconfiguring 140 141 Command: 142 kbcli cluster configure mysql-cluster --component-names=mysql --template-name=mysql-consensusset-config --config-file=my.cnf --set innodb_buffer_pool_size=512M --set max_connections=600 143 144 Status: 145 Start Time: Mar 13,2023 02:55 UTC+0800 146 Completion Time: Mar 13,2023 02:55 UTC+0800 147 Duration: 1s 148 Status: Succeed 149 Progress: 1/1 150 151 Conditions: 152 LAST-TRANSITION-TIME TYPE REASON STATUS MESSAGE 153 Mar 13,2023 02:55 UTC+0800 Progressing OpsRequestProgressingStarted True Start to process the OpsRequest: mysql-cluster-reconfiguring-z2wvn in Cluster: mysql-cluster 154 Mar 13,2023 02:55 UTC+0800 Validated ValidateOpsRequestPassed True OpsRequest: mysql-cluster-reconfiguring-z2wvn is validated 155 Mar 13,2023 02:55 UTC+0800 Reconfigure ReconfigureStarted True Start to reconfigure in Cluster: mysql-cluster, Component: mysql 156 Mar 13,2023 02:55 UTC+0800 ReconfigureMerged ReconfigureMerged True Reconfiguring in Cluster: mysql-cluster, Component: mysql, ConfigTpl: mysql-consensusset-config, info: updated: map[my.cnf:{"mysqld":{"innodb_buffer_pool_size":"512M","max_connections":"600"}}], added: map[], deleted:map[] 157 Mar 13,2023 02:55 UTC+0800 ReconfigureSucceed ReconfigureSucceed True Reconfiguring in Cluster: mysql-cluster, Component: mysql, ConfigTpl: mysql-consensusset-config, info: updated policy: <autoReload>, updated: map[my.cnf:{"mysqld":{"innodb_buffer_pool_size":"512M","max_connections":"600"}}], added: map[], deleted:map[] 158 Mar 13,2023 02:55 UTC+0800 Succeed OpsRequestProcessedSuccessfully True Successfully processed the OpsRequest: mysql-cluster-reconfiguring-z2wvn in Cluster: mysql-cluster 159 ``` 160 161 </details> 162 163 4. Connect to the database to verify whether the parameters are configured as expected. 164 165 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. 166 167 ```bash 168 kbcli cluster connect mysql-cluster 169 ``` 170 171 ```bash 172 mysql> show variables like '%max_connections%'; 173 > 174 +-----------------+-------+ 175 | Variable_name | Value | 176 +-----------------+-------+ 177 | max_connections | 600 | 178 +-----------------+-------+ 179 1 row in set (0.04 sec) 180 ``` 181 182 ```bash 183 mysql> show variables like '%innodb_buffer_pool_size%'; 184 > 185 +-------------------------+-----------+ 186 | Variable_name | Value | 187 +-------------------------+-----------+ 188 | innodb_buffer_pool_size | 536870912 | 189 +-------------------------+-----------+ 190 1 row in set (0.00 sec) 191 ``` 192 193 ### Configure parameters with edit-config command 194 195 For your convenience, KubeBlocks offers a tool `edit-config` to help you to configure parameter in a visulized way. 196 197 For Linux and macOS, you can edit configuration files by vi. For Windows, you can edit files on notepad. 198 199 The following steps take configuring MySQL Standalone as an example. 200 201 1. Edit the configuration file. 202 203 ```bash 204 kbcli cluster edit-config mysql-cluster --config-spec=mysql-consensusset-config 205 ``` 206 207 :::note 208 209 * `--config-spec` is required to specify a configuration template since ApeCloud MySQL currently supports multiple templates. You can run `kbcli cluster describe-config mysql-cluster` to view the all template names. 210 * If there are multiple components in a cluster, use `--component` to specify a component. 211 212 ::: 213 214 1. View the status of the parameter configuration. 215 216 ```bash 217 kbcli cluster describe-ops xxx -n default 218 ``` 219 220 2. Connect to the database to verify whether the parameters are configured as expected. 221 222 ```bash 223 kbcli cluster connect mysql-cluster 224 ``` 225 226 :::note 227 228 1. For the `edit-config` function, static parameters and dynamic parameters cannot be edited at the same time. 229 2. Deleting a parameter will be supported later. 230 231 ::: 232 233 ## View history and compare differences 234 235 After the configuration is completed, you can search the configuration history and compare the parameter differences. 236 237 View the parameter configuration history. 238 239 ```bash 240 kbcli cluster describe-config mysql-cluster 241 > 242 ConfigSpecs Meta: 243 CONFIG-SPEC-NAME FILE ENABLED TEMPLATE CONSTRAINT RENDERED COMPONENT CLUSTER 244 mysql-consensusset-config my.cnf true mysql8.0-config-template mysql8.0-config-constraints mysql-cluster-mysql-mysql-config mysql mysql-cluster 245 246 History modifications: 247 OPS-NAME CLUSTER COMPONENT CONFIG-SPEC-NAME FILE STATUS POLICY PROGRESS CREATED-TIME VALID-UPDATED 248 mysql-cluster-reconfiguring-4q5kv mysql-cluster mysql mysql-consensusset-config my.cnf Succeed reload -/- Mar 16,2023 15:44 UTC+0800 {"my.cnf":"{\"mysqld\":{\"max_connections\":\"3000\",\"read_buffer_size\":\"24288\"}}"} 249 mysql-cluster-reconfiguring-cclvm mysql-cluster mysql mysql-consensusset-config my.cnf Succeed reload -/- Mar 16,2023 17:28 UTC+0800 {"my.cnf":"{\"mysqld\":{\"innodb_buffer_pool_size\":\"1G\",\"max_connections\":\"600\"}}"} 250 mysql-cluster-reconfiguring-gx58r mysql-cluster mysql mysql-consensusset-config my.cnf Succeed -/- Mar 16,2023 17:28 UTC+0800 251 ``` 252 253 From the above results, there are three parameter modifications. 254 255 Compare these modifications to view the configured parameters and their different values for different versions. 256 257 ```bash 258 kbcli cluster diff-config mysql-cluster-reconfiguring-4q5kv mysql-cluster-reconfiguring-gx58r 259 > 260 DIFF-CONFIGURE RESULT: 261 ConfigFile: my.cnf TemplateName: mysql-consensusset-config ComponentName: mysql ClusterName: mysql-cluster UpdateType: update 262 263 PARAMETERNAME MYSQL-CLUSTER-RECONFIGURING-4Q5KV MYSQL-CLUSTER-RECONFIGURING-GX58R 264 max_connections 3000 600 265 innodb_buffer_pool_size 128M 1G 266 ```