How to set a PostgreSQL as a primary DB instead of H2

This tutorial is intended for those, who followed "Getting started" tutorial to run IdM as a local demo (for Linux server).

It is not recommended for production use!!!

1) Authentication method properly set in "pg_hba.conf" to be able to CzechIdM to connect.

example

2) DB dedicated to CzechIdM with proper owner - ideally named "czechidm"

example

3) PostgreSql up and running - check with

systemctl status postgresql.service -l

1) Download jdbs postgresql driver for tomcat and place it into tomcat /lib

example

2) In tomcat /bin create "setenv.sh" file with

JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true -Djavax.servlet.request.encoding=UTF-8 -Dspring.profiles.active=dev -Djava.util.Arrays.useLegacyMergeSort=true"

thus you specify spring profile as "dev"

3) Check file "/webapps/idm/WEB-INF/classes/application-dev.properties" in tomcat. There credentials must be set for the tomcat to connect to PostgreSQL, for example

spring.datasource.url=jdbc:postgresql://localhost:5432/czechidm
spring.datasource.username=czechidm
spring.datasource.password=TODOPASSWORD

If idm wasn't deployed yet (folder idm doesn't exist). The file *application-dev.properties* will be available in idm.war file. "idm.war/webapps/idm/WEB-INF/classes/application-dev.properties".

4) Now you can start tomcat as usual (startup.sh)

Be aware that this tutorial only shows quick solution to set connection to postgreSQL. It is for testing purposes only and not for production use
If you upgrade to new version of czechidm - thus tomcat make changes in "webapps/idm" directory, you lost the configuraction set in this tutorial. So do not deploy to tomcat unless you backup files mensioned in this tutorial!
For files catalina.sh, catalina.sh, catalina.sh and catalina.sh must be setup permissions for read and execute for user that will execute commands for startup and end tomcat - IdM application.
  • by kopro