When working with the binary version of Restcomm, the default database is hsqlDB. This is of course not suitable for production but it is provided as a way for you to conveniently and quickly start up Restcomm. For those who would like to run Restcomm on a local server or on another cloud based system, the following tutorial will show how to get started with Restcomm and Mysql.

Requirements

Step 1 - Download Mysql Java Connector and Configure Java Connector

  • Download mysql java connector as explained HERE

  • Create the following folder stucture mkdir -p $RESTCOMM_HOME/modules/org/mariadb/jdbc/main

  • Download the myqls jar file into the main directory, cp mysql-connector-java-5.1.40.jar $RESTCOMM_HOME/modules/org/mariadb/jdbc/main

  • create a the file module.xml vi $RESTCOMM_HOME/modules/org/mariadb/jdbc/main/module.xml make sure the content of the module.xml looks like the one below with the appropriate mysql connector jar file name.

<?xml version="1.0" encoding="UTF-8" ?>
<module xmlns="urn:jboss:module:1.1" name="org.mysql.jdbc">
        <resources>
        <resource-root path="mysql-connector-java-5.1.40.jar"/>
        </resources>
        <dependencies>
                <module name="javax.api"/>
                <module name="javax.transaction.api"/>
        </dependencies>
</module>

Step 2 : Configure the standalone-sip.xml to use the Mysql Connector

  • Edit the file $RESTCOMM_HOME/standalone/configuration/standalone-sip.xml

  • Edit the datasource and make sure it looks like the section below

  • Note that the IP 192.168.1:3306 is the IP where mysql is listening for traffic

           <datasources>
         <datasource jndi-name="java:/MysqlDS" pool-name="MysqlDS" enabled="true">
                    <connection-url>jdbc:mysql://192.168.1.3:3306/restcomm</connection-url>
                    <driver>mysqlDriver</driver>
                    <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
                    <pool>
                        <min-pool-size>100</min-pool-size>
                        <max-pool-size>200</max-pool-size>
                    </pool>
                    <security>
                        <user-name>root</user-name>
                        <password>YourMysqlDBPwd</password>
                    </security>
                    <statement>
                        <prepared-statement-cache-size>100</prepared-statement-cache-size>
                        <share-prepared-statements/>
                    </statement>
                </datasource>

            <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="false" use-java-context="true">
                    <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
                    <driver>h2</driver>
                    <security>
                        <user-name>sa</user-name>
                        <password>sa</password>
                    </security>
                </datasource>
                <drivers>
                <driver name="mysqlDriver" module="org.mysql.jdbc">
                        <driver-class>com.mysql.jdbc.Driver</driver-class>
                    </driver>
                    <driver name="h2" module="com.h2database.h2">
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    </driver>
                </drivers>
            </datasources>

Step 3 : Create restcomm database in mysql and grant DB privileges

  • Create restcomm database in mysql as follows

 mysql -u root -p < $RESTCOMM_HOME/standalone/deployments/restcomm.war/WEB-INF/scripts/mariadb/init.sql
  • The command above will create a restcomm database inside mysql

  • log into mysql to make sure the database is created.

mysql -u root -p

show databases;
use restcomm;
show tables;
  • Grant the appropriate DB privileges to the user, in the example, root

GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.%' IDENTIFIED BY 'YourMysqlDBPwd' WITH GRANT OPTION;

then save the changes as follows

GRANT ALL PRIVILEGES;

The above command will allow your use to be able to access the DB on 192.168.1.x subnet
The is important if you have multiple Restcomm instances in the same subnet and they will need to Replicate DB on a MASTER-MASTER format

WARNING: If you need to change an existing GRANT, you can use the ALTER command as follows

ALTER USER PRIVILEGES ON *.* TO 'root'@'192.168.1.%' IDENTIFIED BY 'YourMysqlDBPwd' WITH GRANT OPTION;
  • Restart mysql service

sudo service mysql restart

or like this

sudo /etc/init.d/mysql restart
If you are unable to access your mysql server on the IP on which Restcomm is installed, please make sure you checking the following.
Edit the file /etc/mysql/my.cnf and make sure bind to 127.0.0.1 is disabled or commented out like this
#bind-address  = 127.0.0.1

Run the following command to make sure mysql is not bound to the loopback (127.0.0.1) address (below it is listening to all IP)

netstat -lnp | grep mysql
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      7657/mysqld
unix  2      [ ACC ]     STREAM     LISTENING     77682    7657/mysqld         /var/run/mysqld/mysqld.sock

Step 4 : UPdate mybatis.xml file to use Mysql

  • Edit $RESTCOMM_HOME/standalone/deployments/restcomm.war/WEB-INF/conf/mybatis.xml

  • The environment tag should look like the example below:

<environments default="mysql">
    <environment id="mysql">
                <transactionManager type="JDBC" />
                <dataSource type="JNDI">
                  <property name="data_source" value="java:/MysqlDS" />
                </dataSource>
        </environment>
<!--    <environment id="production">
      <transactionManager type="JDBC"/>
      <dataSource type="POOLED">
        <property name="driver" value="org.hsqldb.jdbcDriver"/>
        <property name="url" value="jdbc:hsqldb:file://${data}/restcomm;ifexists=true;hsqldb.write_delay=false;shutdown=true"/>
        <property name="username" value="sa"/>
        <property name="password" value=""/>
      </dataSource>
    </environment>-->
  </environments>

Step 5 - Update the dao-manager in the dao-manager.xml file

  • It should disable the default hsql and use mariadb sql which is the same as the one for mariadb

<restcomm>
   <!-- <dao-manager class="org.restcomm.connect.dao.mybatis.MybatisDaoManager">
        <configuration-file>${restcomm:home}/WEB-INF/conf/mybatis.xml</configuration-file>
        <data-files>${restcomm:home}/WEB-INF/data/hsql</data-files>
        <sql-files>${restcomm:home}/WEB-INF/sql</sql-files>
    </dao-manager>-->
    <dao-manager class="org.restcomm.connect.dao.mybatis.MybatisDaoManager">
        <configuration-file>${restcomm:home}/WEB-INF/conf/mybatis.xml</configuration-file>
        <data-files></data-files>
        <sql-files>${restcomm:home}/WEB-INF/scripts/mariadb/sql</sql-files>
    </dao-manager>
</restcomm>

Start Restcomm

  • Go to the $RESTCOMM_HOME/bin/restcomm/ directory. command:

./start-restcomm.sh
  • Open your web browser and go to the url – http://IP:8080. Instead of "IP" you should put your IP.

  • Log in with the administrator@company.com username and the RestComm password. Then you should change the default password. If you have changed the default password before, you should insert your own password at once.

Here you can read the detailed information on Starting Restcomm-Connect.