github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/docs/user_docs/kubeblocks-for-postgresql/configuration/configuration.md (about) 1 --- 2 title: Configure cluster parameters 3 description: Configure cluster parameters 4 keywords: [postgresql, 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 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 pg-cluster 20 ``` 21 22 From the meta information, you can find the configuration files of this PostgreSQL cluster. 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 pg-cluster --show-detail 30 ``` 31 32 * View the parameter description. 33 34 ```bash 35 kbcli cluster explain-config pg-cluster | head -n 20 36 ``` 37 38 * View the user guide of a specified parameter. 39 40 ```bash 41 kbcli cluster explain-config pg-cluster --param=max_connections 42 ``` 43 44 <details> 45 46 <summary>Output</summary> 47 48 ```bash 49 template meta: 50 ConfigSpec: postgresql-configuration ComponentName: postgresql ClusterName: pg-cluster 51 52 Configure Constraint: 53 Parameter Name: max_connections 54 Allowed Values: [6-8388607] 55 Scope: Global 56 Dynamic: true 57 Type: integer 58 Description: Sets the maximum number of concurrent connections. 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 configured 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 takes configuring `max_connections` as an example. 73 74 1. View the current values of `max_connections`. 75 76 ```bash 77 kbcli cluster connect pg-cluster 78 ``` 79 80 ```bash 81 postgres=# show max_connections; 82 max_connections 83 ----------------- 84 100 85 (1 row) 86 ``` 87 88 2. Adjust the values of `max_connections`. 89 90 ```bash 91 kbcli cluster configure pg-cluster --set=max_connections=200 92 ``` 93 94 :::note 95 96 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, 97 98 ```bash 99 kbcli cluster configure pg-cluster --set=max_connections=5 100 error: failed to validate updated config: [failed to cue template render configure: [pg.acllog-max-len: invalid value 5 (out of bound 6-8388607): 101 343:34 102 ] 103 ] 104 ``` 105 106 ::: 107 108 3. View the status of the parameter configuration. 109 110 `Status.Progress` and `Status.Status` shows the overall status of the parameter configuration and `Conditions` show the details. 111 112 When the `Status.Status` shows `Succeed`, the configuration is completed. 113 114 ```bash 115 kbcli cluster describe-ops pg-cluster-reconfiguring-fq6q7 -n default 116 ``` 117 118 <details> 119 120 <summary>Output</summary> 121 122 ```bash 123 Spec: 124 Name: pg-cluster-reconfiguring-fq6q7 NameSpace: default Cluster: pg-cluster Type: Reconfiguring 125 126 Command: 127 kbcli cluster configure pg-cluster --components=postgresql --config-spec=postgresql-configuration --config-file=postgresql.conf --set max_connections=100 --namespace=default 128 129 Status: 130 Start Time: Mar 17,2023 19:25 UTC+0800 131 Completion Time: Mar 17,2023 19:25 UTC+0800 132 Duration: 2s 133 Status: Succeed 134 Progress: 1/1 135 OBJECT-KEY STATUS DURATION MESSAGE 136 137 Conditions: 138 LAST-TRANSITION-TIME TYPE REASON STATUS MESSAGE 139 Mar 17,2023 19:25 UTC+0800 Progressing OpsRequestProgressingStarted True Start to process the OpsRequest: pg-cluster-reconfiguring-fq6q7 in Cluster: pg-cluster 140 Mar 17,2023 19:25 UTC+0800 Validated ValidateOpsRequestPassed True OpsRequest: pg-cluster-reconfiguring-fq6q7 is validated 141 Mar 17,2023 19:25 UTC+0800 Reconfigure ReconfigureStarted True Start to reconfigure in Cluster: pg-cluster, Component: postgresql 142 Mar 17,2023 19:25 UTC+0800 ReconfigureMerged ReconfigureMerged True Reconfiguring in Cluster: pg-cluster, Component: postgresql, ConfigSpec: postgresql-configuration, info: updated: map[postgresql.conf:{"max_connections":"200"}], added: map[], deleted:map[] 143 Mar 17,2023 19:25 UTC+0800 ReconfigureSucceed ReconfigureSucceed True Reconfiguring in Cluster: pg-cluster, Component: postgresql, ConfigSpec: postgresql-configuration, info: updated policy: <operatorSyncUpdate>, updated: map[postgresql.conf:{"max_connections":"100"}], added: map[], deleted:map[] 144 Mar 17,2023 19:25 UTC+0800 Succeed OpsRequestProcessedSuccessfully True Successfully processed the OpsRequest: pg-cluster-reconfiguring-fq6q7 in Cluster: pg-cluster 145 ``` 146 147 </details> 148 149 4. Connect to the database to verify whether the parameter is configured as expected. 150 151 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. 152 153 ```bash 154 kbcli cluster connect pg-cluster 155 ``` 156 157 ```bash 158 postgres=# show max_connections; 159 max_connections 160 ----------------- 161 200 162 (1 row) 163 ``` 164 165 ### Configure parameters with edit-config command 166 167 For your convenience, KubeBlocks offers a tool `edit-config` to help you to configure parameter in a visulized way. 168 169 For Linux and macOS, you can edit configuration files by vi. For Windows, you can edit files on notepad. 170 171 1. Edit the configuration file. 172 173 ```bash 174 kbcli cluster edit-config pg-cluster 175 ``` 176 177 :::note 178 179 If there are multiple components in a cluster, use `--component` to specify a component. 180 181 ::: 182 183 2. View the status of the parameter configuration. 184 185 ```bash 186 kbcli cluster describe-ops xxx -n default 187 ``` 188 189 3. Connect to the database to verify whether the parameters are configured as expected. 190 191 ```bash 192 kbcli cluster connect pg-cluster 193 ``` 194 195 :::note 196 197 1. For the `edit-config` function, static parameters and dynamic parameters cannot be edited at the same time. 198 2. Deleting a parameter will be supported later. 199 200 ::: 201 202 ## View history and compare differences 203 204 After the configuration is completed, you can search the configuration history and compare the parameter differences. 205 206 View the parameter configuration history. 207 208 ```bash 209 kbcli cluster describe-config pg-cluster 210 ``` 211 212 <details> 213 214 <summary>Output</summary> 215 216 ```bash 217 ConfigSpecs Meta: 218 CONFIG-SPEC-NAME FILE ENABLED TEMPLATE CONSTRAINT RENDERED COMPONENT CLUSTER 219 postgresql-configuration kb_restore.conf false postgresql-configuration postgresql14-cc pg-cluster-postgresql-postgresql-configuration postgresql pg-cluster 220 postgresql-configuration pg_hba.conf false postgresql-configuration postgresql14-cc pg-cluster-postgresql-postgresql-configuration postgresql pg-cluster 221 postgresql-configuration postgresql.conf true postgresql-configuration postgresql14-cc pg-cluster-postgresql-postgresql-configuration postgresql pg-cluster 222 postgresql-configuration kb_pitr.conf false postgresql-configuration postgresql14-cc pg-cluster-postgresql-postgresql-configuration postgresql pg-cluster 223 postgresql-custom-metrics custom-metrics.yaml false postgresql-custom-metrics pg-cluster-postgresql-postgresql-custom-metrics postgresql pg-cluster 224 225 History modifications: 226 OPS-NAME CLUSTER COMPONENT CONFIG-SPEC-NAME FILE STATUS POLICY PROGRESS CREATED-TIME VALID-UPDATED 227 pg-cluster-reconfiguring-fq6q7 pg-cluster postgresql postgresql-configuration postgresql.conf Succeed 1/1 Mar 17,2023 19:25 UTC+0800 {"postgresql.conf":"{\"max_connections\":\"100\"}"} 228 pg-cluster-reconfiguring-bm84z pg-cluster postgresql postgresql-configuration postgresql.conf Succeed 1/1 Mar 17,2023 19:27 UTC+0800 {"postgresql.conf":"{\"max_connections\":\"200\"}"} 229 pg-cluster-reconfiguring-cbqxd pg-cluster postgresql postgresql-configuration postgresql.conf Succeed 1/1 Mar 17,2023 19:35 UTC+0800 {"postgresql.conf":"{\"max_connections\":\"500\"}"} 230 pg-cluster-reconfiguring-rcnzb pg-cluster postgresql postgresql-configuration postgresql.conf Succeed restart 1/1 Mar 17,2023 19:38 UTC+0800 {"postgresql.conf":"{\"shared_buffers\":\"512MB\"}"} 231 ``` 232 233 </details> 234 235 From the above results, there are three parameter modifications. 236 237 Compare these modifications to view the configured parameters and their different values for different versions. 238 239 ```bash 240 kbcli cluster diff-config pg-cluster-reconfiguring-bm84z pg-cluster-reconfiguring-rcnzb 241 > 242 DIFF-CONFIG RESULT: 243 ConfigFile: postgresql.conf TemplateName: postgresql-configuration ComponentName: postgresql ClusterName: pg-cluster UpdateType: update 244 245 PARAMETERNAME PG-CLUSTER-RECONFIGURING-BM84Z PG-CLUSTER-RECONFIGURING-RCNZB 246 max_connections 200 500 247 shared_buffers 256MB 512MB 248 ```