I noticed there are several questions about Postgres (10) not able to boot because of the shared memory; despite that I couldn't really make it run. Now everytime I try to start the cluster I keep getting this error:
2021-10-24 10:13:43.269 UTC [11253] FATAL: could not map anonymous shared memory: Cannot allocate memory
2021-10-24 10:13:43.269 UTC [11253] HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory, swap space, or huge pages. To reduce the request size (currently 5507432448 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.
I tryed to check and modify the kernel shmall parameter, but didn't work.
~$ cat /proc/sys/kernel/shmall
18446744073692774399
~$ cat /proc/sys/kernel/shmmax
18446744073692774399
I can't reduce the memory into the config file because these are the settings I must use although I tryied anyway but without success (I even used the minimum values).
Thanks for the help!
EDIT 1:
Ok, I found something strange:
- I purged postgresql completely from the system
- I reinstalled postgresql
- Started the cluster and everything went well
- Stopped the cluster and edited the configuration file with the settings I need
- Tryed to start the cluster again but got the same error
- Reverted back to the default configuration file but still getting the same error. Why is this happening?
The system has 16 GB of RAM.
EDIT 2: ADDING DETAILS
Ok so basically I had to migrate a postgresql database by moving the data directory. That's the only thing it could be done. After moving the data folder completely here's the error. I noticed there weren't a swap memory so I created it but still same error.
The shared memory and segment between the two server are basically identical. When I start the cluster It immediately fails, so maybe this can be a clue for you. The destination server is an EC2 machine.
I don't know what else I can do..
EDIT 3: OTHER DETAILS
This is what the command lsipc shows:
RESOURCE DESCRIPTION LIMIT USED USE%
MSGMNI Number of message queues 32000 0 0.00%
MSGMAX Max size of message (bytes) 8192 - -
MSGMNB Default max size of queue (bytes) 16384 - -
SHMMNI Shared memory segments 4096 0 0.00%
SHMALL Shared memory pages 18446744073692774399 0 0.00%
SHMMAX Max size of shared memory segment (bytes) 18446744073692774399 - -
SHMMIN Min size of shared memory segment (bytes) 1 - -
SEMMNI Number of semaphore identifiers 32000 0 0.00%
SEMMNS Total number of semaphores 1024000000 0 0.00%
SEMMSL Max semaphores per semaphore set. 32000 - -
SEMOPM Max number of operations per semop(2) 500 - -
SEMVMX Semaphore max value 32767 - -
These values are the same of the source machine I'm trying to migrate. The data directory is identical with the original one, but everythime I go with this command:
sudo pg_ctlcluster 10 main start
I get the same error. I really need help!