title: Another postgres not starting: "could not map anonymous shared memory"
body: <p>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:</p>
  <pre><code>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.
  </code></pre>
  <p>I tryed to check and modify the kernel shmall parameter, but didn't work.</p>
  <pre><code>~$ cat /proc/sys/kernel/shmall
  18446744073692774399
  </code></pre>
  <pre><code>~$ cat /proc/sys/kernel/shmmax
  18446744073692774399
  </code></pre>
  <p>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).</p>
  <p>Thanks for the help!</p>
  <p><strong>EDIT 1</strong>:</p>
  <p>Ok, I found something strange:</p>
  <ol>
  <li>I purged postgresql completely from the system</li>
  <li>I reinstalled postgresql</li>
  <li>Started the cluster and everything went well</li>
  <li>Stopped the cluster and edited the configuration file with the settings I need</li>
  <li>Tryed to start the cluster again but got the same error</li>
  <li>Reverted back to the default configuration file but still getting the same error. Why is this happening?</li>
  </ol>
  <p>The system has 16 GB of RAM.</p>
  <p><strong>EDIT 2: ADDING DETAILS</strong></p>
  <p>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.</p>
  <p>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.</p>
  <p>I don't know what else I can do..</p>
  <p><strong>EDIT 3: OTHER DETAILS</strong></p>
  <p>This is what the command lsipc shows:</p>
  <pre><code>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    -     -
  </code></pre>
  <p>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:</p>
  <pre><code>sudo pg_ctlcluster 10 main start
  </code></pre>
  <p>I get the same error. I really need help!</p>