At this
paper. You will see how you can install PostgreSQL on Oracle Linux 7
There are
many ways to install PostgreSQL on Oracle Linux 7. We chose to use yum to
install PostgreSQL.
After
installing Oracle Linux 7 on Oracle Virtula Box. First Check yum repository.
If that
contains PostgreSQL
[root@localhost
~]# yum list | grep postgresql
postgresql.x86_64 9.2.15-1.el7_2 @ol7_latest
postgresql-libs.x86_64 9.2.15-1.el7_2 @ol7_latest
postgresql-server.x86_64 9.2.15-1.el7_2 @ol7_latest
pcp-pmda-postgresql.x86_64 3.10.6-2.el7 ol7_latest
postgresql.i686 9.2.15-1.el7_2 ol7_latest
postgresql-contrib.x86_64 9.2.15-1.el7_2 ol7_latest
postgresql-devel.i686 9.2.15-1.el7_2 ol7_latest
postgresql-devel.x86_64 9.2.15-1.el7_2 ol7_latest
postgresql-docs.x86_64 9.2.15-1.el7_2 ol7_latest
postgresql-jdbc.noarch 9.2.1002-5.el7 ol7_latest
postgresql-libs.i686 9.2.15-1.el7_2 ol7_latest
postgresql-odbc.x86_64 09.03.0100-2.el7 ol7_latest
postgresql-plperl.x86_64 9.2.15-1.el7_2 ol7_latest
postgresql-plpython.x86_64 9.2.15-1.el7_2 ol7_latest
postgresql-pltcl.x86_64 9.2.15-1.el7_2 ol7_latest
postgresql-test.x86_64 9.2.15-1.el7_2 ol7_latest
qt-postgresql.i686 1:4.8.5-11.el7 ol7_latest
qt-postgresql.x86_64 1:4.8.5-11.el7 ol7_latest
Now we
can start to installation;
Install
PostgreSQL
[root@localhost
~]# yum install postgresql
Loaded
plugins: langpacks
ol7_UEKR3
| 1.2 kB 00:00
ol7_latest
| 1.4 kB 00:00
Resolving
Dependencies
-->
Running transaction check
--->
Package postgresql.x86_64 0:9.2.15-1.el7_2 will be installed
-->
Processing Dependency: postgresql-libs(x86-64) = 9.2.15-1.el7_2 for package:
postgresql-9.2.15-1.el7_2.x86_64
-->
Processing Dependency: libpq.so.5()(64bit) for package:
postgresql-9.2.15-1.el7_2.x86_64
-->
Running transaction check
--->
Package postgresql-libs.x86_64 0:9.2.15-1.el7_2 will be installed
-->
Finished Dependency Resolution
Dependencies
Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
postgresql x86_64 9.2.15-1.el7_2 ol7_latest 3.0 M
Installing
for dependencies:
postgresql-libs x86_64 9.2.15-1.el7_2 ol7_latest 231 k
Transaction
Summary
================================================================================
Install 1 Package (+1 Dependent package)
Total
download size: 3.2 M
Installed
size: 16 M
Is this
ok [y/d/N]: y
Downloading
packages:
(1/2):
postgresql-libs-9.2.15-1.el7_2.x86_64.rpm | 231 kB 00:00
(2/2):
postgresql-9.2.15-1.el7_2.x86_64.rpm
| 3.0 MB 00:01
--------------------------------------------------------------------------------
Total
1.9 MB/s | 3.2 MB 00:01
Running
transaction check
Running
transaction test
Transaction
test succeeded
Running
transaction
Installing :
postgresql-libs-9.2.15-1.el7_2.x86_64 1/2
Installing :
postgresql-9.2.15-1.el7_2.x86_64 2/2
Verifying
: postgresql-libs-9.2.15-1.el7_2.x86_64 1/2
Verifying
yum install postgresql-server: postgresql-9.2.15-1.el7_2.x86_64 2/2
Installed:
postgresql.x86_64 0:9.2.15-1.el7_2
Dependency
Installed:
postgresql-libs.x86_64 0:9.2.15-1.el7_2
Complete!
[root@localhost
~]# yum install postgresql-server
Loaded
plugins: langpacks
Resolving
Dependencies
-->
Running transaction check
--->
Package postgresql-server.x86_64 0:9.2.15-1.el7_2 will be installed
-->
Finished Dependency Resolution
Dependencies
Resolved
================================================================================================================
Package Arch Version Repository Size
================================================================================================================
Installing:
postgresql-server x86_64 9.2.15-1.el7_2 ol7_latest 3.8 M
Transaction
Summary
================================================================================================================
Install 1 Package
Total
download size: 3.8 M
Installed
size: 16 M
Is this
ok [y/d/N]: y
Downloading
packages:
postgresql-server-9.2.15-1.el7_2.x86_64.rpm |
3.8 MB 00:00:02
Running
transaction check
Running
transaction test
Transaction
test succeeded
Running
transaction
Installing :
postgresql-server-9.2.15-1.el7_2.x86_64
1/1
Verifying
: postgresql-server-9.2.15-1.el7_2.x86_64
1/1
Installed:
postgresql-server.x86_64
0:9.2.15-1.el7_2
Complete!
[root@localhost
~]#
Installation
is completed. Now we configure PostgreSQL
[root@localhost
~]# service postgresql initdb
Hint:
the preferred way to do this is now "postgresql-setup initdb"
Initializing
database ... OK
There is
a warning but , It is not important.
Now we
can start PostgreSQL.
[root@localhost
init.d]# service postgresql start
Redirecting
to /bin/systemctl start
postgresql.service
[root@localhost
init.d]# service postgresql status
Redirecting
to /bin/systemctl status
postgresql.service
postgresql.service
- PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service;
disabled)
Active: active (running) since Sun
2016-04-17 10:02:32 EEST; 10s ago
Process: 4894 ExecStart=/usr/bin/pg_ctl start
-D ${PGDATA} -s -o -p ${PGPORT} -w -t 300 (code=exited, status=0/SUCCESS)
Process: 4889
ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGDATA} (code=exited,
status=0/SUCCESS)
Main PID: 4898 (postgres)
CGroup: /system.slice/postgresql.service
├─4898 /usr/bin/postgres -D /var/lib/pgsql/data
-p 5432
├─4899 postgres: logger process
├─4901 postgres: checkpointer process
├─4902 postgres: writer process
├─4903 postgres: wal writer process
├─4904 postgres: autovacuum launcher process
└─4905 postgres: stats collector
process
Apr 17
10:02:31 localhost.localdomain systemd[1]: Starting PostgreSQL databas...
Apr 17
10:02:32 localhost.localdomain systemd[1]: Started PostgreSQL database...
Hint:
Some lines were ellipsized, use -l to show in full.
[root@localhost
init.d]#
To stop
it
[root@localhost
init.d]# service postgresql stop
Redirecting
to /bin/systemctl stop
postgresql.service
Logon
and start to use PostgreSQL
# su -
postgres
Last
login: Sun Apr 17 10:13:20 EEST 2016 on pts/0
-bash-4.2$
psql postgres
psql
(9.2.15)
Type
"help" for help.
postgres-#
\l # To list Databases
List of
databases
Name
| Owner | Encoding |
Collate | Ctype
| Access privileges
-----------+----------+----------+------------+------------+--------------------
---
postgres
| postgres | UTF8 | en_GB.utf8
| en_GB.utf8 |
template0 | postgres | UTF8 | en_GB.utf8 | en_GB.utf8 |
=c/postgres
+
| | | | | postgres=CTc/postgr
es
template1 | postgres | UTF8 | en_GB.utf8 | en_GB.utf8 |
=c/postgres
+
| | | | | postgres=CTc/postgr
es
(3 rows)
postgres=#
\q # to Quit
-bash-4.2$