Skip to content

Database configuration#

For LUNA PLATFORM to work correctly, you must configure the databases as follows:

VLMatch is a function for performing descriptor matching calculations. The VLMatch library is compiled for a specific version of the database. Do not use a library created for a different version of the database. For example, a library created for PostgreSQL version 16 cannot be used for PostgreSQL version 12.

The sections below provide commands for PostgreSQL. For Oracle, only the VLMatch library compilation commands are given (see "VLMatch library compilation for Oracle" in the "Additional information" section).

Configuring InfluxDB#

If InfluxDB is already deployed in your Kubernetes cluster, make sure the following information is set correctly:

  • Username and password

  • Bucket and organization name

  • Administrator Token

Important: The above data must be specified in the LUNA PLATFORM settings dump file in order for services to access InfluxDB. However, Configurator service settings cannot be specified in the dump file, so they must be specified in the Configurator service Helm chart as follows:

env:
  - name: VL_SETTINGS.LUNA_MONITORING.STORAGE_TYPE
    value: "influx"
  - name: VL_SETTINGS.LUNA_MONITORING.SEND_DATA_FOR_MONITORING
    value: "1"
  - name: VL_SETTINGS.LUNA_MONITORING.ORGANIZATION
    value: "luna"
  - name: VL_SETTINGS.LUNA_MONITORING.TOKEN
    value: "12345678"
  - name: VL_SETTINGS.LUNA_MONITORING.BUCKET
    value: "luna_monitoring"
  - name: VL_SETTINGS.LUNA_MONITORING.HOST
    value: "influxdb"
  - name: VL_SETTINGS.LUNA_MONITORING.PORT
    value: "8086"
  - name: VL_SETTINGS.LUNA_MONITORING.USE_SSL
    value: "0"
  - name: VL_SETTINGS.LUNA_MONITORING.FLUSHING_PERIOD
    value: "1"

InfluxDB settings can also be specified in environment variables in the Helm chart of each service.

VLMatch library compilation#

Note: The following instructions provide an example for PostgreSQL 16 DBMS on CentOS 8.

All files required to compile the user-defined extension (UDx) into VLMatch can be found in the following directory:

/var/lib/luna/luna_v.5.76.0/extras/VLMatch/postgres/

To compile the VLMatch UDx function, you need to:

  • Install the RPM repository:
dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
  • Install PostgreSQL:
dnf install postgresql16-server
  • Install development environment:
dnf install postgresql16-devel
  • Install the gcc package:
dnf install gcc-c++
  • Install CMAKE. Version 3.5 or higher is required.

  • Open the make.sh script in a text editor. It includes the paths to the currently used PostgreSQL version. Change the following values (if necessary):

SDK_HOME specifies the path to the PostgreSQL home directory. The default is /usr/pgsql-16/include/server.

LIB_ROOT specifies the path to the PostgreSQL library root directory. The default is /usr/pgsql-16/lib.

  • Open the make.sh script directory and run it:
cd /var/lib/luna/luna_v.5.76.0/extras/VLMatch/postgres/ 
chmod +x make.sh
./make.sh

Transfer the generated VLMatchSource.so file to the PostgreSQL DBMS.

Create user and databases#

This section provides sample commands for creating a user and databases using the PostgreSQL DBMS as an example.

Create a database user.

psql -U postgres -c 'create role luna;'

Assign a password to the user.

psql -U postgres -c "ALTER USER luna WITH PASSWORD 'luna';"

Create databases for all services:

psql -U postgres -c 'CREATE DATABASE luna_configurator;'
psql -U postgres -c 'CREATE DATABASE luna_accounts;'
psql -U postgres -c 'CREATE DATABASE luna_handlers;'
psql -U postgres -c 'CREATE DATABASE luna_backport3;'
psql -U postgres -c 'CREATE DATABASE luna_faces;'
psql -U postgres -c 'CREATE DATABASE luna_events;'
psql -U postgres -c 'CREATE DATABASE luna_tasks;'
psql -U postgres -c 'CREATE DATABASE luna_lambda;'
psql -U postgres -c 'CREATE DATABASE luna_video_manager;'

Assign privileges to the database user.

psql -U postgres -c 'GRANT ALL PRIVILEGES ON DATABASE luna_configurator TO luna;'
psql -U postgres -c 'GRANT ALL PRIVILEGES ON DATABASE luna_accounts TO luna;'
psql -U postgres -c 'GRANT ALL PRIVILEGES ON DATABASE luna_handlers TO luna;'
psql -U postgres -c 'GRANT ALL PRIVILEGES ON DATABASE luna_backport3 TO luna;'
psql -U postgres -c 'GRANT ALL PRIVILEGES ON DATABASE luna_faces TO luna;'
psql -U postgres -c 'GRANT ALL PRIVILEGES ON DATABASE luna_events TO luna;'
psql -U postgres -c 'GRANT ALL PRIVILEGES ON DATABASE luna_tasks TO luna;'
psql -U postgres -c 'GRANT ALL PRIVILEGES ON DATABASE luna_lambda TO luna;'
psql -U postgres -c 'GRANT ALL PRIVILEGES ON DATABASE luna_video_manager TO luna;'

Allow user authorization on databases:

psql -U postgres -c 'ALTER ROLE luna WITH LOGIN;'

Note: Note that the username and password are specified in LUNA PLATFORM settings to connect services to the database.

Add VLMatch functions to Faces and Events databases#

Define the VLMatch function in the Faces and Events databases:

psql -d luna_faces -c "CREATE FUNCTION VLMatch(bytea, bytea, int) RETURNS float8 AS 'VLMatchSource.so', 'VLMatch' LANGUAGE C PARALLEL SAFE;"
psql -d luna_events -c "CREATE FUNCTION VLMatch(bytea, bytea, int) RETURNS float8 AS 'VLMatchSource.so', 'VLMatch' LANGUAGE C PARALLEL SAFE;"

Install PostGIS for Events database#

The Events service requires a PostGIS extension to work with coordinates.

Since PostGIS is an extension for PostgreSQL, its version usually corresponds to the version of PostgreSQL with which it is compatible.

Install the extension yourself for the PostgreSQL version you are using, using official documentation.

PostgreSQL 16 requires PostGIS version 3.4.