Wednesday, April 24, 2024

Postgres installation on different mount point other than default installation

 1) Download PostgreSQL:website: https://www.postgresql.org/ftp/source/ 


2) Download file and place on required directory.


3) complete installation step by step.


cd /software

tar -xvzf postgresql-14.0.tar.gz

cd postgresql-14.0

mkdir -p /u01/postgres/v14

cd /software/postgresql-14.0

./configure --prefix=/u01/postgres/v14

make

make install

Now you will find complete bin on /u01/postgres/v14

cd /u01/postgres/v14/bin >> Verify if contents are showing

cd /u01/postgres/v14

mkdir data

cd data

chown -R postgres:postgres /u01/postgres/v14/data


4) Now create data directory using below command:

sudo -u postgres /u01/postgres/v14/bin/initdb -D /u01/postgres/v14/data

5) Above all done using root or priv users. Now switch user:

su - postgres

Go to location and start PG server:

cd /u01/postgres/v14/data

/u01/postgres/v14/bin/pg_ctl -D /u01/postgres/v14/data -l logfile start


Check processes using below:
ps -ef|grep postgres

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

while connecting to db getting this error.

6) Below changes in "postgresql.conf" 

listen_addresses = '*'  
max_connections = 100 
unix_socket_directories = '/tmp' 
log_destination = 'stderr'
logging_collector = on 
log_directory = 'log'  
log_filename = 'postgresql-%a.log'


7) RESTART SERVER

.bash_profile
export PGHOST=/tmp
/u01/postgres/v14/bin/pg_ctl -D /u01/postgres/v14/data restart

You should be login to PG server using psql now.





No comments:

Post a Comment