JBoss.orgCommunity Documentation
If you intend to bring your eXo Platform to production, the embedded hsql database will not be appropriate and you will need to configure your app server to use another one. You need to learn how to configure eXo Platform data sources and your app server. If you need to change the data sources name, read the Rename the data source section below.
The steps below will show you how to configure eXo Platform to use a MySQL database. You need to adapt them to your actual production environment.
Refer to the FAQs of database configuration section to find out our sample configuration files for MySQL and other DB systems.
Step 1. Prepare your database server.
You need to prepare two database schema, then do as follows:
1. Connect to your database server using the ssh command:
ssh root@db.example.org
2. Verify that MySQL is running:
sudo /etc/init.d/mysqld status
3. Connect to MySQL:
mysql -u root -p
In this step, you will be prompted for entering your password.
4. Create 2 databases: one for idm ($dbname-idm) and the other for jcr ($dbname-jcr). For example:
i. Create the first database.
create database _$dbname_;
ii. Configure the user who has the remote access right (not only from the host server):
grant all on _$dbname_.* to '_$username_'@'_$IP_' identified by '_$password_';
In which, $IP = AS host name, $IP = IP with wildcard (eg 192.168.1.% = all IPs on 192.168.1.x network) and $username = username that eXo Platform will connect with (i.e. 'dbnameuser').
5. Verify that both databases were created successfully.
show databases;
6. Quit the server with the exit command.
eXo Platform does not require tables to be created before it starts because these tables are created automatically on the first startup. If you want to run the DDL script to create the database objects, please contact eXo Support to obtain the script for your database.
Step 2. Configure eXo Platform.
After the database is ready, you need to configure eXo Platform to connect to it. The configuration steps may be different, depending on the application server. Here, instructions are for Tomcat and JBoss.
In Tomcat, the data sources configuration requires you to edit the server.xml file.
Please refer to Tomcat's JNDI Resources How To for more details on the JNDI resources binding in Tomcat.
Edit the server.xml file
1. Open the file following the $TOMCAT_HOME/conf/server.xml path.
2. Declare the binding of the data sources in the GlobalNaming context:
Change the driver from org.hsqldb.jdbcDriver to com.mysql.jdbc.Driver.
Change the username and password to the values set above.
Change the URL to access your DataBase from jdbc:hsqldb:file:../gatein/data/hsql/exo-jcr_portal into jdbc:mysql://_$host_:3306/_$dbname_.
The code now should look like:
<!-- eXo JCR Datasource for portal -->
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" logAbandoned="true" maxActive="20" maxIdle="10" maxWait="10000" minEvictableIdleTimeMillis="60000" name="exo-jcr_portal" password="_$password_" removeAbandoned="true" removeAbandonedTimeout="10" type="javax.sql.DataSource" url="jdbc:mysql://_$host_:3306/_$dbname-jcr_" username="_$username_"/>
<!-- eXo IDM Datasource for portal -->
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" logAbandoned="true" maxActive="20" maxIdle="10" maxWait="10000" minEvictableIdleTimeMillis="60000" name="exo-idm_portal" password="_$password_" removeAbandoned="true" removeAbandonedTimeout="10" type="javax.sql.DataSource" url="jdbc:mysql://_$host_:3306/_$dbname-idm_" username="_$username_"/>
3. Add the JDBC driver. In this step, you need to add the MySQL connector to Tomcat by adding mysql-connector-java-5.1.x.jar to $TOMCAT_HOME/lib/.
Configure the data source for eXo Platform under JBoss
Edit gatein-ds.xml
Add the JDBC driver
1. Edit the gatein-ds.xml file.
i. Open the file following the $JBOSS_HOME/server/default/deploy/gatein-ds.xml path.
ii. Declare the binding of the data sources in the GlobalNaming context:
Change the driver: org.hsqldb.jdbcDriver into com.mysql.jdbc.Driver.
Change the username and password to the values set earlier.
Change the URL to access your database: <connection-url>jdbc:hsqldb:$${/}exo${/}hypersonic${/}exo-xxxportal-localDB</connection-url> to <connection-url>jdbc:mysql://_$host_:3306/_$dbname_</connection-url>.
The configuration should now look like:
<datasources>
<no-tx-datasource>
<jndi-name>exo-idm_portal</jndi-name>
<connection-url>jdbc:mysql://_$host_:3306/_$dbname-idm_</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>_$username_</user-name>
<password>_$password_</password>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
<idle-timeout-minutes>0</idle-timeout-minutes>
<prepared-statement-cache-size>32</prepared-statement-cache-size>
</no-tx-datasource>
<!-- ... -->
<no-tx-datasource>
<jndi-name>exo-jcr_portal</jndi-name>
<connection-url>jdbc:mysql://_$host_:3306/_$dbname-jcr_</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>_$username_</user-name>
<password>_$password_</password>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
<idle-timeout-minutes>0</idle-timeout-minutes>
<prepared-statement-cache-size>32</prepared-statement-cache-size>
</no-tx-datasource>
</datasources>
2. Add the JDBC driver. In this step, you need to add the MySQL connector library in JBoss by adding mysql-connector-java-5.1.x.jar to $JBOSS_HOME/server/default/lib/.
You can get the latest MySQL connector here.
By default, eXo Platform defines two data sources:
exo-jcr_portal - for the Java Content Repository (JCR).
exo-idm_portal - for the organizational model.
You may want to rename the data source as follows:
i. Open and edit the configuration.properties path.
In this step, indicate to eXo name of the data sources.
# JNDI name of the datasource that will be used by eXo JCR gatein.jcr.datasource.name=java:/comp/env/exojcr ... # JNDI Name of the IDM datasource gatein.idm.datasource.name=java:/comp/env/exo-idm
eXo Platform automatically appends the portal container name ("_portal" by default) to these values before performing a JNDI lookup.
ii. Change the data source name in the application server.
In this step, you need to change the name under which the data sources are bound in the JNDI tree by the app server. This is a dependent application sever.