Shared Memory allocation in jail

Alejandro Imass ait at p2ee.org
Thu Jan 5 15:55:58 UTC 2012


On Thu, Jan 5, 2012 at 8:56 AM, bsd <bsd at todoo.biz> wrote:
> Hi,
>
> I am trying to run both postgres and zabbix in the same jail and I am only able to start postgres or zabbix not both of them.
>


Yeah bro, it bit me in the ass as well ;-) the SysV IPC is common for
the whole system. So anything that uses IPC in jails will have to go
through this process....

You have to change the Pg user's id and the chown the Pg files. I use
a nomeclature for this and is the last 3 digits of the jail's IP and
the original uid. Example The jail on 192.168.101.124 has a Pg user of
70124 for port NATing I use the contrary nomenclature like 12480 is
the network port 80 of the same jail in th public IP as 12480.

Anyway here is my recipe:

pw usermod pgsql -u 70124
 pw groupmod pgsql -g 70124
 chown -R pgsql /usr/local/pgsql/
 chgrp -R pgsql /usr/local/pgsql/

When you run ipcs from the jail You should the see something like the
example below, where there is still one Pg on uid 70 but from the
jail's perspective it's the pgsql user who now has uid of 70124

Message Queues:
  T           ID          KEY MODE        OWNER    GROUP

  Shared Memory:
  T           ID          KEY MODE        OWNER    GROUP
  m      1179648      5432001 --rw------- 70       70
  m       131073            0 --rw------- 70       70
  m      1572866      5432002 --rw------- pgsql    pgsql

  Semaphores:
  T           ID          KEY MODE        OWNER    GROUP
  s      1703936      5432001 --rw------- 70       70
  s      1703937      5432002 --rw------- 70       70
  s      1703938      5432003 --rw------- 70       70
  s      1572867      5432004 --rw------- 70       70
  s      1572868      5432005 --rw------- 70       70
  s      1572869      5432006 --rw------- 70       70
  s      1572870      5432007 --rw------- 70       70
  s      1179655      5432008 --rw------- pgsql    pgsql
  s      1179656      5432009 --rw------- pgsql    pgsql
  s      1179657      5432010 --rw------- pgsql    pgsql
  s      1179658      5432011 --rw------- pgsql    pgsql
  s      1179659      5432012 --rw------- pgsql    pgsql
  s      1179660      5432013 --rw------- pgsql    pgsql
  s      1179661      5432014 --rw------- pgsql    pgsql

Cheers,

-- 
Alejandro Imass


More information about the freebsd-questions mailing list