Taking Backup of IAM H2 database and upgrade to latest version
search cancel

Taking Backup of IAM H2 database and upgrade to latest version

book

Article ID: 233393

calendar_today

Updated On:

Products

CA Application Test

Issue/Introduction

We have Devtest IAM users configured in embeded database and planning to upgrade from Devtest 10.6 to Devtest 10.7.2.

When we do the inplace upgrade, IAM is not coming up due to database connection error Noticed below error in logs.

Can you give the steps to upgrade enmbeded database before upgrading devtest components.

ERROR:

 [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (ServerService Thread Pool -- 64) IJ000604: Throwable while attempting to get a new connection: null: javax.resource.ResourceException: IJ031084: Unable to create connection
    at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:345)
    at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:352)
    at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:287)
    at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.createConnectionEventListener(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:1322)
    at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.getConnection(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:499)

Environment

Release : DevTest 10.7.2

Component : DevTest Install/Upgrade

Cause

Sometimes IAM DB is corrupted or because of user details in database, details are not imported/exported correctly and causes this issue during upgrade.

Resolution

Follow the below steps to take backup of IAM default database h2 before starting the upgrade:
  1.  Run below command to copy keycloak h2 database in your local machine:
  2. kubectl cp <iaam-pod>:/iam/standalone/data/keycloak.mv.db .
  3. Run below command to copy h2 jar in your local machine:
    kubectl cp iaam-pod:/iam/modules/system/layers/base/com/h2database/h2/main/h2-1.4.193.jar . 
  4. Check if Java 8 is there in your local machine:
    java -version
  5. Take backup of the h2 database in your local machine:
    java -cp h2*.jar org.h2.tools.Script -url jdbc:h2:./keycloak -user sa -password sa
    This will create backup.sql in your local machine.

Now upgrade the environment to latest version. After completion of upgrade, follow the steps to restore the backup data.

1. Go to {LISA_HOME}/IdentityAccessManager/standalone folder and create data folder.
2. Go to data folder and copy the backup.sql file.
3. Run the below command to restore backup:
java -cp ../../modules/system/layers/base/com/h2database/h2/main/h2*.jar org.h2.tools.RunScript -url jdbc:h2:./keycloak -user sa -password sa
4. Go to {LISA_HOME}/IdentityAccessManager/bin directory and Start ./IdentityAccessManager.sh
5. Check if all the data comes