Monday, December 13, 2010

Tamil charset in Postgresql

Storing Tamil charset into postgresql database.
I'm assumed your Operating System were installed Tamil font.

1) Create database in Postgresql with Encoding style as UNICODE

CREATE DATABASE tamildb
WITH OWNER = postgres
ENCODING = 'UNICODE';

2) Create table to insert Tamil charset

CREATE TABLE tamitbl (
emp_no int, emp_name varchar(50) );

INSERT INTO tamiltbl VALUES91,'சோலை முருகன்')

since your Operating System were installed Tamil fonts, table would accept records in tamil charset.

likewise you can add any other language charset valuse provided
OS were installed fonts.

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.