DB Node Installation

Overall Installation Steps

The high-level steps for installing and configuring N2SNS DB nodes are:

  1. Ensure the installation pre-requisites are met.
  2. Install the DB package.
  3. Perform any required post-installation steps.
  4. Update the DB configuration as desired.

Installation Pre-requisites

OS-specific Setup

Refer to the specific Red Hat or Debian instructions for any pre-requisites as required.

PostgreSQL Server

The PostgreSQL database server must be installed and configured. Follow the installation procedure for this, noting any prerequisites.

At least version 10 of the PostgreSQL server is required for the N2SNS platform.

In order to perform the database initialisation steps, the PostgreSQL server must be running on the database instance and must be listening and able to be connected to from the command line, i.e. assuming that the PostgreSQL default user is used, this should succeed:

su - postgres
psql

DBMaintain

N2SNS DB nodes use the third-party tool DBMaintain to manage the database over time.

This tool can be obtained by:

If you are using an N-Squared packaged installation, DBMaintain will be installed in /usr/share/dbmaintain. For direct download, it may be placed in any convenient location. Commands for using DBMaintain are listed below, but may require updating the path appropriately for your environment.

Java

Usage of the DBMaintain tool requires a JDK or JRE of at least Java 5 to be available on the system. The default Java installation is acceptable in most cases.

To find the local java version, execute:

java -version

If Java is not installed or the version is not at least 5.x, install a new Java version as follows. The commands to execute will depend on your operating system type and version.

RHEL 8

On Red Hat Enterprise Linux 8 or similar platforms, execute:

sudo dnf install java-11-openjdk
sudo alternatives --install /usr/bin/java java /usr/java/latest/bin/java 1
sudo alternatives --config java

RHEL 7

On Red Hat Enterprise Linux 7 or similar platforms, execute:

sudo yum install java-11-openjdk
sudo alternatives --install /usr/bin/java java /usr/java/latest/bin/java 1
sudo alternatives --config java

Ubuntu

On Ubuntu or similar platforms, execute:

sudo apt install default-jdk

Perl

The N2SNS DB node requires several Perl packages to be available prior to installation. The package names may vary depending on your OS type:

RPM-based Systems DEB-based Systems
perl or perl-interpreter >= 1:5.12
postgresqlXX-plperl *
perl(IO)
perl(JSON)
perl(POSIX)
perl(strict)
perl(warnings)
perl >= 5.12
perl-base
perl-modules
libdbd-pg-perl
postgresql-plperl-XX *
libjson-perl

Note that packages marked with an asterisk must have the XX in their name changed to match your installed PostgreSQL version number.

For each of these packages (or with all as one command), execute the instructions specific to your operating system:

RHEL 8 Other RPM-based Systems DEB-based Systems
dnf install <package(s)> yum install <package(s)> apt-get install <package(s)>

Installation Steps

Follow the appropriate installation steps depending on your installation sources.

Note that the packages only need to be installed on nodes where a database schema needs to be created and maintained. This will generally only be the primary database instance.

From N-Squared Repository

Execute the instructions specific to your operating system:

RHEL 8 Other RPM-based Systems DEB-based Systems
dnf install n2sns-db yum install n2sns-db apt-get install n2sns-db

As Manual Installation

Transfer the provided package file to the target node, then follow the instructions specific to your operating system.

Execute (adjusting as appropriate for package location and version details) the following:

RPM-based Systems DEB-based Systems
sudo rpm -Uvh /path/to/n2sns-db-M.m.p-b.noarch.rpm sudo dpkg -i /path/to/n2sns-db_M.m.p-b_all.deb

Post-Installation Steps

Database Initialisation

N2SNS uses the database maintenance tool DBMaintain to upgrade and manage its database automatically.

N2SNS uses the following (unchangeable) database schemas and users:

These instructions assume that you will use the following values for N2SNS database storage:

These values may be modified as required for your installation by updating the installation steps below accordingly.

Database Preparation

The commands in this section must be executed as the OS user that is running the PostgreSQL server. By default, this is postgres.

  1. Create the required users for database administration, runtime data retrieval, and GUI access. You will be prompted to enter a password for each user.
createuser -P -l -s n2sns_owner
createuser -P -l n2sns_web
  1. If the database schemas do not already exist, create them.
psql n2in
CREATE SCHEMA IF NOT EXISTS audit AUTHORIZATION n2sns_owner;
GRANT ALL ON SCHEMA audit TO n2sns_owner;
CREATE SCHEMA IF NOT EXISTS n2sns AUTHORIZATION n2sns_owner;
\q
  1. Confirm database login as n2sns_owner works, and set the schema search path.
psql -h localhost -U n2sns_owner n2in
ALTER ROLE n2sns_owner SET search_path TO n2sns,public;
\q
  1. Confirm database login as n2sns_web works, and set the schema search path.
psql -h localhost -U n2sns_web n2in
ALTER ROLE n2sns_web SET search_path TO n2sns,public;
\q
  1. Grant specific permissions to the non-administrative users (each command must be executed separately).
psql -h localhost -d n2in -U n2sns_owner
GRANT USAGE ON SCHEMA n2sns TO n2sns_web;
\q

Database Creation

Before executing the commands to put the N2SNS database elements into the database, edit the file:

/usr/share/n2sns/db/servicedb/dbmaintain.properties

In the file, locate the following section:

database.url=jdbc:postgresql://REPLACE_WITH_DB_ADDRESS:REPLACE_WITH_DB_PORT/n2in
database.userName=n2sns_owner
database.password=REPLACE_WITH_DB_PASSWORD

Update these values to match the commands executed during database preparation.

To automatically install the database elements, execute the following commands:

cd /usr/share/n2sns/db
export DBMAINTAIN_JDBC_DRIVER=/usr/share/dbmaintain/postgresql-42.3.1.jar
/usr/share/dbmaintain/dbmaintain.sh updateDatabase -config servicedb/dbmaintain.properties
cd -

Firewall

The firewall (if any) on the DB node must be updated to allow:

The exact commands to do this will depend both on the firewall on your platform and also which port(s) are in use. For example, to allow the default PostgreSQL port when using firewalld, the commands might be:

firewall-cmd --zone=public --add-port=5432/tcp --permanent
service firewalld restart