Quantcast
Channel: Telestax Docs Online
Viewing all articles
Browse latest Browse all 94

Restcomm – Install and Configure Restcomm to use Mysql

$
0
0

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 wish to run Restcomm on a local server or on another cloud based system, the following tutorial will show you how to get started with Restcomm and Mysql.

Requirements

  • Install Mysql
  • Download the latest version of Restcomm Telscale as explained HERE

Step 1 – Adding the Mysql JDBC connector to JBoss Datasource

  • Edit $RESTCOMM_HOME/standalone/configuration/standalone-sip.xml file
  • Under the datasource tag add the following:
  • Make sure you are using the correct IP address and port default port 3306. In the example below the local IP is 192.168.1.3:3306
  • Use the correct username and password for the Mysql access
  • Set the Mysql enabled=”true” and make sure you set the default dummy datasource to “false”

<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>myPWD</password>
                    </security>
                    <statement>
                        <prepared-statement-cache-size>100</prepared-statement-cache-size>
                        <share-prepared-statements/>
                    </statement>
                </datasource>

  • In the datasource under the drivers tag, add the following:
  • save and exit the standalone-sip.xml file

                    <driver name="mariadb" module="org.mariadb.jdbc">
                        <xa-datasource-class>org.mariadb.jdbc.MySQLDataSource</xa-datasource-class>
                    </driver>

Step 2 – Configuring the mybatis.xml file to use Mysql

  • Edit the file $RESTCOMM_HOME/standalone/deployments/restcomm.war/WEB-INF/conf/mybatis.xml
  • Change the environments id to id=”mariadb”
  • Add the MariaDB configuration environment tag as shown below

<environment id="mysql">
                <transactionManager type="JDBC" />
                <dataSource type="JNDI">
                  <property name="data_source" value="java:/MysqlDS" />
                </dataSource>
        </environment>

  • Save and exist the mybatis.xml file

Step 3 – Download Mysql Java Client Driver

  • Download the latest mysql java connector client driver jar file from HERE.
  • Go to the directory $RESTCOMM_HOME/modules
  • Run the following command to create a new directory structure:  mkdir -p ./org/mysql/jdbc/main
  • Go to the newly created directory structure $RESTCOMM_HOME/modules/org/mysql/jdbc/main
  • Copy the downloaded mysql-connector-java-5.1.38-bin.jar to the $RESTCOMM_HOME/modules/org/mysql/jdbc/main
  • In the $RESTCOMM_HOME/modules/org/mysql/jdbc/main create a new xml file called module.xml
  • The content of the module.xml should be similar to the one below. Notice the path name of the java client must matches the one you download
  • You should now have 2 files in the $RESTCOMM_HOME/modules/org/mysql/jdbc/main directory.

<?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.38-bin.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
</module>

 

Step 4 – Start Mysql and Create the restcomm Database.

  •  Start mysql service if it is not already started  – sudo /etc/init.d/mysql start
  • Go to the directory $RESTCOMM_HOME/standalone/deployments/restcomm.war/WEB-INF/scripts/mariadb
  • (Note the scripts/mariadb contains the same files needed by mysql)
  • There will be an init.sql file and an sql directory
  • Create the restcomm database from the init.sql as follows:
  • mysql -u root -p < init.sql
  • log into mysql and make sure the restcomm database is created :  show databases;

Step 5 – Edit the restcomm.xml file to point the DAO to mysql

  • Edit the file $RESTCOMM_HOME/standalone/deployments/restcomm.war/WEB-INF/conf/restcomm.xml
  • Find the dao-manager tag and change the sql-files path to mariadb as shown below
  • (Note the scripts/mariadb  contains the same files needed by mysql)

<dao-manager class="org.mobicents.servlet.restcomm.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/scripts/mariadb/sql</sql-files>
	</dao-manager>

 

Start Restcomm as explained in the quick user guide HERE

 

The post Restcomm – Install and Configure Restcomm to use Mysql appeared first on Telestax Docs Online.


Viewing all articles
Browse latest Browse all 94

Trending Articles