Link Search Menu Expand Document

Setup of Lab Instance

In some cases, there might be a need to set-up a stand-alone lab instance of the repositories for data/metadata storage. Such a need could arise when there are huge volumes of data which cannot be smoothly transferred over internet to the online instance of the NFDI-MatWerk Data and Metadata Repositories hosted by KIT / SCC. Also some research data might require increased security and privacy, in which case a lab instance might be the best way forward. Also a lab instance would allow for more customization. In this example, the repositories are installed on a server located on a bwCloud instance. Some basic generic setups, like creating a user and setting up a database (PostgreSQL) for the services are needed to start with the installation of a lab instance.

After the basic set up, local instances of the NFDI-MatWerk Data Repository and NFDI-MatWerk Metadata Repository can be installed.

The section advanced setup contains tips to have “clean” URLs and to make use of the frontend-collection as a web GUI (Graphical User Interface) for the repositories.

Create Unprivileged User

If the repositories are to be installed on a local machine, the following steps are not relevant, as you can use one of the pre-existing users. But always make sure that this user is used whenever the user matwerk is mentioned in this tutorial. In such a case, you can proceed to the next section to install postgreSQL to setup the databases.

If you are setting up the instances on a remote server, you need to first login to your server and create an uprilviliged user there. First update all packages and create a unprivileged user matwerk on this server. The following example demonstrates the commands and output on a linux based server called matwerklab.

root@matwerklab:~# apt-get update
root@matwerklab:~# apt-get upgrade
root@matwerklab:~# apt-get install vim curl git
root@matwerklab:~# adduser --disabled-password matwerk
Adding user `matwerk' ...
Adding new group `matwerk' (1001) ...
Adding new user `matwerk' (1001) with group `matwerk' ...
Creating home directory `/home/matwerk' ...
Copying files from `/etc/skel' ...
Changing the user information for matwerk
Enter the new value, or press ENTER for the default
   Full Name []:
   Room Number []:
   Work Phone []:
   Home Phone []:
   Other []:
Is the information correct? [Y/n] Y

PostgreSQL

The NFDI-MatWerk Data and Metadata repositories need a database each. We use PostgreSQL for setting up the databases. Therefore, PostgreSQL needs to be installed and configured with a separate user and databases.

Installation of PostgreSQL

Follow the instructions on the PostgreSQL website to install PostgreSQL based on your operating system.

On a linux based server, the command for installation would look like this:

root@matwerklab:~# apt install postgresql postgresql-client`

Check Status of PostgreSQL Service

Next check the status of the PostgreSQL service.

For Mac OS, use the command brew services list, to check if postgreSQL is listed there as a service, indicating that it is running (provided that PostgreSQL was installed using Homebrew). If it’s not running, the status column for PostgreSQL will show stopped instead of started.

For Windows, check the status by running the Services Manager “services.msc”. More details available here

For Linux, type systemctl status postgresql.service in the command prompt and press enter. The output will look similar to the block below.

root@matwerklab:~# systemctl status postgresql.service
● postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
   Active: active (exited) since Wed 2022-12-07 14:09:28 UTC; 1min 42s ago
   Main PID: 12839 (code=exited, status=0/SUCCESS)
      Tasks: 0 (limit: 4698)
   Memory: 0B
      CPU: 0
   CGroup: /system.slice/postgresql.service

Dec 07 14:09:28 matwerklab systemd[1]: Starting PostgreSQL RDBMS...
Dec 07 14:09:28 matwerklab systemd[1]: Finished PostgreSQL RDBMS.

Start PostgreSQL

On Mac, to start PostgreSQL using Homebrew, use the following command brew services start postgresql.

On Windows, follow the instructions on this website based on your OS version.

On Linux, type su -c /usr/bin/psql postgres and press enter. The output will look similar to the block below. And you will be logged into Postgres.

psql (13.8 (Debian 13.8-0+deb11u1))
Type "help" for help.

Create Databases for the Data and Metadata Repositories

Login into the PostgreSQL service based on your operating system. Instructions for logging into PostgreSQL service on Windows is available here.

For Mac, type psql postgres to login into the PostgreSQL service. More information for Mac is available here.

For Linux, type sudo -u postgres psql to login into PostgreSQL for the first time. More information for Linux is available here.

Enter the following commands in the PostgreSQL service, to create two databases named “baserepo” and “metastore” for the NFDI-MatWerk Data and Metadata Repsoitories, respectively.

postgres=# CREATE DATABASE baserepo;
CREATE DATABASE
postgres=# CREATE DATABASE metastore;
CREATE DATABASE

Create a user for postgres called matwerk_db_user

Next, create a user matwerk_db_user in the PostgreSQL service which will have access to both databases: baserepo (for the Data Repository) and metastore (for the Metadata Repository) with a password. For this, type the commands as shown in the code snippet below. Press enter after each command to execute it. Here the password ‘DB_USER_ADMIN_PASSWORD’ is selected arbitrarily. You may choose a different password, but remember to use the same password whenever ‘DB_USER_ADMIN_PASSWORD’ is mentioned in this documentation. The \q at end is used to log out of the PostgreSQL service.

postgres=# CREATE USER matwerk_db_user WITH ENCRYPTED PASSWORD 'DB_USER_ADMIN_PASSWORD';
CREATE ROLE
postgres=# GRANT ALL PRIVILEGES ON DATABASE baserepo TO matwerk_db_user;
GRANT
postgres=# GRANT ALL PRIVILEGES ON DATABASE metastore TO matwerk_db_user;
GRANT
postgres=# \q

Make sure the matwerk_db_user can connect to the database. You might need to modify your database’s configuration for this. The configuration file is at the location /etc/postgresql/13/main/pg_hba.conf. Note that in this example PostgreSQL version 13 is used. based on the version you install, and the actual location where you install Postgres, the path needs to be updated.

root@matwerk:~# vim  /etc/postgresql/13/main/pg_hba.conf
# "local" is for Unix domain socket connections only
local   all             all                                     md5
local   all             all                                     peer

Now we have a user named matwerk and have prepared Postgres databases for our repositories.

The repositories can now be installed, i.e. NFDI-MatWerk Data Repository and NFDI-MatWerk Metadata Repository


Table of contents