Download as pdf or txt
Download as pdf or txt
You are on page 1of 36

TAFJ-Po s t g r e S QL 1 1

I n s t all
R20
TAFJ-Po s t g r e S QL I n s t all

Amendment History:

Revisio
Date Amended Name Description
n

1 1st April 2017 H. Aubert Initial version

2 6th Jun 2017 M. Kumar procedure with screen shots

3 5th July 2019 H. Aubert PostgreSQL 10

4 29th Jan 2020 M. Kumar Screen shots for PostgreSQL 11.

Update PL/SQL procedure load instead of java


5 10th Mar 2020 M. Kumar
stored procs.

6 24th Mar 2020 M. Kumar R20 AMR review

Page 2
TAFJ-Po s t g r e S QL I n s t all

Copyri g h t
Copyright © Temenos Headquarters SA 2009-2020

All rights reserved.

This document contains proprietary information that is protected by copyright. No part of this document may
be reproduced, transmitted, or made available directly or indirectly to a third party without the express
written agreement of TEMENOS UK Limited. Receipt of this material directly TEMENOS UK Limited
constitutes its express permission to copy. Permission to use or copy this document expressly excludes
modifying it for any purpose, or using it to create a derivative therefrom.

Errat a and Com m e n t s


If you have any comments regarding this manual or wish to report any errors in the
documentation, please document them and send them to the address below:
Technology Department

Temenos Headquarters SA
2 Rue de l’Ecole-de-Chimie,
CH - 1205 Geneva,
Switzerland

Tel SB: +41 (0) 22 708 1150


Fax: +41 (0) 22 708 1160

Please include your name, company, address, and telephone and fax numbers, and email
address if applicable. TAFJdev@temenos.com

Page 3
TAFJ-Po s t g r e S QL I n s t all

Table of Contents
Copyright................................................................................................................................................ 3
Errata and Comments............................................................................................................................ 3
Introduction............................................................................................................................................. 5
Download PostgreSQL........................................................................................................................... 5
Install PostgreSQL.................................................................................................................................. 5
Connect to the database...................................................................................................................... 18
Set and add PG_HOME variable.......................................................................................................... 19
BUILD PLJava...................................................................................................................................... 19
Open CMD and build PL\Java as administrator....................................................................................21
Install PL_Java and necessary stored functions into PostgreSQL DB..................................................23
Create the T24 database and user....................................................................................................... 24
Login with new t24 user:....................................................................................................................... 25

Page 4
TAFJ-Po s t g r e S QL I n s t all

Intro d u c t i o n
This document will show all steps to configure a database, ready to be used by T24 with
TAFJ.

This procedure is for Windows® platform. For all other OS please refer to the official product
documentation.

Dow n l o a d Pos t g r e S Q L
From the following link: https://www.enterprisedb.com/downloads/postgres-postgresql-
downloads

Select the version 10.x and your operating system

Inst a l l Pos t g r e S Q L
Execute the downloaded file postgresql-11.6-3-windows-x64.exe.

Press Next…

Page 5
TAFJ-Po s t g r e S QL I n s t all

Choose the Installation Directory... (it will be $PG_HOME)

Press Next…

Page 6
TAFJ-Po s t g r e S QL I n s t all

Press Next…

Select the Data Directory...

Press Next…

Page 7
TAFJ-Po s t g r e S QL I n s t all

Set a Password. This is NOT (!) the password you will set in the properties file...

Page 8
TAFJ-Po s t g r e S QL I n s t all

Press Next…

Press Next…

Page 9
TAFJ-Po s t g r e S QL I n s t all

Press Next…

Page 10
TAFJ-Po s t g r e S QL I n s t all

Press Next…

Page 11
TAFJ-Po s t g r e S QL I n s t all

Press Next…

Page 12
TAFJ-Po s t g r e S QL I n s t all

Press Finish…

Page 13
TAFJ-Po s t g r e S QL I n s t all

Press your PostgreSQL installation…

Press Next…

Select pgJDBC

Page 14
TAFJ-Po s t g r e S QL I n s t all

Press Next…

Choose Download Directory...

Page 15
TAFJ-Po s t g r e S QL I n s t all

Press Next…

Page 16
TAFJ-Po s t g r e S QL I n s t all

Press Next…

Page 17
TAFJ-Po s t g r e S QL I n s t all

Press Finish…

Execute from the download edb_pgjdbc.exe

Press Next…

Set the path to %PG_HOME%\pgJDBC

Page 18
TAFJ-Po s t g r e S QL I n s t all

Press Next…

Press Next…

Page 19
TAFJ-Po s t g r e S QL I n s t all

Press Finish…

Restart your computer if prompts

Try connecting to the master DB using pgAdmin4.

Execute %PG_HOME%\pgAdmin4\bin\pgAdmin4.exe

Page 20
TAFJ-Po s t g r e S QL I n s t all

 Press the passwords given during the installation process…

Con n e c t to the dat a b a s e


To connect to the database, open a web browser.

Page 21
TAFJ-Po s t g r e S QL I n s t all

Press the passwords given during the installation process…

You are connected to the database : PosgreSQL with the user postgres

Page 22
TAFJ-Po s t g r e S QL I n s t all

Se t and add PG_HOME varia b l e


Edit %PG_HOME%\pg_env.bat

Change and set PG_HOME


@ECHO OFF
REM The script sets environment variables helpful for PostgreSQL

@SET PG_HOME="E:\3rdParty\Db\PostgreSQL\10"
@SET PGDATA=E:\3rdParty\Db\PostgreSQL\10\data
@SET PGDATABASE=postgres
@SET PGUSER=postgres
@SET PGPORT=5432
@SET PGLOCALEDIR=E:\3rdParty\Db\PostgreSQL\10\share\locale

@SET PATH="%PG_HOME%\bin";%PATH%

Page 23
TAFJ-Po s t g r e S QL I n s t all

Inst a l l ne c e s s a r y T24- Tran s a c t relat e d set t i n g s


int o Pos t g r e S Q L DB.

Change the following parameter with higher number and uncomment it to avoid error
shared memory : max_locks_per_transaction
#--------------------------------------------------------------------------------
--------------------------
max_locks_per_transaction = 10000 (instead of 64 by default)

Post this step; restart the PostgreSQL services to take effect of environment variable
change.

Creat e the T24 data b a s e and us e r


Connect through psql prompt using super user and execute the following script to
create a database and user for T24 use.

psql.exe

Password:
CREATE TABLESPACE t24data OWNER postgres LOCATION
‘C:\PostgreSQL\postgressData\t24’;

CREATE DATABASE "T24" WITH OWNER = postgres TEMPLATE = template0


ENCODING = 'UTF8' TABLESPACE = t24data CONNECTION LIMIT = -1;

CREATE USER t24 WITH LOGIN SUPERUSER NOCREATEDB NOCREATEROLE


INHERIT NOREPLICATION CONNECTION LIMIT -1 PASSWORD 't24';

GRANT ALL ON DATABASE "T24" TO t24;

Page 24
TAFJ-Po s t g r e S QL I n s t all

Restart the PostgreSQL service from windows services section.

Logi n with new t2 4 us e r:


psql.exe T24 t24
Password for user t24:

Load the necessary PL/SQL functions into the database using the script under

$TAFJ_HOME/DBScripts/postgreSql (WARNING: Postgres does not like


backslashes!)

Server [localhost]:
Database [postgres]: T24
Port [5433]:
Username [postgres]: t24

Page 25
TAFJ-Po s t g r e S QL I n s t all

Password for user t24:


psql (11.6)
WARNING: Console code page (437) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page "Notes for Windows users" for details.
Type "help" for help.

T24=# \i
'C:/Temenos/Development/TAFJ_SOURCES/TAFJ_DEV/TAFJHome/dbscripts/postg
resql/plsqlfunctions_postgresql.sql';

CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION

Page 26
TAFJ-Po s t g r e S QL I n s t all

CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION

Page 27
TAFJ-Po s t g r e S QL I n s t all

CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
T24=#

Page 28
TAFJ-Po s t g r e S QL I n s t all

T24=# CREATE CAST (varchar AS numeric) WITH INOUT AS IMPLICIT;

The line above creates an implicit cast from varchar to numeric. Without it, queries
such as :

SELECT RECID FROM “V_FBNK_CURRENCY” WHERE “RANK” > 2

Where “RANK” is implicitly converted to numeric will fail.

The \df command should be executed to verify the functions have been loaded inside DB.

Also, from the pgAdmin4, the following could be executed

SELECT proname FROM pg_catalog.pg_namespace n JOIN pg_catalog.pg_proc p

ON pronamespace = n.oid WHERE nspname = 'public';

Page 29
TAFJ-Po s t g r e S QL I n s t all

Once done, we are ready for the DB Import process to populate necessary tables and data
for T24 on this newly created database in PostgreSQL.

Page 30
TAFJ-Po s t g r e S QL I n s t all

Inst a l l Pos t g r e s q l with Doc k e r


Postgres has a Debian linux docker image out on dockerhub. One can take this image and
build one with pljava using the script below. This docker script will install all dependencies
for pljava and pljava for Postgresql version 10.9

ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64

RUN apt-get update -y

RUN apt-get install -y apt-utils

RUN apt-get install -y default-jdk

RUN apt-get install -y gcc

RUN apt-get install -y g++

RUN apt-get install -y python-psycopg2

RUN apt-get install -y postgresql postgresql-contrib

RUN apt-get install -y postgresql-server-dev-10

RUN apt-get install -y libkrb5-dev

RUN apt-get install -y libecpg-dev

RUN apt-get install -y libssl-dev

RUN apt-get install -y maven

RUN apt-get install -y git

RUN cd /usr/share/postgresql/ \

&& git clone https://github.com/tada/pljava.git \

&& cd pljava \

&& mvn clean install -Pwnosign

RUN cd /usr/share/postgresql/pljava/pljava-packaging/target && java -jar pljava-pg10.10-


amd64-Linux-gpp.jar

With the above image built, one can then run the below docker script to install
TAFJFunctions.jar

FROM ${POSTGRES_IMAGE_BUILT_ABOVE}

COPY --chown=postgres:root TAFJFunctions.jar /u01/app/

Page 31
TAFJ-Po s t g r e S QL I n s t all

COPY --chown=postgres:root javafunctions_postgresql.sql /u01/app/sql/

COPY --chown=postgres:root start-postgresql.sh /u01/app/

RUN chmod 755 /u01/app/start-postgresql.sh && chmod 755 /u01/app && chmod 755
/u01/app/data

USER postgres

ENTRYPOINT /u01/app/start-postgresql.sh

Where start-postresql.sh is shown below:

#!/bin/bash

# Debian

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

export PG_HOME=/usr/local/share/postgresql/

export POSTGRES_DB=$DB_NAME

export POSTGRES_USER=$DB_USER

export POSTGRES_PASSWORD=$DB_PASSWORD

echo "POSTGRES_DB:" $DB_NAME

echo "POSTGRES_USER: " $DB_USER

echo "POSTGRES_PASSWORD: " $DB_PASSWORD

cd /u01/app/sql

# Debian

/usr/lib/postgresql/10/bin/initdb

# Debian

/usr/lib/postgresql/10/bin/pg_ctl -D /var/lib/postgresql/data start

Page 32
TAFJ-Po s t g r e S QL I n s t all

# Create the database

psql --echo-all -v ON_ERROR_STOP=1 --username postgres <<-EOF

\x

ALTER SYSTEM set max_locks_per_transaction=500;

CREATE TABLESPACE t24data OWNER postgres LOCATION '/u01/app/data';

ALTER TABLESPACE t24data OWNER TO postgres;

CREATE DATABASE "$POSTGRES_DB" WITH OWNER = postgres TEMPLATE =


template0 ENCODING = 'UTF8' LC_COLLATE='C.UTF-8' TABLESPACE = t24data
CONNECTION LIMIT = -1;

CREATE USER $POSTGRES_USER WITH LOGIN SUPERUSER NOCREATEDB


NOCREATEROLE INHERIT NOREPLICATION CONNECTION LIMIT -1 PASSWORD
'$POSTGRES_PASSWORD';

GRANT ALL ON DATABASE "$POSTGRES_DB" TO $POSTGRES_USER;

EOF

#Debian

echo "pljava.classpath='/usr/share/postgresql/10/pljava/pljava-1.6.0-
SNAPSHOT.jar:/u01/app/TAFJFunctions.jar'" >> /var/lib/postgresql/data/postgresql.conf

echo "pljava.libjvm_location='/usr/lib/jvm/java-8-openjdk-
amd64/jre/lib/amd64/server/libjvm.so'" >> /var/lib/postgresql/data/postgresql.conf

echo "host all all 0.0.0.0/0 md5" >> /var/lib/postgresql/data/pg_hba.conf

# Debian

/usr/lib/postgresql/10/bin/pg_ctl -D /var/lib/postgresql/data stop

/usr/lib/postgresql/10/bin/pg_ctl -D /var/lib/postgresql/data start

echo

echo "Creating pljava extension...."

echo

psql --echo-all -v ON_ERROR_STOP=1 --username postgres <<-EOF

Page 33
TAFJ-Po s t g r e S QL I n s t all

\x

CREATE EXTENSION pljava;

GRANT USAGE ON LANGUAGE java TO postgres;

EOF

psql --echo-all -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d "$POSTGRES_DB"


<<-eosql

\x

CREATE EXTENSION pljava;

GRANT USAGE ON LANGUAGE java TO $POSTGRES_USER;

CREATE CAST (varchar AS numeric) WITH INOUT AS IMPLICIT;

eosql

# Stored functions

psql --echo-all -U "$POSTGRES_USER" -d "$POSTGRES_DB" -f


./javafunctions_postgresql.sql

echo "Finished post install"

# Wait

while true; do sleep 10000; done

Inst a l l Pos t g r e s q l for Ubu n t u

Following a similar procedure, it should work for Ubuntu (install of Postgresql on Ubuntu not
shown).

As a root os user:

apt-get update -y

Page 34
TAFJ-Po s t g r e S QL I n s t all

apt-get install -y apt-utils

apt-get install java-8-openjdk-amd64

apt-get install -y gcc

apt-get install -y g++

apt-get install -y python-psycopg2

apt-get install -y postgresql postgresql-contrib

apt-get install -y postgresql-server-dev-10

apt-get install -y libkrb5-dev

apt-get install -y libecpg-dev

apt-get install -y libssl-dev

apt-get install -y maven

apt-get install -y git

As a postgres os user:

cd /usr/share/postgresql/

To get pljava:

git clone https://github.com/tada/pljava.git

cd pljava

mvn clean install -Pwnosign

cd /usr/share/postgresql/pljava/pljava-packaging/target

java –jar <pljava.jar>, example: java -jar pljava-pg10.10-amd64-Linux-gpp.jar

Configuration Parameters in postgresql psql:

SHOW pljava.classpath;

--------------------------------------------------------------------------------------------------------------------------

Page 35
TAFJ-Po s t g r e S QL I n s t all

/usr/share/postgresql/10/pljava/pljava/target/pljava-1.6.0-
SNAPSHOT.jar;/u01/Temenos/TAFJ/dbscripts/h2/TAFJFunctions.jar

SHOW pljava.libjvm_location;

----------------------------------------------------------------------

/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/amd64/server/libjvm.so

Page 36

You might also like