HOWTO INSTALL KONG API GATEWAY & ITS DATABASE i.e., POSTGRES

Posted on July 18, 2018

0


ENVIRONMENT

Postgres = 9.6

Kong API Gateway = 0.11.2

OS = RHEL 7.3

 

INSTALL POSTGRES

  • Configure YUM repositories to install Postgres

cd /etc/yum.repos.d

yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm

  • Install Postgres database

yum search postgres|grep server

yum install -y postgresql96-server.x86_64

(reference below link for installation)

https://www.postgresql.org/download/linux/redhat/

  • Configure Postgres

su – postgres

$ /usr/pgsql-9.6/bin/pg_ctl initdb       #Create data and other directories under

/var/lib/pgsql/9.6/data

  • Check Postgres status

Procedure-1

systemctl start postgresql-9.6

systemctl status postgresql-9.6

  • Login to Postgres

su – postgres

$ psql

Procedure-2

/usr/pgsql/bin/pg_ctl status -w -D DATA_PATH -o “-p PORT -h HOSTNAME

/usr/pgsql/bin/pg_ctl start -w -D /var/lib/pgsql/9.6/data -o “-p 5432 -h IRIS5-NODE1”

/usr/pgsql/bin/pg_ctl status -w -D /var/lib/pgsql/9.6/data -o “-p 5432 -h IRIS5-NODE1”

  • CONFIGURE Postgres configuration file

vi /var/lib/pgsql/10/data/pg_hba.conf

# TYPE  DATABASE        USER            ADDRESS                 METHOD

 

# “local” is for Unix domain socket connections only

local   all             all                                                    md5

# IPv4 local connections:

host    all             all             127.0.0.1/32                 trust

# IPv6 local connections:

host    all             all             ::1/128                          trust

# Allow replication connections from localhost, by a user with the

# replication privilege.

local   replication     all                                              peer

host    replication     all             127.0.0.1/32            ident

host    replication     all             ::1/128                     ident

  • Create DATABASE, USERNAME,  PASSWORD in postgresql:

 

su -u postgres

psql

CREATE USER kong; CREATE DATABASE kong OWNER kong;

alter user kong with encrypted password ‘ABC123‘;

grant all privileges on database kong to kong;

  • RESTART POSTGRES

Follow above mentioned procedure

INSTALL KONG API GATEWAY

  • Download KONG API GATEWAY from below link

https://kong.bintray.com/kong-community-edition-rpm/centos/7/

  • Configure KONG API GATEWAY

vi /etc/kong/kong.conf

edit values accordingly:

database = postgres             # Determines which of PostgreSQL or Cassandra

# this node will use as its datastore.

# Accepted values are `postgres` and

# `cassandra`.

 

pg_host = 127.0.0.1                  # The PostgreSQL host to connect to.

pg_port = 5432                          # The port to connect to.

pg_user = kong                         # The username to authenticate if required.

pg_password = ABC123          # The password to authenticate if required.

pg_database = kong               # The database name to connect to.

 

pg_ssl = off                              # Toggles client-server TLS connections

# between Kong and PostgreSQL.

 

pg_ssl_verify = off             # Toggles server certificate verification if

# `pg_ssl` is enabled.

# See the `lua_ssl_trusted_certificate`

# setting to specify a certificate authority.

  • KONG MIGRATION AND START UP

kong migrations up [-c /path/to/kong.conf]

kong start [-c /path/to/kong.conf]

 

 

 

 

Posted in: Linux