## How To Setup A Sequoia Database Cluster

Sequoia is a transparent middleware solution for offering clustering, load balancing and failover services for any database. The purpose of this howto is to explain how to setup a Sequoia database cluster with JOnAS, and more precisely a RAIDB1 cluster composed of three HSQLDB databases and one Sequoia controller. This configuration allows to replicate the data in two different databases. The third database is used as recovery log. For further informaton about Sequoia and its configuration, please refer to the Sequoia documentation.

1. Download the Sequoia binaries from the Sequoia site.

2. Extract the Sequoia archive in a folder. For instance:
   `tar xvfz sequoia-x.y-bin.tar.gz`

3. Set the environment variables.
   `export JAVA_HOME=<Path to JDK home>`
   `export SEQUOIA_HOME=<Path to the Sequoia home>`

4. Modify the `$SEQUOIA_HOME/demo/demo-raidb1.sh` file.
   The ports for the HSQLDB instances must be modified to match the `sampleCluster2` configuration. Change the ports for the three databases to `11001, 11002, 11003`.

5. Modify the Sequoia virtual database file: `$SEQUOIA_HOME/config/virtualdatabase/hsqldb-raidb1.xml`
   Change the ports according to the values defined in the section above. To avoid problems in the Datasource configuration of JOnAS, modify also the password for the user to log in (`VirtualLogin` element). Warning if you choose another username than default value (`user`), modify also the `vLogin` attribute of `ConnectionManager` elements.

6. Start the cluster (HSQLDB instances and then Sequoia controller).
   `$SEQUOIA_HOME/demo/demo-raidb1.sh`

7. Connect to the Sequoia controller using the `$SEQUOIA_HOME/drivers/sequoia-driver.jar` JDBC driver and the URL:
   `jdbc:sequoia://localhost:25322/myDB` with `username: <user>` and `password: <pass>`
   Use the password you set in `$CJDBC_HOME/config/virtualdatabase/hsqldb-raidb1.xml` file.

   Sample Sequoia DataSource configuration file to use in JOnAS:

       ###################### Sequoia DataSource configuration example
       #
       #####
       DataSource configuration
       #
       datasource.name jdbc_1
       datasource.url jdbc:sequoia://localhost:25322/myDB
       datasource.classname org.continuent.sequoia.driver.Driver
       datasource.username user
       datasource.password pass
       # WARNING: you must specify the mapper of the databases used as
       # backend by Sequoia. It is not possible to use a heterogenious
       # Sequoia configuration here.
       datasource.mapper rdb.hsql