H2 database is included and configured by default in the RM development/evaluation configuration. It is highly recommended NOT to use H2 on production deployments.
Below you will find guides on how you can setup MySQL, MariaDB, Oracle or PostgreSQL database for the RM.
MySQL DB Setup Guide
Prerequisites
The following properties need to be set or added to the my.cfn/my.ini file of the MySQL as in the example below:
[mysqld]max_allowed_packet=32Minnodb_log_file_size=640Mdefault-storage-engine=innodbSetup
To properly create a MySQL database for the RM please follow the steps below:
Prepare a MySQL database and user for RM: Log into the MySQL console as admin user (e.g. `mysql -u root -p`) and execute:
mysql> CREATE DATABASE mprm_data;mysql> CREATE USER'mprm_user'@'<IP_Address>'IDENTIFIED BY'mprm_secret';mysql> GRANT ALL PRIVILEGES ON mprm_data.* TO'mprm_user'@'<IP_Address>';mysql> FLUSH PRIVILEGES;where:
mprm_data - is the name of the RM database
mprm_user - is the name of the MySQL user that has full rights on the RM database
mprm_secret - is the password assigned to the RM's database user
Turn off the built-in H2 database support in RM: Comment the following lines inside the file bin/mserver/db.sys:
#url=jdbc\:h2\:h2db/mprm;DEFAULT_LOCK_TIMEOUT\=30000#user=sa#password=#driver=org.h2.DriverConfigure RM with the MySQL database settings: Append the following lines to the file bin/mserver/db.sys according to the values set in step 1 (Skip this step if you are going to use scm.xml cluster configuration!):
url=jdbc\:mysql\://<host>:<port>/mprm_data?autoReconnect=falseuser=mprm_userpassword=mprm_secretdriver=com.mysql.jdbc.DriverDownload and Install MySQL JDBC Driver: Download the latest MySQL Connector/J package.
Add the MySQL JDBC Driver to the RM Classpath: Edit the EXT_CLASSPATH= line inside the RM's startup script to point to the connector driver.
For example: EXT_CLASSPATH=/etc/mysql/mysql-connector-java.jar
In case of using MySQL database and UTF8 encoding, to setup TR-069 device management correctly, set the property mprm.tr069.db.varCharColumnMaxLen=2000 into the default.prs file.
MariaDB Setup Guide
Prerequisites
The following properties need to be set or added to the my.cfn/mariadb.cnf file of the MySQL as in the example below:
[mariadb]max_allowed_packet=32MSetup
To properly create a database for the RM please follow the steps below:
Prepare a MariaDB database and user for RM: Log into the MariaDB console as admin user (e.g. `mariadb -u root -p`) and execute:
MariaDB [(none)]> CREATE DATABASE mprm_data;MariaDB [(none)]> CREATE USER'mprm_user'@'<IP Address>'IDENTIFIED BY'mprm_secret';MariaDB [(none)]> GRANT ALL PRIVILEGES ON mprm_data.* TO'mprm_user'@'<IP Address>';MariaDB [(none)]> FLUSH PRIVILEGES;Note: To allow access to mprm_user from any IP address, use the'%'wildcard. For example: CREATE USER'mprm_user'@'%'...where:
mprm_data - is the name of the RM database
mprm_user - is the name of the DB user that has full rights on the RM database
mprm_secret - is the password assigned to the database user
Turn off the built-in H2 database support in RM: Comment out the relevant lines in the file bin/mserver/db.sys, following the same approach described for the other databases in this guide.
Configure RM with the MariaDB database settings: Append the following lines to the file bin/mserver/db.sys according to the values set in step 1 (Skip this step if you are going to use scm.xml cluster configuration!):
url=jdbc\:mariadb\://<host>:<port>/mprm_data?autoReconnect=falseuser=mprm_userpassword=mprm_secretdriver=org.mariadb.jdbc.DriverDownload and Install latest MariaDB JDBC Driver
Add the MariaDB JDBC Driver to the RM Classpath: Edit the EXT_CLASSPATH= line inside the RM's startup script to point to the connector driver.
For example: EXT_CLASSPATH=/etc/mariadb/mariadb-java-client.jar
Similar to MySQL database, if you are using UTF8 encoding, set the property mprm.tr069.db.varCharColumnMaxLen=2000 into the default.prs file in order to setup TR-069 device management correctly
Oracle DB Setup Guide
Setup
To properly create an Oracle database for the RM please follow the steps below:
Prepare an Oracle database and user for RM: Log into the Oracle console as system user and execute:
create user mprm_data identified by mprm_secret default tablespace users
grant connect, resource to mprm_datawhere:
mprm_data - is the name of the RM database and the name of the Oracle user that has full rights on the RM database.
mprm_secret - is the password assigned to the RM's database user.
Turn off the built-in H2 database support in RM: Comment the following lines inside the file bin/mserver/db.sys:
#url=jdbc\:h2\:h2db/mprm;DEFAULT_LOCK_TIMEOUT\=30000#user=sa#password=#driver=org.h2.DriverConfigure RM with the Oracle database settings: Append the following lines to the file bin/mserver/db.sys according to the values set in step 1 (Skip this step if you are going to use scm.xml cluster configuration!):
url= jdbc\:oracle\:thin\host\:port\:oracle_instalationuser=mprm_datapassword=mprm_secretdriver=oracle.jdbc.OracleDriverDownload Oracle Driver: Download the latest Oracle driver in folder.
Add the Oracle Driver to the RM Classpath: Edit the EXT_CLASSPATH= line inside the RM's startup script to point to the connector driver.
For example: EXT_CLASSPATH=/oracle_drivers/ojdbc6.jar
PostgreSQL
To accurately start the RM with the PostgreSQL database management system please take in consideration the steps below.
The PostgreSQL Server can be found here while the PostgreSQL JDBC Drivers are available here.
Managing users and databases is possible with the usage of the PostgreSQL Tools (pgAdmin). Simple SQL queries may be also used e.g. CREATE USER ttt WITH PASSWORD 'ttt'; CREATE DATABASE ttt OWNER ttt
The URL property in the db.sys file must be changed to: url=jdbc:postgresql://<ip>:<port>/<database_name>?prepareThreshold=0
The default port is 5432
The name of the database is <database_name> and should be created previously.
The property prepareThreshold=0 is used for better performance of batch queries e.g. jdbc:postgresql://127.0.0.1:5432/ttt?prepareThreshold=0
The driver class in the db.sys file should be changed to : org.postgresql.Driver
H2 Database Test Usage
The H2 database can be used for testing purposes but some matters must be considered first:
The H2 database creates its files in the following folder : general\bin\mserver\h2db. If this folder does not exist the H2 will create it. When it is needed to commence work with an empty database, the following script that deletes the files under this folder must be executed: general\bin\h2_resetdb.bat (Windows) or general/bin/h2_resetdb (Linux)
The Embedded mode is the default configuration.
Starting the H2 database in Server mode requires the execution of one of the following scripts depending on the OS:
For Windows:
cd mserverjava -mx256M -cp ../../h2/h2.jar org.h2.tools.Server -tcp -baseDir h2db -tcpAllowOtherscd ..For Linux:
#!/bin/shcd mserverjava -mx256M -cp ../../h2/h2.jar org.h2.tools.Server -tcp -baseDir h2db -tcpAllowOtherscd ..The url property in the db.sys file has to be changed to url=jdbc:h2:tcp://localhost/mprm
Connecting to the database in Server mode is possible with DbVisualizer, SQuirrel SQL Client or other programs that can view the database records created by the RM. The H2 driver is located in the general/h2/h2.jar file and the driver class is org.h2.Driver
System Properties
The following database-related system properties may come in handy in some problematic scenarios:
Property | Type | Default Value | Description |
|---|---|---|---|
mprm.db.reconnect.period | Int | 30 | Specifies the time period after which the system will attempt to reconnect to the DB, if the connection has dropped. |
mprm.jdbc.connections.ping.interval.minutes | Int | 0 | Specifies the time period in which the system sends a ping style query to the DB, in order to keep the connection active and avoid any timeout scenarios. |