Skip to main content

Tutorial on modifying database parameters with yaml

Some parameters of the database cannot take effect immediately after modification. Therefore, you need to apply yaml to modify parameters and restart the database. Modifying parameters in yaml will cause the database to restart, and the whole process will take about 20 seconds. The following uses the Postgres database as an example to modify parameters:

  1. Access the terminal

config_1

  1. Edit pg-config.yaml
$ vim pg-config.yaml

config_2

  1. Copy yaml to pg-config.yaml and save pg-config.yaml

config_3

apiVersion: apps.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
name: test
spec:
clusterRef: test-pg #Change the database name to your own
reconfigure:
componentName: postgresql
configurations: #The following configuration is for reference only. You only need to keep the part to be modified and modify the corresponding parameter values
- keys:
- key: postgresql.conf
parameters:
- key: max_connections #Sets the maximum number of simultaneous connections that can be made to the database
value: "1000"
name: postgresql-configuration
ttlSecondsAfterSucceed: 0
type: Reconfiguring

Common PostgreSQL Parameters:

Parameter NameDescription
max_connectionsSets the maximum number of connections that can be
established with the database simultaneously.
max_wal_sizeSets the maximum size of WAL (Write-Ahead Logging) files.
min_wal_sizeSets the minimum size of WAL files.
max_worker_processesSets the maximum number of background processes that
PostgreSQL can start.
shared_buffersThe size of memory used for data caching.

Common MySQL Parameters:

Parameter NameDescription
innodb_buffer_pool_sizeSets the size of the InnoDB buffer pool.
max_connectionsThe maximum number of concurrent connections allowed.
query_cache_sizeThe size of the query cache.
thread_cache_sizeThe size of the thread cache.
max_allowed_packetThe maximum packet size.
innodb_log_file_sizeThe size of the InnoDB log file.

Common MongoDB Parameters:

Parameter NameDescription
storage.dbPathThe path for storing data files.
storage.journal.enabledSets the maximum size of WAL (Write-Ahead Logging) files.
min_wal_sizeEnables logging.
net.portThe server port.
net.bindIpThe bound IP address.

Common Redis Parameters:

Parameter NameDescription
maxclientsThe maximum number of client connections.
maxmemoryThe maximum amount of memory usage.
maxmemory-policyThe memory eviction policy.
appendonlySwitch for AOF persistence.
appendfsyncThe frequency of AOF file flushing.
  1. Apply pg-config.yaml
$ kubectl apply -f pg-config.yaml

config_4

  1. Check whether pg-config.yaml is successfully applied
# If the status of OpsRequest is Succeed and the status of pod is Running, the application is successfully configured
$ kubectl get OpsRequest
$ kubectl get pod

config_5

  1. Access the database to check whether the configuration takes effect
$ show max_connections;

config_6 config_7