Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

PostgreSQL 10 Installation

PostgreSQL 10.3 installation steps:
In this tutorial i will explain how to install postgreSQL 10 on Red Hat Enterprise Linux Server release 7.3 Beta (Maipo) and How to make network configuration and how to do linux partition for DATA , ARCHIVE, BACKUP.
Step 2. Install the below mandatory rpm’s .
1.postgresql10-libs – The shared libraries required for any PostgreSQL clients
2.postgresql10 – PostgreSQL client programs and libraries
3.postgresql10-server – The programs needed to create and run a PostgreSQL server
4.postgresql10-contrib – Contributed source and binaries distributed with PostgreSQL
rpm -ivh postgresql1010-10.10-1.x86_64.rpm --nodeps
rpm -ivh postgresql1010-contrib-10.10-1.x86_64.rpm --nodeps
rpm -ivh postgresql1010-contrib-debuginfo-10.10-1.x86_64.rpm --nodeps
rpm -ivh postgresql1010-debuginfo-10.10-1.x86_64.rpm --nodeps
rpm -ivh postgresql1010-debugsource-10.10-1.x86_64.rpm --nodeps
rpm -ivh postgresql1010-devel-10.10-1.x86_64.rpm --nodeps
rpm -ivh postgresql1010-devel-debuginfo-10.10-1.x86_64.rpm --nodeps
rpm -ivh postgresql1010-docs-10.10-1.x86_64.rpm --nodeps
rpm -ivh postgresql1010-libs-10.10-1.x86_64.rpm --nodeps
rpm -ivh postgresql1010-libs-debuginfo-10.10-1.x86_64.rpm --nodeps
rpm -ivh postgresql1010-pglogical-2.2.2-1.x86_64.rpm --nodeps
rpm -ivh postgresql1010-pglogical-debuginfo-2.2.2-1.x86_64.rpm --nodeps
rpm -ivh postgresql1010-pglogical-debugsource-2.2.2-1.x86_64.rpm --nodeps
rpm -ivh postgresql1010-plperl-10.10-1.x86_64.rpm --nodeps
rpm -ivh postgresql1010-plperl-debuginfo-10.10-1.x86_64.rpm --nodeps
rpm -ivh postgresql1010-plpython-10.10-1.x86_64.rpm --nodeps
rpm -ivh postgresql1010-plpython-debuginfo-10.10-1.x86_64.rpm --nodeps
rpm -ivh postgresql1010-pltcl-10.10-1.x86_64.rpm --nodeps
rpm -ivh postgresql1010-pltcl-debuginfo-10.10-1.x86_64.rpm --nodeps
rpm -ivh postgresql1010-server-10.10-1.x86_64.rpm --nodeps
rpm -ivh postgresql1010-server-debuginfo-10.10-1.x86_64.rpm --nodeps
rpm -ivh postgresql1010-test-10.10-1.x86_64.rpm --nodeps
rpm -ivh postgresql1010-test-debuginfo-10.10-1.x86_64.rpm --nodeps


Step 3. Intialize  the  postgres cluster .
[root@master bin]# pwd
/usr/pgsql-10/bin
[root@master bin]# ls -lrt postgresql-10-setup
-rwxr-xr-x. 1 root root 8582 Feb 27 05:16 postgresql-10-setup
Then initialize the database:
[root@master bin]# /usr/pgsql-10/bin/postgresql-10-setup initdb
Initializing database ... OK
Note:PostgreSQL data is typically found /var/lib/pgsql/10/data/ directory.
Verify the data directory:
[root@master bin]# /var/lib/pgsql/10/data/
base/         pg_commit_ts/ pg_multixact/ pg_serial/    pg_stat_tmp/  pg_twophase/
global/       pg_dynshmem/  pg_notify/    pg_snapshots/ pg_subtrans/  pg_wal/
log/          pg_logical/   pg_replslot/  pg_stat/      pg_tblspc/    pg_xact/
Step 4. Currently postgres is not running we need to start the postgres cluster:
A.check the postgres cluster status:
[root@master bin]# ps -ef|grep postgres
root       5141   3519  0 18:41 pts/0    00:00:00 grep --color=auto postgres
B.start the postgres cluster:
[root@master ~]# systemctl start postgresql-10
[root@master ~]# ps -ef|grep post
root       2271      1  0 17:21 ?        00:00:00 /usr/libexec/postfix/master -w
postfix    2274   2271  0 17:21 ?        00:00:00 pickup -l -t unix -u
postfix    2275   2271  0 17:21 ?        00:00:00 qmgr -l -t unix -u
root       5171   3519  0 18:44 pts/0    00:00:00 su postgres
postgres   5172   5171  0 18:44 pts/0    00:00:00 bash
postgres   5295      1  0 18:47 ?        00:00:00 /usr/pgsql-10/bin/postmaster -D /var/lib/pgsql/10/data/
postgres   5297   5295  0 18:47 ?        00:00:00 postgres: logger process   
postgres   5299   5295  0 18:47 ?        00:00:00 postgres: checkpointer process   
postgres   5300   5295  0 18:47 ?        00:00:00 postgres: writer process   
postgres   5301   5295  0 18:47 ?        00:00:00 postgres: wal writer process   
postgres   5302   5295  0 18:47 ?        00:00:00 postgres: autovacuum launcher process   
postgres   5303   5295  0 18:47 ?        00:00:00 postgres: stats collector process   
postgres   5304   5295  0 18:47 ?        00:00:00 postgres: bgworker: logical replication launcher   
root       5306   5237  0 18:47 pts/0    00:00:00 grep --color=auto post
C. Check the database connectivity:
[root@master ~]# psql
psql: FATAL:  role "root" does not exist

[root@master ~]# su postgres
[postgres@master root]$ cd
[postgres@master ~]$ psql
psql (10.3)
Type "help" for help.

postgres=# show data_directory;
     data_directory     
------------------------
 /var/lib/pgsql/10/data
(1 row)
Step 5.  Changing data directory path.
A. Stop the postgres server .
[postgres@master ~]$ /usr/pgsql-10/bin/pg_ctl -D /var/lib/pgsql/10/data/ stop 
waiting for server to shut down.... done 
server stopped
B. Move the Data’s  to /mnt/DATA partition:
[postgres@master ~]$ rsync -av /var/lib/pgsql/10/data/* /mnt/DATA/
sending incremental file list
PG_VERSION
current_logfiles
pg_hba.conf
pg_ident.conf
postgresql.auto.conf
postgresql.conf
postmaster.opts
base/
base/1/
base/1/112
...
..
.
sent 41370578 bytes  received 18299 bytes  16555550.80 bytes/sec
total size is 41316241  speedup is 1.00
C.  Check the data directory on postgresql.conf file
[postgres@slave1 ~]$ cat /mnt/DATA/postgresql.conf |grep data_directory
#data_directory = 'ConfigDir'  # use data in another directory
As postgres user:
change the data partition ownership.
[postgres@master DATA]$ /usr/pgsql-10/bin/pg_ctl -D /mnt/DATA start
waiting for server to start....2018-03-06 19:18:05.013 IST [5745] FATAL:  data directory "/mnt/DATA" has group or world access
2018-03-06 19:18:05.013 IST [5745] DETAIL:  Permissions should be u=rwx (0700).
 stopped waiting
pg_ctl: could not start server
Examine the log output.
Solution:
changing data partion permission as 700 then start the postgres cluster.
[postgres@master ~]$  chmod 0700 /mnt/DATA/
[postgres@master ~]$ /usr/pgsql-10/bin/pg_ctl -D /mnt/DATA start
waiting for server to start....2018-03-06 19:22:47.515 IST [5920] LOG:  listening on IPv6 address "::1%1", port 5432
2018-03-06 19:22:47.515 IST [5920] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2018-03-06 19:22:47.517 IST [5920] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2018-03-06 19:22:47.521 IST [5920] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2018-03-06 19:22:47.660 IST [5920] LOG:  redirecting log output to logging collector process
2018-03-06 19:22:47.660 IST [5920] HINT:  Future log output will appear in directory "log".
 done
server started

Checking postgres process whether is running or not.
[postgres@master DATA]$ ps -ef|grep postgres
root       5171   3519  0 18:44 pts/0    00:00:00 su postgres
postgres   5172   5171  0 18:44 pts/0    00:00:00 bash
root       5317   5237  0 18:48 pts/0    00:00:00 su postgres
postgres   5318   5317  0 18:48 pts/0    00:00:00 bash
root       5876   5843  0 19:22 pts/0    00:00:00 su postgres
postgres   5877   5876  0 19:22 pts/0    00:00:00 bash
postgres   5920      1  0 19:22 pts/0    00:00:00 /usr/pgsql-10/bin/postgres -D /mnt/DATA
postgres   5921   5920  0 19:22 ?        00:00:00 postgres: logger process   
postgres   5923   5920  0 19:22 ?        00:00:00 postgres: checkpointer process   
postgres   5924   5920  0 19:22 ?        00:00:00 postgres: writer process   
postgres   5925   5920  0 19:22 ?        00:00:00 postgres: wal writer process   
postgres   5926   5920  0 19:22 ?        00:00:00 postgres: autovacuum launcher process  
postgres   5927   5920  0 19:22 ?        00:00:00 postgres: stats collector process   
postgres   5928   5920  0 19:22 ?        00:00:00 postgres: bgworker: logical replication launcher  
postgres   5980   5877  0 19:28 pts/0    00:00:00 ps -ef
postgres   5981   5877  0 19:28 pts/0    00:00:00 grep --color=auto postgres
Step 6: then put the application details on pg_hba.conf file the reload or restart the postgres server then check the postgres connectivity and check the data partition whether is updated or not in data_directory parameter.
[postgres@master ~]$ psql 
psql (10.3) 
Type "help" for help. 
postgres=# 
postgres=# show data_directory; 
data_directory 
---------------- 
/mnt/DATA 
(1 row)

Comments

Popular posts from this blog

Oracle DBMS SCHEDULER Examples

How to find the server is whether standby (slave) or primary(master) in Postgresql replication ?

7 Steps to configure BDR replication in postgresql

How to Get Table Size, Database Size, Indexes Size, schema Size, Tablespace Size, column Size in PostgreSQL Database

vacuumlo - removing large objects orphans from a database PostgreSQL