1

I want to update the max_connection count in /var/lib/postgresql/data/pgdata/postgresql.conf file, postgresql database is deployed in the form of pod. There is no vim present inside pod to update the file, nor I could modify the Dockerfile to install vim, as I don't have access for that. Also I have tried adding the args and command in the deployment.yaml file

containers:
        - name: postgres
          image: postgres:latest
          args: ["-c", "max_connections=500"]

still no luck for it.

SVD
  • 385
  • 4
  • 24

2 Answers2

0
  1. You can use sed to edit this file?
  2. Some helpfull options on this thread
  • sed sample: `sed -i "s/max_connections = .*/max_connections = 500/i" /var/lib/postgresql/data/pgdata/postgresql.conf` – William Leite Araújo Mar 17 '22 at 12:51
  • I have updated the file now, but it requires to restart postgres, when trying to restart postgres it gives below error. warn] No PostgreSQL clusters exist; see "man pg_createcluster" ... (warning) – SVD Mar 17 '22 at 12:53
  • You must use pg_ctl command instead pg_ctlcluster. Ex.: `su - postgres -c "$(find /usr/lib/ -name pg_ctl) restart -D /var/lib/postgresql/data/"` `-D` parameter must indicate the local data directory on pod, and the user to execute must be postgres – William Leite Araújo Apr 19 '22 at 12:44
0

Just increasing max_connections is bad idea. You need to increase shared_buffers and kernel.shmmax as well.

Kindly refer to this SO answer here for more information.

Piotr Malec
  • 3,429
  • 11
  • 16
  • 1
    got your point, but since I have deployed postgres on Kubernetes pod not sure how to update the max_connections and shared_buffer, since vim tool is not present inside the pod to edit the conf file. I am using the official postgres image postgres:13.4, and here there is no env variable option for max_connection or shared buffer – SVD Mar 21 '22 at 07:31