...
top
6.7. Configuring Failover Deployments
This chapter will demonstrate how to configure failover deployments.
Simple
...
lock file
The simple lock file mechanism is intended for failover configurations where instances reside on the same host machine.
To use this feature, edit the $KARAF_HOME/etc/system.properties
file as follows on each system in the master/slave setup:
...
Note: Ensure that the karaf.lock.dir
property points to the same directory for both the master and slave instance, so that the slave can only acquire the lock when the master releases it.
JDBC locking
The JDBC locking mechanism is intended for failover configurations where instances exist on separate machines. In this deployment, the master instance holds a lock on a Karaf locking table hosted on a database. If the master loses the lock, a waiting slave process gains access to the locking table and fully starts its container.
To use this feature, do the following must be set on each system in the master/slave setup:
- Update the classpath to include the JDBC driver
- Update the
$KARAF_HOME/bin/karaf
script to have unique JMX remote port set if instances reside on the same host - Update the
$KARAF
$SERVICEMIX_HOME/etc/system.properties
file updated to reflect the below entries.
No Format |
---|
servicemix.lock=true
servicemix.lock.delay=10
|
Simple Lock File with container level locking.
- as follows:
...
Note:
- Will fail if JDBC driver is not on classpath.
- The database name "sample" will be created if it does not exist on the database.
- The first Karaf instance to acquire the locking table is the master instance.
- If the connection to the database is lost, the master instance tries to gracefully shutdown, allowing a slave instance to become master when the database service is restored. The former master will require manual restart.
JDBC locking on Oracle
If you are using Oracle as your database in a JDBC locking scenario, the karaf.lock.class
property in the $KARAF_HOME/etc/system.properties
file must point to org.apache.felix.karaf.main.OracleJDBCLock
.
Otherwise, configure the system.properties file as normal for your setup, for example:
...
As with the default JDBC locking setup, the Oracle JDBC driver JAR file must be in your classpath. You can ensure this by copying the ojdbc14.jar
into Karaf's lib
folder before starting Karaf.
Note: The karaf.lock.jdbc.url
requires an active SID, which means you must manually create a database instance before using this particular lock.
locklevel
Container-level locking
Container-level locking allows bundles to be preloaded The Container Level locking mechanism allows bundles to be loaded into the slave kernel instance in order to provide faster failover performance. Container-level locking is supported in both the simple file and JDBC locking mechanisms.
To implement container-level locking, add the following to the $KARAF_HOME/etc/system.properties
file on each system in the master/slave setup:
...
The karaf.log.level
property tells the Karaf instance how far up the boot process to bring the OSGi container. Bundles assigned the same start level or lower will then also be started in that Karaf instance.
Bundle The Container Level refers to the starting priority assigned to each bundle in the OSGI container. These start levels are specified in $SERVICEMIX $KARAF_HOME/etc/startup.properties
, in the format jar.name=level
. The core system bundles have levels below 50, where as user bundles have levels greater than 50.
Level | Behavior |
---|---|
1 | A 'cold' standby instance. Core bundles are not loaded into container. Slaves will wait until lock acquired to start server. |
<50 | A 'hot' standby instance. Core bundles are loaded into the container. Slaves will wait until lock acquired to start user level bundles. The console will be accessible for each slave instance at this level. |
>50 | This setting is Not not recommended as user bundles will be started. |
To use this feature the following must be set on each system in the master/slave setup:
- $SERVICEMIX_HOME/etc/system.properties file updated to reflect the below entries.
No Format |
---|
servicemix.lock=true
servicemix.lock.level=50
servicemix.lock.delay=10
|
Please note that when Note: When using a 'hot' spare on the same host you need to set the jmx JMX remote port will need to be configured to a unique port value to avoid bind conflicts. The servicemix You can edit the Karaf start script can be edited to include the following:
...
JDBC Locking
To use this feature the following must be set on each system in the master/slave setup:
- Classpath updated to include JDBC driver.
- $SERVICEMIX_HOME/etc/system.properties file updated to reflect the below entries.
No Format |
---|
servicemix.lock=true
servicemix.lock.class=org.apache.servicemix.kernel.main.DefaultJDBCLock
servicemix.lock.jdbc.url=jdbc:derby://dbserver:1527/sample
servicemix.lock.jdbc.driver=org.apache.derby.jdbc.ClientDriver
servicemix.lock.jdbc.user=user
servicemix.lock.jdbc.password=password
servicemix.lock.jdbc.table=SERVICEMIX_LOCK
servicemix.lock.jdbc.clustername=smx4
servicemix.lock.jdbc.timeout=30
|
Note:
- Will fail if jdbc driver is not on classpath.
- The database name "sample" will be created if it does not exist on the db.
- First SMX4 instance to acquire the locking table is the master instance.
- If connection to the DB is lost then the master instance will attempt to gracefully shutdown, allowing a slave instance to become master when the DB service is restored. The former master will require manual restart.
...