error in postgresql

I installed postgresql90-server with ports

Code:
[root@VM-FreeBSD /usr/home/douglas]# /usr/local/etc/rc.d/postgresql initdb
Ever wonder what those numbers after command names were, as in cat(1)?  It's
the section of the manual the man page is in.  "man man" will tell you more.
		-- David Scheidt <dscheidt@tumbolia.com>
The files belonging to this database system will be owned by user "pgsql".
This user must also own the server process.

The database cluster will be initialized with locale C.
The default text search configuration will be set to "english".

initdb: directory "/usr/local/pgsql/data" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/usr/local/pgsql/data" or run initdb
with an argument other than "/usr/local/pgsql/data".

Code:
[root@VM-FreeBSD /usr/home/douglas]# cd /usr/local/pgsql/     
[root@VM-FreeBSD /usr/local/pgsql]# mv data data2
[root@VM-FreeBSD /usr/local/pgsql]# /usr/local/etc/rc.d/postgresql initdb
To clear the screen, use "clear". To re-display your screen buffer, press
the scroll lock key and use your page up button. When you're finished,
press the scroll lock key again to get your prompt back.
		-- Dru <genesis@istar.ca>
The files belonging to this database system will be owned by user "pgsql".
This user must also own the server process.

The database cluster will be initialized with locale C.
The default text search configuration will be set to "english".

creating directory /usr/local/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 10
selecting default shared_buffers ... 400kB
creating configuration files ... ok
creating template1 database in /usr/local/pgsql/data/base/1 ... FATAL:  could not create shared memory segment: Cannot allocate memory
DETAIL:  Failed system call was shmget(key=1, size=1712128, 03600).
HINT:  This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory or swap space, or exceeded your 
kernel's SHMALL parameter.  You can either reduce the request size or reconfigure the kernel with larger SHMALL.  To reduce the request size 
(currently 1712128 bytes), reduce PostgreSQL's shared_buffers parameter (currently 50) and/or its max_connections parameter (currently 14).
	The PostgreSQL documentation contains more information about shared memory configuration.
child process exited with exit code 1
initdb: removing data directory "/usr/local/pgsql/data"
 
Try to increase sysctl kern.ipc.shmmax, and/or discover what you have in [cmd=]ipcs -a[/cmd] output.
 
# sysctl kern.ipc.shmmax
Code:
kern.ipc.shmmax: 33554432

what I put in /etc/sysctl.conf
Code:
kern.ipc.shmmax=????????
 
# ipcs -a
Code:
Message Queues:
T           ID          KEY MODE        OWNER    GROUP    CREATOR  CGROUP                 CBYTES                 QNUM               QBYTES        LSPID        LRPID STIME    RTIME    CTIME   

Shared Memory:
T           ID          KEY MODE        OWNER    GROUP    CREATOR  CGROUP         NATTCH        SEGSZ         CPID         LPID ATIME    DTIME    CTIME   
m       196608      5432001 --rw------- pgsql    pgsql    pgsql    pgsql               4     32120832         1660         1660  2:41:40  3:02:51  2:41:40
m       196609            0 --rw------- douglas  wheel    douglas  wheel               2       393216         3731         3717  5:26:06 no-entry  5:26:06
m       131074            0 --rw------- douglas  wheel    douglas  wheel               2       393216         3738         3717  5:26:08 no-entry  5:26:08
m       196611            0 --rw------- douglas  wheel    douglas  wheel               2       393216         3738         3717  5:26:05 no-entry  5:26:05

Semaphores:
T           ID          KEY MODE        OWNER    GROUP    CREATOR  CGROUP          NSEMS OTIME    CTIME   
s       196608      5432001 --rw------- pgsql    pgsql    pgsql    pgsql              17  2:41:40  2:41:40
s       196609      5432002 --rw------- pgsql    pgsql    pgsql    pgsql              17  2:41:40  2:41:40
s       196610      5432003 --rw------- pgsql    pgsql    pgsql    pgsql              17  2:41:40  2:41:40
 
Try removing pgsql's part of mem
Code:
ipcrm -W -m 196608 -s 196608 -s 196609 -s 196610
Then try to initdb again. Also you can increase kern.ipc.shmmax to some bigger value
 
# ipcrm -W -m 196608 -s 196608 -s 196609 -s 196610
Code:
ipcrm: shmid(196608): : Invalid argument
ipcrm: semid(196608): : Invalid argument
ipcrm: semid(196609): : Invalid argument
ipcrm: semid(196610): : Invalid argument

Put that number? About 1000000 or more. Has some specific calculation?
 
No, its IDs from `ipcs -a`..
Ok you just need to clean what eats memory, looking in `ipcs -a` then it should start
 
# sysctl -w kern.ipc.shmall=32768
# sysctl -w kern.ipc.shmmax=134217728
# sysctl -w kern.ipc.semmap=256

added in /etc/sysctl.conf.

PostgreSQL is already running.

Thanks!
 
Back
Top