Skip to content

5 DBMS for OpenEMM

5.1 MariaDB

If you want to use OpenEMM with a MariaDB database, you have to install the database software before you install the MariaDB database driver module for Python. If MySQL is preinstalled on any of your servers, you have to remove it first before installing MariaDB:

systemctl stop mysql
dnf remove mysql*

Even officially published versions of MariaDB may contain serious bugs, including severe data corruption, performance problems or security issues (see public bugtracker at https://jira.mariadb.org). Therefore, we can not recommend to blindly install the latest version available because of the potential risk of data loss. For example, we used MariaDB 10.6.8 for the EMM public cloud quite some time and for us this version worked fine (while the following version 10.6.9 contained a crash level bug and does not work at all with OpenEMM).

Please note that MariaDB 10.6.8 will no longer work with RHEL 9 or AlmaLinux 9, because some required dependencies are no longer available in the repositories of these Linux versions. Also, MariaDB 10.6.8 does not work with Python 3.11, which is required by OpenEMM. For AlmaLinux 9 and Python 3.11, we use MariaDB 10.11.7 in our production environment and this version works fine for us.

We recommend to install the MariaDB RPM files from the official MariaDB repository. If you want to use the same version we use, download the version mentioned above.

For OpenEMM you need both the server and the client component of MariaDB. At first, enable the MariaDB repository so that the required dependencies are installed automatically:

wget https://r.mariadb.com/downloads/mariadb_repo_setup
bash mariadb_repo_setup --mariadb-server-version="mariadb-10.11"

Install the MariaDB-server package (including dependencies) first. For RHEL 9 use

dnf install https://archive.mariadb.org/mariadb-10.11.7/yum/almalinux9-amd64/rpms/MariaDB-server-10.11.7-1.el9.x86_64.rpm

and for RHEL 8

dnf install https://archive.mariadb.org/mariadb-10.11.7/yum/almalinux8-amd64/rpms/MariaDB-server-10.11.7-1.el8.x86_64.rpm

Afterwards, install the remaining package MariaDB-devel (needed for Python/PIP) with:

dnf install MariaDB-devel

To protect your MariaDB installation from automatic updates by dnf update, lock your version with

dnf install yum-plugin-versionlock
dnf versionlock add MariaDB-server

Edit the master configuration file my.cnf in directory /etc:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
log-error=/var/log/mariadb/mariadb.log
innodb_stats_persistent=0
!includedir /etc/my.cnf.d

To start MariaDB and to make sure it launches every time the server is rebooted:

systemctl enable mariadb
systemctl start mariadb

Finally, add the MariaDB database driver module for Python which allows Python to access the MariaDB API after you have installed Python 3.11 or later:

python3 -m pip install mariadb

Please note that with RHEL 8 you must first set Python version 3.11 as the default, since the system’s preinstalled Python version is not sufficient. Use the following command to configure the default version:

alternatives --config python3

Enter the number of the desired option (for example, 1) to select Python 3.11 as default version.

It is not necessary to create a separate database user for OpenEMM, because the OST (OpenEMM Support Tool) will take care of it (see section OST (OpenEMM Support Tool) below).

5.2 MariaDB Configuration

Set the MariaDB root password right after installation with

mysql -u root
ALTER USER 'root'@'localhost' IDENTIFIED by '<password>';

and save it in your local password store or on your server in a secret file like .mysqlpw in directory /root with read and write permission only for user root:

cd /root
vi .mysqlpw
chmod 600 .mysqlpw

To avoid problems operating OpenEMM with MariaDB, you must not use its default configuration, but you have to set or change the following properties in section [mysqld] of MariaDB's configuration file my.cnf (usually found in directory /etc):

sql-mode = "STRICT_ALL_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

MariaDBs offers several modes of operation. Please make sure these three modes (and only these three modes) are set:

If the strict mode is not selected, if OpenEMM tries to import a string into a database field which is too short to hold the complete string, MariaDB would simply cut off the string at the end to make it fit - without any warning! This would harm the integrity of your data.

Preventing auto-creation of new database users is a security setting.

The ban of substitutions makes sure that MariaDB uses OpenEMM's choice of database engine InnoDB in any case.

lower_case_table_names = 1

→ This enforces usage of lower case for table names on Linux systems (where the case of a letter makes a difference).

wait_timeout = 86400

→ This property is set to 28800 by default. This means that MariaDB automatically cuts the connection to OpenEMM after 8 hours of inactivity. This leads to an initial connection error when OpenEMM attempts to contact the MariaDB database next time. If your OpenEMM installation does not access its MariaDB database all the time, you should increase this value to at least one day (86400) or even to a whole week (604800).

innodb_lock_wait_timeout = 1800

→ This prevents MariaDB from canceling a database operation after a mere 50 seconds (the default value of MariaDB), which could lead to inconsistent data in the OpenEMM database.

character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

→ This avoids possible conflicts between OpenEMM code and MariaDB caused by different settings for character set and collations in the database.

max_allowed_packet = 10M

→ Please be aware that the default value of this parameter may only be 1 or 2 MByte. In this case, you can not load a single data packet (a file for example) bigger than 1 or 2 MByte into the database. This affects the upload of files with the OpenEMM upload feature or the upload of attachments for emails. Since the transfer of data to the database has some overhead, the value for max_allowed_packet should be a little bit higher than the value for attachment.maxSize in file emm.properties. (You can check the current value inMariaDB with “SELECT @@max_allowed_packet;”). This value also limits the maximum size of SQL statements. In OpenEMM this is important for those SQL statements that retrieve statistical data for display in the workflow manager and dashboard calendar. In (the very unlikely) case that the GUI does not show these numbers and you find a corresponding error message in Tomcat's log catalina.out, double the value for parameter max_allowed_packet until it works.

autocommit = 1

→ If you want to set property autocommit, then set it to active. However, this is not strictly necessary, because MariaDB enables autocommit by default.

Please do not forget to restart MariaDB after changing the configuration file. For more advice on how to configure the MariaDB database, check out section MariaDB Database Tuning.

5.3 DNS Requirements

When setting up the DNS entries for your OpenEMM server, please make sure that your server holds a valid A record and a PTR record which points back to the hostname of your server (see /etc/hosts) for reverse lookups. This is important because most external mailservers that receive emails from your OpenEMM installation will do a reverse DNS lookup in order to check if the FQDN of your server and the PTR record of your server's IP address match. If not, this is an indication of a spambot network and quite often your emails will be rejected.

If you plan to use an SPF entry for the domain which is used for the sending address of your mass mails, make sure to add your server to this SPF record.