Monday, December 6, 2010

Installing Postgresql on BOSS/Debian Image

last week when I was Installing Postgrersql 8.4 on Debian based OS Image, I have got few errors which listed here with solutions.


1)
sh: /dev/null: Permission denied
fgets failure: Success
The program "postgres" is needed by initdb but was not found in the
same directory as "/opt/PostgreSQL/8.4/bin/

initdb".
Check your installation.

SOULUTION
full permission to " /dev/null " i.e chmode 777 /dev/null

then start postgresql by

/opt/PostgreSQL/8.4/bin/initdb -D /opt/PostgreSQL/8.4/data/
/opt/PostgreSQL/8.4/bin/postgres -D /opt/PostgreSQL/8.4/data/

2) psql: error while loading shared libraries: libpq.so.5: cannot open shared object file:
No such file or directory


SOLUTION

*) find / -name libpq.so.5
*) export LD_LIBRARY_PATH="/opt/PostgreSQL/8.4/lib/"

3)

A) psql: could not connect to server: No such file or directory
   Is the server running locally and accepting
      connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

SOLUTION
*) possibly change your default port no specified in postgres.conf file,
if you have mentioned other then default port no 5432 while installing. (OR)
*) Change the port no in postgresql.conf file and restart the DB server (OR)
*) instead of psql type full command like psql -p 5432 -h localhost

B)  sudo -u postgres createuser -D -A -P username 
 
ERROR : 

createuser: could not connect to database postgres: could not connect to server: No such file or directory
    Is the server running locally and accepting
     connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
 
SOLUTION  :
 
*) sudo -u postgres createuser -D -A -P username -h localhost
  -h --> server name  
 
4) sh: psql: command not found

SOLUTION

*) add postgresql path to .bashrc
PATH=$PATH:Postgres/8.4/main/bin  to root/.bashrc
*) restart bashrc file
boss:/$ source /root/.bashrc
5) locales not set or any issue related to locales in debian

SOLUTION

*) dpkg-reconfigure locales
     |
     |
      -- it will list the all the locales, select all locales in US_EN* 

6) FATAL: could not create shared memory segment: Cannot allocate memory

DETAIL: Failed system call was shmget(key=1, size=1081344, 03600).

HINT: This error usually means that PostgreSQL's request for a shared
memory segment exceeded available memory or swap space. To reduce the
request size (currently 1081344 bytes), reduce PostgreSQL's
shared_buffers parameter (currently 50) and/or its max_connections
parameter (currently 10).
The PostgreSQL documentation contains more information about 
shared memory configuration.

SOLUTION

aove problem can be sortout by different way,
*) Postgresql installed by deb package, here you go for the solution,

*) postgresql installed from bin file, if you get the above error
while create initdb,just increase the size of the shmall and shmmax value,
value of the variable stored in byte.

the above variable available in sysctl, list and find the variable format

$ sysctl -a
-- in BOSS os(DEBIAN based) the variable   "kernel.shmall and kernel.shmmax"
-- in mac OS X, variable "kern.sysv.shmmax and  kern.sysv.shmall"

increase the size of the varible by

sysctl -w kernel.shmmax=13421772800
sysctl -w kernel.shmall=13421772800

now start postgresql, it ll work.


4 comments:

TCH said...

Man i surfed through half of the net and never found anyithing useful about this "initdb & postgres" error, now it's solved thanks to you, so thanks to you! :)

dataanalytics said...

thanks TCH ...

Anonymous said...

I am getting this error.

invalid binary "/home/user/pgsql/bin/initdb"

The program "postgres" is needed by initdb but was not found in the
same directory as "initdb".
Check your installation.


I googled and none of the solutions working.Can you help me

dataanalytics said...

hi,

1) Check PostgreSQL installed and check where initdb is by

which initdb.

2) Change the current directory to that specified in he command mode.