Use the following procedures to (optionally) use PostgreSQL instead of Derby with the Rhino SLEE SDK.

Note

The Rhino SLEE SDK uses a Derby embedded database to store its internal state. There is generally nothing to configure with the Derby database. It is stored in $RHINO_HOME/work/rhino_sdk, and the default configuration variables should work. You only need to be aware of the embedded Derby database if you want to remove all state from the SDK (using the init-management-db.sh script).

The Rhino SLEE SDK can optionally be reconfigured to use PostgreSQL to store state. It can use either the Derby embedded database or PostgreSQL, but not both at the same time.

1

Install PostgreSQL

PostgreSQL is usually available from your Linux distribution repositories.

2

Create a user

Once PostgreSQL has been installed, the next step is to create or assign a database user for the Rhino SLEE. This user will need permissions to create databases, but does not need permissions to create users. Use the createuser script supplied with PostgreSQL, as follows:

[postgres]$ createuser
Enter name of user to add: rhino
Shall the new user be allowed to create databases? (y/n) y
Shall the new user be allowed to create more new users? (y/n) n
CREATE USER

3

Configure access control

The default PostgreSQL installation trusts connections from the local host. If the Rhino SLEE and PostgreSQL are installed on the same host, the access control for the default configuration is sufficient. Below is a sample access-control configuration, from the file $PGDATA/pg_hba.conf:

#TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
local all all trust
host all all 127.0.0.1 255.255.255.255 trust

When you need to install the Rhino SLEE and PostgreSQL on separate hosts, or need a stricter security policy, you’ll need to tailor the access control rules in $PGDATA/pg_hba.conf to allow connections from Rhino to the database manager. For example, to allow connections from a Rhino instance on another host, make the following changes:

#TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
local all all trust
host all all 127.0.0.1 255.255.255.255 trust
host rhino rhino 192.168.0.5 255.255.255.0 password

After making these changes, you’ll need to completely restart the PostgreSQL server. Telling the server to reload the configuration file does not cause it to enable TCP/IP networking as this is initialised when the database is initialised. To restart PostgreSQL, either use the command supplied by the package (for example, /etc/init.d/postgresql restart), or use the pg_ctl restart command provided with PostgreSQL.

5

Edit configuration variables

By default, the Rhino SLEE SDK uses its own Derby embedded database. To use PostgreSQL rather than Derby, make the following changes.

  1. Edit the following configuration variables in the file $RHINO_HOME/config/config_variables, to point to your PostgreSQL configuration:

    # Management database settings
    MANAGEMENT_DATABASE_NAME=rhino_sdk
    MANAGEMENT_DATABASE_HOST=localhost
    MANAGEMENT_DATABASE_PORT=5432
    MANAGEMENT_DATABASE_USER=username
    MANAGEMENT_DATABASE_PASSWORD=changeit
    Warning If you cannot find the file $RHINO_HOME/config/config_variables, this probably means that you haven’t run the start-rhino.sh script on Linux or the start-rhino.bat script on Windows yet. Please run it first to generate a $RHINO_HOME/config/config_variables file.
  2. Edit the file $RHINO_HOME/config/persistence.xml. Find the <persistence-resource> elements with the names management and profiles and change their <persistence-resource-ref> sub-elements to reference the persistence resource with the name postgres instead of derby.

Note If the $RHINO_HOME/config/persistence.xml is ever deleted, the Rhino SLEE SDK will reconstruct its content from the values contained in $RHINO_HOME/config/defaults.xml. If you wish the change to use PostgreSQL to be more permanent in this case, then edit the $RHINO_HOME/config/defaults.xml file in the same way.

6

Initialise the PostgreSQL database

To initialise the database, run:

./init-management-db.sh postgres
Warning From now on, you will always need to pass the word postgres to this script.

Now, executing start-rhino.sh should start the Rhino SLEE using the PostgreSQL database backend.

Previous page Next page