postgresql-container
postgresql-container copied to clipboard
How to tune memory when running image in OpenShift
Container platform
OCP 4
Version
postgresql-15:1-10 from https://catalog.redhat.com/software/containers/rhel8/postgresql-15/63d29a05fd1c4f5552a305b3?architecture=amd64&tag=1-10&push_date=1684253325000
running via a deployment config on Openshift 4.10
OS version of the container image
RHEL 8
Bugzilla, Jira
No response
Description
The readme for v15 refers to the --memory
parameter. Where do I set the --memory
parameter in an Openshift deployment config (DC) so that the shared_buffers
and effective_cache_size
are set automatically?
My DC has resource limits configured under spec:template:spec as:
containers:
- resources:
limits:
cpu: '1'
memory: 4Gi
requests:
cpu: 100m
memory: 400Mi
but my shared_buffers is the default 128MB:
# show shared_buffers;
shared_buffers
----------------
128MB
(1 row)
Do you recommend that I instead manually set the shared_buffers
and effective_cache_size
parameters by editing the postgresql.conf
file located at /var/lib/pgsql/data/userdata/postgresql.conf
?
FYI - For anyone who comes across this post due to errors like this in their logs:
ERROR: could not resize shared memory segment "/PostgreSQL.1237418266" to 33554432 bytes: No space left on device
You should check the space allocated to /dev/shm
:
sh-4.4$ df -h
Filesystem Size Used Avail Use% Mounted on
...
shm 64M 1.1M 63M 2% /dev/shm
...
I increased the /dev/shm
space from 64M to 128M via the technique here: https://stackoverflow.com/questions/43373463/how-to-increase-shm-size-of-a-kubernetes-container-shm-size-equivalent-of-doc/63152020#63152020
by adding lines to the DC:
spec:
template:
spec:
volumes:
- name: dshm
emptyDir:
medium: Memory
sizeLimit: 128Mi
containers:
volumeMounts:
- name: dshm
mountPath: /dev/shm
After the above DC change, the could not resize shared memory segment
errors have stopped.
Reproducer
No response
Off the top of my head, It seems that you tried to set up a higher memory limit than available, so the server set the default one.