Installation (example)

Installation Hints

The following installation instructions for Linux are thought as installation hint / example and do not come with any guarantee by Ergon/Airlock. Free support for the H2 database is not included in the Airlock SSU.

It has been tested with H2 version "h2-2017-06-10".

  • Make sure a Java runtime compatible with H2 is installed on the system (we use /usr/bin/java in the following example).
  • Download a stable version of H2 from http://www.h2database.com/html/download.html
  • Create an OS user and directory for h2:
  • copy
    # create user h2database and home directory (must be root to do that)
    useradd -d /home/h2database -m h2database
    # switch to that user
    su - h2database
  • Unzip the downloaded h2 zip file in the h2 users's home:
  • copy
    # in this example we downloaded the H2 archive to /var/tmp/
    $ unzip /var/tmp/h2-2017-06-10.zip
    # make shell scripts runnable
    $ chmod +x h2/bin/*.sh
    # Test the installation by executing (requires that the command "java" can be executed)
    # It should print the usage message.
    $ ./h2/bin/h2.sh -help
  • Create a data directory:
  • copy
    # create data directory
    $ mkdir data
    # h2database user's home should look like
    $ ls
    data h2
  • To start the database "iamdb" in foreground, use the following example:# start database server with web console in foreground java -cp h2/bin/h2-1.4.196.jar org.h2.tools.Server -tcp -tcpPort 9001 -web -webPort 9000 -baseDir ~/data
    • If it did not yet exist, it will create an empty database.
    • Connect to it using the browser (e.g. http://localhost:9000/) - use the following values (example):
    • 81035059.png

      warning.svg If a new database is created, the username and password entered above are used as database user and password for future connections.

    • Use the option "-webAllowOthers" to allow remote connections to the web console
    • Please refer to http://www.h2database.com/html/tutorial.html for more options and further information
  • After opening the web console, add the IAM database schema by executing SQL files from here:  (Schema and initial admin). Skip this step, if you opened an existing database, of course.
  • Alternative to using the H2 Web Console

    Instead of using the web console (H2 web application) you may use the following H2 command:

    # Print usage of H2 RunScript
    $ java -cp h2/bin/h2*.jar org.h2.tools.RunScript -h
    # Install schema SQL example
    java -cp h2/bin/h2*.jar org.h2.tools.RunScript \ 
     -url jdbc:h2:tcp://localhost:9001/iamdb \ 
     -user iam -password password \ 
     -script create-medusa-schema.sql \ 
    # Add initial admin
    java -cp h2/bin/h2*.jar org.h2.tools.RunScript \ 
     -url jdbc:h2:tcp://localhost:9001/iamdb \ 
     -user iam -password password \ 
     -script insert-admin.sql \ 
  • After this step, the database should be ready for usage. In the IAM database configuration, use the same settings (JDBC URL, username, password and driver) as when connecting with the web console above.
  • To install the H2 database as a Linux service (using systemd), the following examples for database "iamdb" may be used:
    • Create a systemd service file /home/h2database/iamdb.service with the following contents:
    • copy
      Description=H2 Database - iam
      ExecStart=/usr/bin/java -cp h2/bin/h2-1.4.196.jar org.h2.tools.Server -tcp -tcpPort 9001 -web -webPort 9000 -baseDir ~/data

      The above service definition assumes that you intend to use "/usr/bin/java" as Java runtime. If specifying a different Java runtime, make sure to provide an absolute path.

    • Install the service and start it (you must be "root" to do that):
    • copy
      # install the service (as root)
      systemctl enable /home/h2database/iamdb.service
      # start the service (as root)
      systemctl start iamdb
      # check the status with
      systemctl status iamdb
      # to get more stdout from it use
      journalctl -u iamdb
    • We recommend to reboot the system to make sure that the database is started after reboot.