Chapter 47. HowTo Set Up a C-JDBC Database

NoteNote
 

This documentation describes the configuration of a clustered database in a RAID1. For further information, refer to the ObjectWeb C-JDBC documentation http://c-jdbc.objectweb.org/doc/index.html.

This configuration starts three HSQL instances, which are formed by C-JDBC as a RAID1. A RAID1 stores the same data in two different databases and uses a third database as a recovery log.

  1. Download the C-JDBC binaries from the C-JDBC site (http://c-jdbc.objectweb.org).

  2. Extract the C-JDBC archive into a folder:

    tar xvfz c-jdbc-xx-bin.tar.gz
  3. Set the environment variables:

    export JAVA_HOME=<Path_to_JDK_HOME>
    export CJDBC_HOME=<Path_to_CJDBC_HOME>
  4. Modify the $CJDBC_HOME/demo/demo-raidb1.sh file.

    The ports for the HSQLDB instances have to be modified in order to match the sampleCluster2. Change the ports for the three databases to 11001, 11002, 11003.

  5. Configure the C-JDBC controller file:

    1. Modify the ports in $CJDBC_HOME/config/virtualdatabase/hsqldb-raidb1.xml according to values defined in the section above. To avoid problems in the Datasource configuration of JOnAS, you must also set a password with which the users can log in.

    2. Back up the original configuration:

      mv $CJDBC_HOME/config/controller/controller.xml \
          $CJDBC_HOME/config/controller/controller.xml.original
    3. Create a link for the new configuration:

      ln -s $CJDBC_HOME/config/controller/controller-raidb1.xml \
          $CJDBC_HOME/config/controller/controller.xml
    4. Modify the file $CJDBC_HOME/config/controller/controller.xml to specify the configuration file of the virtual database, which is $CJDBC_HOME/config/virtualdatabase/hsqldb-raidb1.xml

    5. Start the HSQL instances:

      $CJDBC_HOME/demo/demo-raidb1.sh
    6. Start the C-JDBC controller:

      $CJDBC_HOME/bin/controller.sh
    7. Connect to the C-JDBC controller using the JDBC driver in $CJDBC_HOME/drivers and the URL jdbc:cjdbc://localhost:25322/myDB with:

      • username: <user>

      • password: <pass>

      NoteNote
       

      No password is specified by default, but you should specify one in the $CJDBC_HOME/config/virtualdatabase/hsqldb-raidb1.xml file.

47.1. Sample Configuration of a C-JDBC Database in JOnAS

###################### C-JDBC DataSource configuration example ######
DataSource configuration
#
datasource.name jdbc_1
datasource.url jdbc:cjdbc://localhost:25322/myDB
datasource.classname org.objectweb.cjdbc.driver.Driver
datasource.username user
datasource.password pass
datasource.mapper rdb.hsql
# Note: You must specify the mapper of the databases used as backend
# by C-JDBC. 
# A heterogeneous C-JDBC configuration cannot be used here!