Sunday 26 May 2019

Install postgreSQL 11 on cent OS 7.6


1] Create user postgres

[root@node1 ~]# adduser postgres
[root@node1 ~]# passwd postgres
Changing password for user postgres.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@node1 ~]#

2] Provide sudo access to postgres User.

3] Configure rpm repos for postgreSQL 11

[root@localhost ~]# yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

Loaded plugins: langpacks, ulninfo
pgdg-redhat-repo-latest.noarch.rpm | 5.6 kB 00:00:00
Examining /var/tmp/yum-root-Qytr2V/pgdg-redhat-repo-latest.noarch.rpm: pgdg-redhat-repo-42.0-4.noarch
Marking /var/tmp/yum-root-Qytr2V/pgdg-redhat-repo-latest.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package pgdg-redhat-repo.noarch 0:42.0-4 will be installed
--> Finished Dependency Resolution
ol7_UEKR5/x86_64 | 1.2 kB 00:00:00
ol7_latest/x86_64 | 1.4 kB 00:00:00
ol7_latest/x86_64/updateinfo | 926 kB 00:00:00
ol7_latest/x86_64/primary | 14 MB 00:00:11
Dependencies Resolved
===============================================================================================
Package Arch Version Repository Size
===============================================================================================
Installing:
pgdg-redhat-repo noarch 42.0-4 /pgdg-redhat-repo-latest.noarch 6.8 k
Transaction Summary
===============================================================================================
Install 1 Package
Total size: 6.8 k
Installed size: 6.8 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : pgdg-redhat-repo-42.0-4.noarch 1/1
Verifying : pgdg-redhat-repo-42.0-4.noarch 1/1
Installed:
pgdg-redhat-repo.noarch 0:42.0-4
Complete!

[postgres@node1 yum.repos.d]$ cd /etc/yum.repos.d
[postgres@node1 yum.repos.d]$ pwd
/etc/yum.repos.d
[postgres@node1 yum.repos.d]$ ls -ltr pgdg-redhat-all.repo
-rw-r--r--. 1 root root 5189 Apr 17 09:42 pgdg-redhat-all.repo


4] Install postgreSQL 11 version using rpm package.

==> install postgresql client and server.

[root@node1 ~]# yum install postgresql11

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos-hcm.viettelidc.com.vn
* extras: centos-hn.viettelidc.com.vn
* updates: centos-hn.viettelidc.com.vn
Resolving Dependencies
--> Running transaction check
---> Package postgresql11.x86_64 0:11.3-1PGDG.rhel7 will be installed
--> Processing Dependency: postgresql11-libs(x86-64) = 11.3-1PGDG.rhel7 for package: postgresql11-11.3-1PGDG.rhel7.x86_64
--> Processing Dependency: libpq.so.5()(64bit) for package: postgresql11-11.3-1PGDG.rhel7.x86_64
--> Running transaction check
---> Package postgresql11-libs.x86_64 0:11.3-1PGDG.rhel7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================
Package Arch Version Repository Size
===============================================================================================
Installing:
postgresql11 x86_64 11.3-1PGDG.rhel7 pgdg11 1.7 M
Installing for dependencies:
postgresql11-libs x86_64 11.3-1PGDG.rhel7 pgdg11 360 k
Transaction Summary
===============================================================================================
Install 1 Package (+1 Dependent package)
Total download size: 2.0 M
Installed size: 10 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/pgdg11/packages/postgresql11-libs-11.3-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Public key for postgresql11-libs-11.3-1PGDG.rhel7.x86_64.rpm is not installed
(1/2): postgresql11-libs-11.3-1PGDG.rhel7.x86_64.rpm | 360 kB 00:00:03
(2/2): postgresql11-11.3-1PGDG.rhel7.x86_64.rpm | 1.7 MB 00:00:07
-----------------------------------------------------------------------------------------------
Total 262 kB/s | 2.0 MB 00:00:07
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Importing GPG key 0x442DF0F8:
Userid : "PostgreSQL RPM Building Project <pgsqlrpms-hackers@pgfoundry.org>"
Fingerprint: 68c9 e2b9 1a37 d136 fe74 d176 1f16 d2e1 442d f0f8
Package : pgdg-redhat-repo-42.0-4.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : postgresql11-libs-11.3-1PGDG.rhel7.x86_64 1/2
Installing : postgresql11-11.3-1PGDG.rhel7.x86_64 2/2
Verifying : postgresql11-11.3-1PGDG.rhel7.x86_64 1/2
Verifying : postgresql11-libs-11.3-1PGDG.rhel7.x86_64 2/2
Installed:
postgresql11.x86_64 0:11.3-1PGDG.rhel7
Dependency Installed:
postgresql11-libs.x86_64 0:11.3-1PGDG.rhel7
Complete!
[root@node1 ~]# yum install postgresql11-server
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos-hcm.viettelidc.com.vn
* extras: centos-hn.viettelidc.com.vn
* updates: centos-hn.viettelidc.com.vn
Resolving Dependencies
--> Running transaction check
---> Package postgresql11-server.x86_64 0:11.3-1PGDG.rhel7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================
Package Arch Version Repository Size
===============================================================================================
Installing:
postgresql11-server x86_64 11.3-1PGDG.rhel7 pgdg11 4.7 M
Transaction Summary
===============================================================================================
Install 1 Package
Total download size: 4.7 M
Installed size: 19 M
Is this ok [y/d/N]: y
Downloading packages:
postgresql11-server-11.3-1PGDG.rhel7.x86_64.rpm | 4.7 MB 00:00:18
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : postgresql11-server-11.3-1PGDG.rhel7.x86_64 1/1
Verifying : postgresql11-server-11.3-1PGDG.rhel7.x86_64 1/1
Installed:
postgresql11-server.x86_64 0:11.3-1PGDG.rhel7
Complete!

5] Initialize the database and start database server.

[root@node1 ~]# /usr/pgsql-11/bin/postgresql-11-setup initdb

Initializing database ... OK

[root@node1 ~]# systemctl enable postgresql-11
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-11.service to /usr/lib/systemd/system/postgresql-11.service.

[root@node1 ~]# systemctl start postgresql-11


6] Connect to database

[root@node1 ~]# sudo su - postgres

[postgres@node1 ~]$ psql
psql (11.3)
Type "help" for help.
postgres=#
postgres=# select version();
version
-----------------------------------------------------------------------------------------------
----------
PostgreSQL 11.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36
), 64-bit
(1 row)
postgres=#

Monday 20 May 2019

How to install postgresql server on linux?


==> Below are the steps to install postgreSQL server.

1] Create user postgres.

[root@node1 ~]# adduser postgres
[root@node1 ~]# passwd postgres
Changing password for user postgres.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@node1 ~]#

2] Provide sudo access to postgres User.

3] Check postgreSQL package install or not.

[root@node1 ~]# rpm -qa | grep postgresql
[root@node1 ~]#

4] Install postgresql package.

[root@node1 ~]# yum install postgresql-server
Loaded plugins: langpacks, ulninfo
ol7_UEKR5                                                               | 1.2 kB  00:00:00
ol7_latest                                                              | 1.4 kB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package postgresql-server.x86_64 0:9.2.24-1.el7_5 will be installed
--> Processing Dependency: postgresql-libs(x86-64) = 9.2.24-1.el7_5 for package: postgresql-server-9.2.24-1.el7_5.x86_64
--> Processing Dependency: postgresql(x86-64) = 9.2.24-1.el7_5 for package: postgresql-server-9.2.24-1.el7_5.x86_64
--> Processing Dependency: libpq.so.5()(64bit) for package: postgresql-server-9.2.24-1.el7_5.x86_64
--> Running transaction check
---> Package postgresql.x86_64 0:9.2.24-1.el7_5 will be installed
---> Package postgresql-libs.x86_64 0:9.2.24-1.el7_5 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================
 Package                    Arch            Version                  Repository           Size
===============================================================================================
Installing:
 postgresql-server          x86_64          9.2.24-1.el7_5           ol7_latest          3.8 M
Installing for dependencies:
 postgresql                 x86_64          9.2.24-1.el7_5           ol7_latest          3.0 M
 postgresql-libs            x86_64          9.2.24-1.el7_5           ol7_latest          233 k
Transaction Summary
===============================================================================================
Install  1 Package (+2 Dependent packages)
Total download size: 7.1 M
Installed size: 33 M
Is this ok [y/d/N]: Y
Downloading packages:
warning: /var/cache/yum/x86_64/7Server/ol7_latest/packages/postgresql-libs-9.2.24-1.el7_5.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Public key for postgresql-libs-9.2.24-1.el7_5.x86_64.rpm is not installed
(1/3): postgresql-libs-9.2.24-1.el7_5.x86_64.rpm                        | 233 kB  00:00:00
(2/3): postgresql-9.2.24-1.el7_5.x86_64.rpm                             | 3.0 MB  00:00:05
(3/3): postgresql-server-9.2.24-1.el7_5.x86_64.rpm                      | 3.8 MB  00:00:05
-----------------------------------------------------------------------------------------------
Total                                                          1.1 MB/s | 7.1 MB  00:00:06
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
Importing GPG key 0xEC551F03:
 Userid     : "Oracle OSS group (Open Source Software group) <build@oss.oracle.com>"
 Fingerprint: 4214 4123 fecf c55b 9086 313d 72f9 7b74 ec55 1f03
 Package    : 7:oraclelinux-release-7.6-1.0.15.el7.x86_64 (@anaconda/7.6)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
Is this ok [y/N]: Y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : postgresql-libs-9.2.24-1.el7_5.x86_64                                       1/3
  Installing : postgresql-9.2.24-1.el7_5.x86_64                                            2/3
  Installing : postgresql-server-9.2.24-1.el7_5.x86_64                                     3/3
  Verifying  : postgresql-server-9.2.24-1.el7_5.x86_64                                     1/3
  Verifying  : postgresql-libs-9.2.24-1.el7_5.x86_64                                       2/3
  Verifying  : postgresql-9.2.24-1.el7_5.x86_64                                            3/3

Installed:
  postgresql-server.x86_64 0:9.2.24-1.el7_5
Dependency Installed:
  postgresql.x86_64 0:9.2.24-1.el7_5          postgresql-libs.x86_64 0:9.2.24-1.el7_5
Complete!

5] Start and add postgreSQL service.

[root@node1 ~]# postgresql-setup initdb
Initializing database ... OK
[root@node1 ~]# systemctl enable postgresql.service
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql.service to /usr/lib/systemd/system/postgresql.service.
[root@node1 ~]# systemctl start postgresql.service
[root@node1 ~]#

6] Connect to postgresql database.

[root@node1 ~]# sudo su - postgres
[postgres@node1 ~]$ psql
psql (9.2.24)
Type "help" for help.
postgres=#
postgres=# SELECT version();
                                                      version

-----------------------------------------------------------------------------------------------
--------------------
 PostgreSQL 9.2.24 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.
8.5-28.0.1), 64-bit
(1 row)
postgres=#

work on autovacuum postgreSQL parameter

 In This blog, we are discussing the auto vacuum parameter on a small scale. we will understand the below parameters and will see how to mod...