Showing posts with label Fault Tolerance. Show all posts
Showing posts with label Fault Tolerance. Show all posts

Tuesday, April 26, 2011

TIBCO EMS Fault Tolerant Pair - Server Authorization=True

TIBCO EMS User's Guide Chapter 19 Fault Tolerance - Authorization and Fault-Tolerant Servers describes how to setup server authorization in a FT pair. This article tries to compliment the TIBCO official documentation with easy to understand examples and illustrations.

There are at least 3 possible configurations of authorization-enabled FT pairs.

1) Primary and secondary servers share a common users.conf file.
2) Primary and secondary servers each uses separate users.conf file.
3) Primary and secondary servers retrieve user/group from a common LDAP.

Before we look into each option, ensure the server names and server passwords are identical on both servers. Server password is stored in the tibemsd.conf file. Examine the section in tibemsd.conf.

########################################################################
# Server Identification Information.
#
# server:    unique server name
# password:  password used to login into other routed server
########################################################################

server                  = EMS-SERVER
password                =

You must setup the server password on both servers. You can do this on individual server, without needing to run them as pair.

First, start up the first instance (using tibemsd1.conf)

Connect to this instance using tibemsadmin in $EMS_HOME/bin

tibadmin@tibems01:~/tibco/ems/5.1/bin$ ./tibemsadmin

TIBCO Enterprise Message Service Administration Tool.
Copyright 2003-2010 by TIBCO Software Inc.
All rights reserved.

Version 5.1.5 V3 3/29/2010

Type 'help' for commands help, 'exit' to exit:
> 


Connect to tibems01 (login name = admin, password = blank)

> connect tibems01
Login name (admin): 
Password: 
Connected to: tcp://tibems01:7222
tcp://tibems01:7222> 

Set the server password using the following command.

tcp://tibems01:7222> set server password=serverpass
Server parameters have been changed
tcp://tibems01:7222> 

Before you proceed to carry out the same step to tibems02, lets inspect the tibemsd1.conf file. You should see that the mangled password is now there.

########################################################################
# Server Identification Information.
#
# server:    unique server name
# password:  password used to login into other routed server
########################################################################

server                  = EMS-SERVER
password                = $man$o9y3vdC5oxiNRQT6Sb4F+FqKLqM

Now set the server password in tibemsd2.conf, with the exact same password used in tibemsd1.conf.

tibadmin@tibems01:~/tibco/ems/5.1/bin$ ./tibemsadmin 

TIBCO Enterprise Message Service Administration Tool.
Copyright 2003-2010 by TIBCO Software Inc.
All rights reserved.

Version 5.1.5 V3 3/29/2010

Type 'help' for commands help, 'exit' to exit:
> connect tibems02
Login name (admin): 
Password: 
Connected to: tcp://tibems02:7222
tcp://tibems02:7222> set server password=serverpass
Server parameters have been changed
tcp://tibems02:7222> 

Inspect tibemsd2.conf file.

########################################################################
# Server Identification Information.
#
# server:    unique server name
# password:  password used to login into other routed server
########################################################################

server                  = EMS-SERVER
password                = $man$vwtgocxurfOKsIcAiMOwD84fCDc


Note that the mangled password does not need to be identical in both tibemsd1.conf and tibemsd2.conf.

The FT pair are still not operational until we create a user 'EMS-SERVER' in each server. This is where it gets confusing. Not only you set up the server password (stored in the tibemsd.conf files), you also need to create a user called 'EMS-SERVER' with the exactly same password (serverpass). This task is subject to which option we choose and is described in sections below.

Option1: Primary and secondary servers share a common users.conf file (in other words, both tibemsd1.conf and tibemsd2.conf point to a single users.conf file)

Servers using a common users.conf file

Start either one of the instances (I chose tibems01)

Start tibco admin tool and connect.

> connect tibems01
Login name (admin): 
Password: 
Connected to: tcp://tibems01:7222
tcp://tibems01:7222> create user EMS-SERVER password=serverpass
User 'EMS-SERVER' has been created
tcp://tibems01:7222> 

Now inspect the users.conf file.

admin::"Administrator"
EMS-SERVER:$2$og/IEiSh$gp3b15kK67UPbMR3t7NX4h2X:""

The user admin is created by default by the server, without a password.

The EMS-SERVER is the one that we have just created. Note the mangled password.

Option 2: Primary and secondary servers each uses separate users.conf files (say, tibemsd1.conf uses users1.conf and tibemsd2.conf uses users2.conf)

Servers have own users.conf file

Perform what were done in step 1 for both tibems01 and tibems02. You should see the mangled password for EMS-SERVER in both usersN.conf files.

3) Primary and secondary servers retrieve user/group from a common LDAP.

Not covered in this article. We will discuss this when I have my LDAP server deployed.

Happy authorizing...☺

Cheers,

Saturday, April 23, 2011

TIBCO EMS 5.1.5 ESTATUS = 230 com.tibco.tibems.tibemsd.internal.db.EMSDataStoreException

Alright, the FT setup in the previous article worked, but didn't quite right. After the first successful startup and worked as pair, it never did again the second time.

Kept giving out this error.

2011-04-19 13:47:22.004 Recovering state, please wait.
2011-04-19 13:48:23.313 com.tibco.tibems.tibemsd.internal.db.EMSDataStoreException: failed to open store: IO Error: Socket read timed out
2011-04-19 13:48:23.313         at com.tibco.tibems.tibemsd.internal.db.DataStore._checkValidConnParams(DataStore.java:280)
2011-04-19 13:48:23.313         at com.tibco.tibems.tibemsd.internal.db.DataStore.open(DataStore.java:302)
2011-04-19 13:48:23.313         at com.tibco.tibems.tibemsd.internal.db.CallableDataStore.open(CallableDataStore.java:121)
2011-04-19 13:48:23.313         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2011-04-19 13:48:23.314         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2011-04-19 13:48:23.314         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2011-04-19 13:48:23.314         at java.lang.reflect.Method.invoke(Method.java:597)
2011-04-19 13:48:23.314         at com.tibco.tibems.tibemsd.internal.Context.invokeMethodInLine(Context.java:308)
2011-04-19 13:48:23.316 SEVERE ERROR: Unable to open store [$sys.failsafe]: [ ESTATUS = 230, ERRSTR = com.tibco.tibems.tibemsd.internal.db.EMSDataStoreException: failed to open store: IO Error: Socket read timed out ]
2011-04-19 13:48:23.317 com.tibco.tibems.tibemsd.internal.db.EMSDataStoreException: failed to open store: IO Error: Socket read timed out
2011-04-19 13:48:23.317         at com.tibco.tibems.tibemsd.internal.db.DataStore._checkValidConnParams(DataStore.java:280)
2011-04-19 13:48:23.317         at com.tibco.tibems.tibemsd.internal.db.DataStore.open(DataStore.java:302)
2011-04-19 13:48:23.324         at com.tibco.tibems.tibemsd.internal.db.CallableDataStore.open(CallableDataStore.java:121)
2011-04-19 13:48:23.324         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2011-04-19 13:48:23.324         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2011-04-19 13:48:23.324         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2011-04-19 13:48:23.325         at java.lang.reflect.Method.invoke(Method.java:597)
2011-04-19 13:48:23.325         at com.tibco.tibems.tibemsd.internal.Context.invokeMethodInLine(Context.java:308)
2011-04-19 13:48:23.325 SEVERE ERROR: Unable to open store [$sys.meta]: [ ESTATUS = 230, ERRSTR = com.tibco.tibems.tibemsd.internal.db.EMSDataStoreException: failed to open store: IO Error: Socket read timed out ]
2011-04-19 13:48:23.327 ERROR: Initialization failed: storage for '$sys.meta' not found.
2011-04-19 13:48:23.327 FATAL: Exception in startup, exiting.

After an hour of investigation, it finally narrowed down to oracle jdbc driver problem.

In TIBCO EMS User's Guide, Chapter 10, the documentation did give some clue about RAC.

"The TIBCO Enterprise Message Service server must connect to the Oracle RAC 10g database using the Oracle JDBC OCI driver and TAF configuration."

Why not give it a try? So I went ahead to try to use OCI rather than the thin driver. And it works!

In summary, 3 things needs to be done.

1) Install the Oracle Instant Client 11.2. (instantclient-basic-linux32-11.2.0.2.0.zip)
2) Install libaio package
3) Update the store-db.conf

1) Install the Oracle Instant Client 11.2.
Download the zip file from Oracle website. Unzip all the contents into the $EMS_HOME/lib folder.

2) Install libaio package

root@tibems01:~# apt-get install libaio1

3) Update the stores-db.conf file.

[$sys.failsafe]
type=dbstore
dbstore_driver_url=jdbc:oracle:oci:emsfs/emsfs@oradb11g01:1521:orcl
dbstore_driver_username=emsfs
dbstore_driver_password=emsfs

[$sys.meta]
type=dbstore
dbstore_driver_url=jdbc:oracle:oci:emsmeta/emsmeta@oradb11g01:1521:orcl
dbstore_driver_username=emsmeta
dbstore_driver_password=emsmeta

[$sys.nonfailsafe]
  type=file
  file=/home/tibadmin/ems_ft_cfg/datastore/async-msgs.db
  mode=async
  file_crc=disabled

Start the server pair, with log_trace = DEFAULT, +DBSTORE

Primary (active) server (tibems01)

TIBCO Enterprise Message Service.
Copyright 2003-2010 by TIBCO Software Inc.
All rights reserved.

Version 5.1.5 V3 3/29/2010

2011-04-19 15:35:28.828 Process started from '/home/tibadmin/tibco/ems/5.1/bin/tibemsd'.
2011-04-19 15:35:28.829 Process Id: 11175
2011-04-19 15:35:28.829 Hostname: tibems01
2011-04-19 15:35:28.829 Hostname IP address: 172.16.10.10
2011-04-19 15:35:28.829 Detected IP interface: 127.0.0.1 (lo)
2011-04-19 15:35:28.829 Detected IP interface: 172.16.10.10 (eth0)
2011-04-19 15:35:28.829 Detected IP interface: 192.168.50.10 (eth1)
2011-04-19 15:35:28.829 Reading configuration from '/home/tibadmin/ems_ft_cfg/tibemsd-db1.conf'.
2011-04-19 15:35:28.835 Logging into file '/home/tibadmin/ems01.log'
2011-04-19 15:35:28.836 Trying JVM location: /opt/java/jre/lib/i386/server/libjvm.so
2011-04-19 15:35:28.851 Loaded jvm from /opt/java/jre/lib/i386/server/libjvm.so
2011-04-19 15:35:28.851 Added java virtal machine option -Xmx256m
2011-04-19 15:35:28.851 Added java virtal machine option -Djava.class.path=/home/tibadmin/tibco/ems/5.1/bin/tibemsd.jar
2011-04-19 15:35:28.851 Added java virtal machine option -Xrs
2011-04-19 15:35:28.851 Added java virtal machine option -Dems.com.tibco.tibems.tibemsd.internal.version=5.1.5
2011-04-19 15:35:29.024 Java virtual machine started.
2011-04-19 15:35:29.089 Java Version 1.6.0_24
2011-04-19 15:35:29.095 Java server tasks started.
2011-04-19 15:35:29.108 Server name: 'EMS-SERVER'.
2011-04-19 15:35:29.108 Storage Location: '.'.
2011-04-19 15:35:29.108 Routing is disabled.
2011-04-19 15:35:29.108 Authorization is disabled.
2011-04-19 15:35:30.999 Active server 'tcp://tibems02:7222' not found.
2011-04-19 15:35:30.999 Continuing as active server.
2011-04-19 15:35:30.000 Accepting connections on tcp://tibems01:7222.
2011-04-19 15:35:30.000 Recovering state, please wait.
2011-04-19 15:41:45.330 Store '$sys.failsafe' locked by 'EMS-SERVER'
2011-04-19 15:41:45.347 Store '$sys.meta' locked by 'EMS-SERVER'
2011-04-19 15:41:45.347 Store '$sys.meta': Recovering Zone records...
2011-04-19 15:41:45.398 Store '$sys.meta': Recovered <1> Zone records
2011-04-19 15:41:45.398 Store '$sys.meta': Recovering Connection records...
2011-04-19 15:41:45.414 Store '$sys.meta': Recovered <0> Connection records
2011-04-19 15:41:45.415 Recovering transaction records
2011-04-19 15:41:45.415 Store '$sys.meta': Recovering Transaction records...
2011-04-19 15:41:45.427 Store '$sys.meta': Recovered <0> Transaction records
2011-04-19 15:41:45.427 Store '$sys.failsafe': Recovering Transaction records...
2011-04-19 15:41:45.458 Store '$sys.failsafe': Recovered <0> Transaction records
2011-04-19 15:41:45.458 Recovered all transaction records
2011-04-19 15:41:45.458 Store '$sys.meta': Recovering Session records...
2011-04-19 15:41:45.470 Store '$sys.meta': Recovered <0> Session records
2011-04-19 15:41:45.470 Store '$sys.meta': Recovering Consumer records...
2011-04-19 15:41:45.485 Store '$sys.meta': Recovered <0> Consumer records
2011-04-19 15:41:45.486 Store '$sys.meta': Recovering Producer records...
2011-04-19 15:41:45.499 Store '$sys.meta': Recovered <0> Producer records
2011-04-19 15:41:45.499 Store '$sys.meta': Recovering Purge records...
2011-04-19 15:41:45.511 Store '$sys.meta': Recovered <0> Purge records
2011-04-19 15:42:40.661 Recovering valid msg records...
2011-04-19 15:42:40.661 Store '$sys.meta': Recovering Valid records...
2011-04-19 15:43:13.912 Store '$sys.meta': Recovered <0> Valid records
2011-04-19 15:43:13.912 Store '$sys.failsafe': Recovering Valid records...
2011-04-19 15:43:13.982 Store '$sys.failsafe': Recovered <1> Valid records
2011-04-19 15:43:13.982 Recovered all valid msg records
2011-04-19 15:43:13.983 Store '$sys.meta': Recovering Message records...
2011-04-19 15:43:13.985 Store '$sys.failsafe': Recovering Message records...
2011-04-19 15:43:14.252 Store '$sys.failsafe': Recovered <0> Message records
2011-04-19 15:43:14.260 Store '$sys.meta': Recovered <0> Message records
2011-04-19 15:43:14.280 Recovering Ack records
2011-04-19 15:43:14.280 Store '$sys.failsafe': Recovering Ack records...
2011-04-19 15:43:14.302 Store '$sys.failsafe': Recovered <0> Ack records
2011-04-19 15:43:14.302 Recovered all Ack records
2011-04-19 15:43:14.302 Server is active.

Secondary (standby) server (tibems02)

TIBCO Enterprise Message Service.
Copyright 2003-2010 by TIBCO Software Inc.
All rights reserved.

Version 5.1.5 V3 3/29/2010

2011-04-19 15:42:56.457 Process started from '/home/tibadmin/tibco/ems/5.1/bin/tibemsd'.
2011-04-19 15:42:56.457 Process Id: 2466
2011-04-19 15:42:56.457 Hostname: tibems02
2011-04-19 15:42:56.457 Hostname IP address: 172.16.10.11
2011-04-19 15:42:56.457 Detected IP interface: 127.0.0.1 (lo)
2011-04-19 15:42:56.458 Detected IP interface: 172.16.10.11 (eth0)
2011-04-19 15:42:56.458 Detected IP interface: 192.168.50.11 (eth1)
2011-04-19 15:42:56.458 Reading configuration from '/home/tibadmin/ems_ft_cfg/tibemsd-db2.conf'.
2011-04-19 15:42:56.462 Trying JVM location: /opt/java/jre/lib/i386/server/libjvm.so
2011-04-19 15:42:56.480 Loaded jvm from /opt/java/jre/lib/i386/server/libjvm.so
2011-04-19 15:42:56.480 Added java virtal machine option -Xmx256m
2011-04-19 15:42:56.480 Added java virtal machine option -Djava.class.path=/home/tibadmin/tibco/ems/5.1/bin/tibemsd.jar
2011-04-19 15:42:56.480 Added java virtal machine option -Xrs
2011-04-19 15:42:56.480 Added java virtal machine option -Dems.com.tibco.tibems.tibemsd.internal.version=5.1.5
2011-04-19 15:42:56.647 Java virtual machine started.
2011-04-19 15:42:56.702 Java Version 1.6.0_24
2011-04-19 15:42:56.708 Java server tasks started.
2011-04-19 15:42:56.710 Server name: 'EMS-SERVER'.
2011-04-19 15:42:56.710 Storage Location: '.'.
2011-04-19 15:42:56.710 Routing is disabled.
2011-04-19 15:42:56.711 Authorization is disabled.
2011-04-19 15:43:14.416 Accepting connections on tcp://tibems02:7222.
2011-04-19 15:43:14.416 Server is in standby mode for 'tcp://tibems01:7222'.

Cheers...getting ready for my Easter holiday trip.

Friday, April 22, 2011

TIBCO EMS FT pair on Oracle Database 11gR2 shared storage

Related article: Read this also

In the previous article I wrote about setting up a TIBCO EMS fault tolerant pair that uses NFSv4 shared folder to store shared states. This article describes the step to set up a database-based shared state datastore.

The end-state is depicted in the following deployment diagram.


This is a 2-in-1 article. One part is to set up the required conf files and set up the Oracle Database 11gR2 for as datastore. The other part is to configure 2 separate tibemsd for the FT pairs.

1) Install hibernate package on the host machine
2) Configure tibemsd-db.conf
3) Configure stores-db.conf
4) Create EMS schema using export tool
5) Test it!

1) Install hibernate package

I will use hibernate 3.2.5 from the package hibernate_3.2.5_linux24gl23_x86.zip

1.1 Unzip the package into you temp folder.
1.2 run TIBCOUniversalInstaller-lnx-x86.bin as tibadmin, created earlier in this article.
1.3 Follow the steps in the screens below.

2) Configure tibemsd-db.conf

tibemsd-db.conf is a sample file located in $EMS_HOME/tibco/ems/5.1/sample/config folder. Copy this file from $EMS_HOME/tibco/ems/5.1/sample/config into your shared state directory.

Edit the tibemsd-db.conf and modify the following lines.

users                   = /home/tibadmin/ems_ft_cfg/users.conf
groups                  = /home/tibadmin/ems_ft_cfg/groups.conf
topics                  = /home/tibadmin/ems_ft_cfg/topics.conf
queues                  = /home/tibadmin/ems_ft_cfg/queues.conf
acl_list                = /home/tibadmin/ems_ft_cfg/acl.conf
factories               = /home/tibadmin/ems_ft_cfg/factories.conf
routes                  = /home/tibadmin/ems_ft_cfg/routes.conf
bridges                 = /home/tibadmin/ems_ft_cfg/bridges.conf
transports              = /home/tibadmin/ems_ft_cfg/transports.conf
tibrvcm                 = /home/tibadmin/ems_ft_cfg/tibrvcm.conf
durables                = /home/tibadmin/ems_ft_cfg/durables.conf
channels                = /home/tibadmin/ems_ft_cfg/channels.conf
stores                  = /home/tibadmin/ems_ft_cfg/stores-db.conf

dbstore_classpath       = /home/tibadmin/tibco/components/eclipse/plugins/com.tibco.tpcl.org.hibernate_3.2.5.001/hibernate3.jar:/home/tibadmin/tibco/components/eclipse/plugins/com.tibco.tpcl.org.com.mchange.c3p0_0.9.1.001/c3p0-0.9.1.jar:/home/tibadmin/tibco/ems/5.1/bin/antlr-2.7.6.jar:/home/tibadmin/tibco/ems/5.1/bin/asm-attrs.jar:/home/tibadmin/tibco/ems/5.1/bin/asm.jar:/home/tibadmin/tibco/ems/5.1/bin/cglib-2.1.3.jar:/home/tibadmin/tibco/ems/5.1/bin/commons-collections-2.1.1.jar:/home/tibadmin/tibco/ems/5.1/bin/commons-logging-1.0.4.jar:/home/tibadmin/tibco/ems/5.1/bin/dom4j-1.6.1.jar:/home/tibadmin/tibco/ems/5.1/bin/ehcache-1.2.3.jar:/home/tibadmin/tibco/ems/5.1/bin/jta.jar:/home/tibadmin/tibco/ems/5.1/lib/ojdbc5.jar

dbstore_driver_name     = oracle.jdbc.driver.OracleDriver
dbstore_driver_dialect  = org.hibernate.dialect.Oracle10gDialect
jre_library             = /opt/java/jre/lib/i386/server/libjvm.so
jre_option   = -Xmx256m

3) Configure stores-db.conf

stores-db.conf is a sample stores.conf file located in $EMS_HOME/tibco/ems/5.1/sample/config folder. Copy this file from $EMS_HOME/tibco/ems/5.1/sample/config into your shared state directory.

[$sys.failsafe]
type=dbstore
dbstore_driver_url=jdbc:oracle:thin:emsfs/emsfs@//oradb11g01:1521/orcl
dbstore_driver_username=emsfs
dbstore_driver_password=emsfs

[$sys.meta]
type=dbstore
dbstore_driver_url=jdbc:oracle:thin:emsmeta/emsmeta@//oradb11g01:1521/orcl
dbstore_driver_username=emsmeta
dbstore_driver_password=emsmeta

#store the non failsafe message in NFS drive.
[$sys.nonfailsafe]
  type=file
  file=/home/tibadmin/ems_ft_cfg/datastore/async-msgs.db
  mode=async
  file_crc=disabled


4) Create EMS schema using export tool

TIBCO EMS comes with a tool to create the required database schema for shared states and message storage.

Before you use the tool, ensure the TIBCO EMS host has the required database connectivity. Though you only need the Oracle JDBC java library (ojdbc5.jar) to be in the classpath, I suggest that you install the entire package of Oracle Instant Client for Linux (instantclient-basic-linux32-11.2.0.2.0.zip).

Next, create an oracle db user for each EMS data store of type dbstore.

for meta dbstore
GRANT CONNECT,RESOURCE,UNLIMITED TABLESPACE TO emsmeta IDENTIFIED BY emsmeta;

ALTER USER emsmeta DEFAULT TABLESPACE USERS;

ALTER USER emsmeta TEMPORARY TABLESPACE TEMP;

for failsafe dbstore

GRANT CONNECT,RESOURCE,UNLIMITED TABLESPACE TO emsfs IDENTIFIED BY emsfs ;

ALTER USER emsfs DEFAULT TABLESPACE USERS;

ALTER USER emsfs TEMPORARY TABLESPACE TEMP;

Note: The userid and password must be same is the one specified in the store-db.conf file in step 3.

After you have created the EMS oracle user, execute the tibemsd_util.jar as follow. The util is located under $EMS_HOME/bin where EMS_HOME is /home/tibadmin/tibco/ems/5.1 in my case.

java -jar tibemsd_util.jar -tibemsdconf /home/tibadmin/ems_ft_cfg/tibemsd-db1.conf -createall -export

You should see the following output on the stdout.

drop table ACK_RECS cascade constraints
drop table CONNECTION_RECS cascade constraints
drop table CONSUMER_RECS cascade constraints
drop table CONSUMER_RECS_IMPSELMAP cascade constraints
drop table EMS_HBLOCK_TABLE cascade constraints
drop table EMS_MESSAGES cascade constraints
drop table EMS_SYS_RECORDS_TABLE cascade constraints
drop table PRODUCER_RECS cascade constraints
drop table PURGE_RECS cascade constraints
drop table SESSION_RECS cascade constraints
drop table TXN_RECS cascade constraints
drop table VALID_MSGS_RECORD cascade constraints
drop table VALID_MSGS_RECORD_HELDMSGS cascade constraints
drop table VALID_MSGS_RECORD_HOLDMSGS cascade constraints
drop table VALID_MSGS_RECORD_NOHOLDMSGS cascade constraints
drop table ZONE_RECS cascade constraints
drop sequence hibernate_sequence
create table ACK_RECS (ACK_RECORD_ID number(19,0) not null, CONSUMER_ID number(19,0), SEQNO number(19,0), DISCARD_ACK_FLAG number(1,0), TXN_ID number(19,0), SESS_ID number(19,0), CONN_ID number(19,0), primary key (ACK_RECORD_ID))
create table CONNECTION_RECS (STORE_ID number(19,0) not null, CONNECTION_ID number(19,0), CONNECTION_TYPE number(10,0), CLIENT_ID varchar2(256 char), CONNECTION_USER varchar2(256 char), NEW_TEMP_DESTS_FLAG number(1,0), primary key (STORE_ID))
create table CONSUMER_RECS (STORE_ID number(19,0) not null, CONSUMER_ID number(19,0), SESSION_ID number(19,0), CONNECTION_ID number(19,0), DURABLE_NAME varchar2(255 char), SUBSCRIPTION_NAME varchar2(255 char), CLIENT_ID varchar2(255 char), ZONE_ID number(10,0), SELECTOR_STRING varchar2(4000 char), SELECTOR_BYTES long raw, NO_LOCAL number(1,0), CONNECTION_CONSUMER number(1,0), DESTINATION varchar2(255 char), DEST_TYPE number(3,0), CONSUMER_MSG_SEQNO number(19,0), MULTICAST_FLAG number(1,0), primary key (STORE_ID))
create table CONSUMER_RECS_IMPSELMAP (StoreId number(19,0) not null, HASHMAP_VALUE varchar2(255 char), HASHMAP_KEY varchar2(255 char) not null, primary key (StoreId, HASHMAP_KEY))
create table EMS_HBLOCK_TABLE (id number(19,0) not null, last_update timestamp not null, server_id varchar2(255 char) not null, JDBCURL varchar2(4000 char) not null, primary key (id))
create table EMS_MESSAGES (STORE_ID number(19,0) not null, MESSAGE_SEQNO number(19,0), TYPE number(3,0), PRIORITY number(3,0), DELIVERYMODE number(3,0), REDELIVERED number(3,0), DESTINATION varchar2(255 char), DESTINATION_TYPE number(3,0), EXPIRATION number(19,0), TIMESTAMP number(19,0), REPLYTO varchar2(255 char), REPLYTO_TYPE number(3,0), USERTYPE varchar2(255 char), MSGID varchar2(255 char), CORRELATIONID varchar2(255 char), COMPRESSED number(1,0), CLIENTFLAGS number(19,0), ENCODING varchar2(255 char), ENCODED_PROPERTIES raw(1024), ENCODED_SUPPRESS_CONSIDS raw(1024), TXNID number(19,0), ZONEID number(19,0), ROUTESRC varchar2(255 char), ROUTESEQNO number(19,0), ROUTECONSID number(19,0), PRODUCERID number(19,0), DELETED number(1,0) not null, MESSAGE_SIZE number(19,0), SMALL_MESSAGE_BODY raw(1024), LARGE_MESSAGE_BODY blob, primary key (STORE_ID))
create table EMS_SYS_RECORDS_TABLE (SYSTEM_REC_ID number(19,0) not null, VERSION varchar2(255 char), EMS_START_TIME varchar2(255 char), EMS_UPDATE_TIME varchar2(255 char), primary key (SYSTEM_REC_ID))
create table PRODUCER_RECS (STORE_ID number(19,0) not null, PRODUCER_ID number(19,0), SESSION_ID number(19,0), CONNECTION_ID number(19,0), DESTINATION varchar2(255 char), DEST_TYPE number(3,0), primary key (STORE_ID))
create table PURGE_RECS (PURGE_RECORD_ID number(19,0) not null, DEST_NAME varchar2(255 char), DEST_TYPE number(3,0), SEQ_NO number(19,0), primary key (PURGE_RECORD_ID))
create table SESSION_RECS (STORE_ID number(19,0) not null, SESSION_ID number(19,0), CONNECTION_ID number(19,0), ACKNOWLEDGE_MODE number(10,0), TRANSACTED number(1,0), IS_XA number(1,0), MSGID_PREFIX varchar2(255 char), primary key (STORE_ID))
create table TXN_RECS (TXNREC_STORE_ID number(19,0) not null, SESS_ID number(19,0), TXN_ID number(19,0), RECORD_ID number(19,0), TXN_STATE number(10,0), XID raw(1024), primary key (TXNREC_STORE_ID))
create table VALID_MSGS_RECORD (VALID_MSG_RECORD_ID number(19,0) not null, ACTIVE_HI_SEQ number(19,0), SMALL_MESSAGE_BODY raw(1024), LARGE_MESSAGE_BODY blob, primary key (VALID_MSG_RECORD_ID))
create table VALID_MSGS_RECORD_HELDMSGS (id number(19,0) not null, HELD_MSGS number(19,0), listIndex number(10,0) not null, primary key (id, listIndex))
create table VALID_MSGS_RECORD_HOLDMSGS (id number(19,0) not null, HOLD_MSGS number(19,0), listIndex number(10,0) not null, primary key (id, listIndex))
create table VALID_MSGS_RECORD_NOHOLDMSGS (id number(19,0) not null, NO_HOLD_MSGS number(19,0), listIndex number(10,0) not null, primary key (id, listIndex))
create table ZONE_RECS (STORE_ID number(19,0) not null, ZONE_ID number(10,0), ZONE_NAME varchar2(255 char), ZONE_TYPE number(5,0), primary key (STORE_ID))
alter table CONSUMER_RECS_IMPSELMAP add constraint FKD1B84D7B3B9C4484 foreign key (StoreId) references CONSUMER_RECS
create index DEL_IDX on EMS_MESSAGES (DELETED)
alter table VALID_MSGS_RECORD_HELDMSGS add constraint FK5908794BC44ABBE5 foreign key (id) references VALID_MSGS_RECORD
alter table VALID_MSGS_RECORD_HOLDMSGS add constraint FK6A06C9D5C44ABBE5 foreign key (id) references VALID_MSGS_RECORD
alter table VALID_MSGS_RECORD_NOHOLDMSGS add constraint FK610EB196C44ABBE5 foreign key (id) references VALID_MSGS_RECORD
create sequence hibernate_sequence

Note: For some reasons the required tables are not created in database, probably due to missing/incorrect configuration of hibernate ddl properties.

Anyway, I have converted the output above into a sql script and simply run them with sqlplus.

[oradb11g01 $] sqlplus emsmeta/emsmeta @meta.sql
[oradb11g01 $] sqlplus emsfs/emsfs @fs.sql

This following paragraphs describe the step to setting up a FT pair.

Make 2 copies of the tibemsd-db.conf files made in step 1. Call them tibemsd-db1.conf and tibemsd-db2.conf respectively.

In both files, make sure the stores parameter points to the same conf file.

stores                  = /home/tibadmin/ems_ft_cfg/stores-db.conf

In each files, do the following:

tibemsd-db1.conf

listen = tcp://tibems01:7222
ft_active = tcp://tibems02:7222

tibemsd-db2.conf

listen = tcp://tibems02:7222
ft_active = tcp://tibems01:7222

The config file referencing can be visualised in the following picture.


Start EMS on both servers using tibemsd-db1.conf and tibemsd-db2.conf, in any sequence. The EMS FT pair on Oracle Database 11g R2 are now operational.

tibadmin@tibems02:~/ems_ft_cfg$ startEMS-db.sh 

TIBCO Enterprise Message Service.
Copyright 2003-2010 by TIBCO Software Inc.
All rights reserved.

Version 5.1.5 V3 3/29/2010

2011-04-19 06:02:33.785 Process started from '/home/tibadmin/tibco/ems/5.1/bin/tibemsd'.
2011-04-19 06:02:33.785 Process Id: 1629
2011-04-19 06:02:33.786 Hostname: tibems02
2011-04-19 06:02:33.786 Hostname IP address: 172.16.10.11
2011-04-19 06:02:33.786 Detected IP interface: 127.0.0.1 (lo)
2011-04-19 06:02:33.786 Detected IP interface: 172.16.10.11 (eth0)
2011-04-19 06:02:33.786 Detected IP interface: 192.168.50.11 (eth1)
2011-04-19 06:02:33.786 Reading configuration from '/home/tibadmin/ems_ft_cfg/tibemsd-db2.conf'.
2011-04-19 06:02:34.891 Java Version 1.6.0_24
2011-04-19 06:02:34.904 Server name: 'EMS-SERVER'.
2011-04-19 06:02:34.904 Storage Location: '.'.
2011-04-19 06:02:34.904 Routing is disabled.
2011-04-19 06:02:34.904 Authorization is disabled.
2011-04-19 06:02:37.451 Active server 'tcp://tibems01:7222' not found.
2011-04-19 06:02:37.451 Continuing as active server.
2011-04-19 06:02:37.456 Accepting connections on tcp://tibems02:7222.
2011-04-19 06:02:37.456 Recovering state, please wait.
2011-04-19 06:04:13.561 Store '$sys.failsafe' locked by 'EMS-SERVER'
2011-04-19 06:04:13.561 Creating system record for store '$sys.failsafe' ...
2011-04-19 06:04:13.660 Store '$sys.meta' locked by 'EMS-SERVER'
2011-04-19 06:04:13.660 Creating system record for store '$sys.meta' ...
2011-04-19 06:04:14.342 Server is active.
2011-04-19 06:06:00.481 Backup server 'EMS-SERVER@tibems01' has connected.

tibadmin@tibems01:~/ems_ft_cfg$ startEMS-db.sh 

TIBCO Enterprise Message Service.
Copyright 2003-2010 by TIBCO Software Inc.
All rights reserved.

Version 5.1.5 V3 3/29/2010

2011-04-19 06:05:58.102 Process started from '/home/tibadmin/tibco/ems/5.1/bin/tibemsd'.
2011-04-19 06:05:58.103 Process Id: 10071
2011-04-19 06:05:58.103 Hostname: tibems01
2011-04-19 06:05:58.103 Hostname IP address: 172.16.10.10
2011-04-19 06:05:58.103 Detected IP interface: 127.0.0.1 (lo)
2011-04-19 06:05:58.103 Detected IP interface: 172.16.10.10 (eth0)
2011-04-19 06:05:58.103 Detected IP interface: 192.168.50.10 (eth1)
2011-04-19 06:05:58.103 Reading configuration from '/home/tibadmin/ems_ft_cfg/tibemsd-db1.conf'.
2011-04-19 06:05:58.410 Java Version 1.6.0_24
2011-04-19 06:05:58.419 Server name: 'EMS-SERVER'.
2011-04-19 06:05:58.419 Storage Location: '.'.
2011-04-19 06:05:58.419 Routing is disabled.
2011-04-19 06:05:58.420 Authorization is disabled.
2011-04-19 06:06:00.401 Accepting connections on tcp://tibems01:7222.
2011-04-19 06:06:00.401 Server is in standby mode for 'tcp://tibems02:7222'.

Lastly, I have a Gigabit connection between the EMS host and the DB host, so I will just let the shared state traffic to pass through my MSG_VLAN. For detail of the Laboratory network topology, refer to this article.

Cheers,

Thursday, March 3, 2011

Basic TIBCO EMS file-based-storage, shared state Fault Tolerance Configuration

The official TIBCO EMS documentation has detailed the steps required to setup a functional Fault Tolerance server pair. I made a summary of the steps below for those who are in hurry.

WARNING: This is not a production configuration as it lacks of security enforcement such as ssl communication between servers. The the file system where the shared storage resides (which is NTFS) may not meet the criteria (Write Order, Synchronous Write Persistence, Distributed File Locking, Unique Write Ownership - refer to the official documentations) for Fault Tolerance. The shared storage folder in local drive is for quicky PoC only. The tibemsd.conf files may contain default parameter values that do not meet your operation scenarios.

New! - FT Pair on NFS
New! - FT Pair on Oracle

In scope:
- FT pair with shared state, file-based
- Inspect the propagation of a new topic into backup server when Fail-over takes place
- FT pair with sever authorization = enabled

Not in scope:
- SSL requirements
- Client configurations for FT connections
- Shared application binary folders for both participating servers
- Testing of client fail-over (it would probably not work because storage criteria are not met)

Tools:
Notepad++
DOS command line prompt

Bill of materials:
Installation of TIBCO EMS 5.1.x (1x)
tibemsd.conf (2x, 1 for primary sever, 1 for backup server)
Windows XP host (1x, we will use different listening ports for both severs so they can co-exist in the same host)

Schematic of Fault Tolerance EMS Server Pair Configuration, shared state (from the official doco).



Preparing the tibemsd.conf for the first server
1) Create a local folder in you local drive, name it "ems_ft_config"
2) Create a sub-folder under that folder, name it "datastore" (it becomes "ems_ft_config\datastore")
3) Copy tibemsd.conf from the sample folder of your TIBCO EMS installation. In my host, it is "C:\tibco\ems\5.1\samples\config"
4) Paste tibemsd.conf into "ems_ft_config", rename it to tibemsd1.conf
5) Edit tibemsd1.conf with your favorite text editor. Update the following parameters

users                   = x:\ems_ft_config\users.conf
 groups                  = x:\ems_ft_config\groups.conf
 topics                  = x:\ems_ft_config\topics.conf
 queues                  = x:\ems_ft_config\queues.conf
 acl_list                = x:\ems_ft_config\acl.conf
 factories               = x:\ems_ft_config\factories.conf
 routes                  = x:\ems_ft_config\routes.conf
 bridges                 = x:\ems_ft_config\bridges.conf
 transports              = x:\ems_ft_config\transports.conf
 tibrvcm                 = x:\ems_ft_config\tibrvcm.conf
 durables                = x:\ems_ft_config\durables.conf
 channels                = x:\ems_ft_config\channels.conf
 stores                  = x:\ems_ft_config\stores.conf
 
  
 store                   = x:\ems_ft_config\datastore

 
 ft_active               = tcp://your-ip-address:7224
 ft_heartbeat            = 3
 ft_activation           = 10
 ft_reconnect_timeout    = 60

6) Save the file.
7) Make another copy of tibemsd1.conf, name it tibesmd2.conf. Update the following parameters (note: replace 'x' with  your drive letter)

ft_active               = tcp://your-ip-address:7222

8) Save the file.
9) Open a command prompt, change directory to your EMS installation bin (in my case, it is C:\tibco\ems\5.1\bin).
10) Execute the following command

tibemsd -config x:\ems_ft_config\tibemsd1.conf

You should see the server startup traces in the stdout.



Let's examine the output.

(1) The server is started with tibemsd1.conf file
(2) It is trying to contact the server specified in the ft_active parameter, but could find the server (could be it was down, we haven't started it, or there was a connection problem to the target server.
(3) It decided to startup as active server (as opposed to 'backup server), and start listening on port 7222 as specified in the 'listen' parameter.
(4) Because it knows that itself is part of a FT pair, it performs the state recovery step.

Up to this stage, all is running as expected.

11) Open another command prompt, change directory to your EMS installation bin (in my case, it is C:\tibco\ems\5.1\bin).
12) Execute the following command

tibemsd -config x:\ems_ft_config\tibemsd2.conf

You should see the server startup traces in the stdout.


Let's examine the output.

(1) The server is started with tibemsd2.conf file
(2) It starts listening on port 7224 as specified in the 'listen' parameter of tibemsd2.conf file
(3) This time, it has started itself in standy mode because it has detected an active EMS server specified in the ft_active parameter.

On the primary server, the trace shows that the secondary server has been accepted as the standby server.


Using tibemsadmin, connect to each server and issue a command 'show server'. It provides the summary of the server, as you can see from the following images. The first server is the 'active' sever, and the second server is the 'standby server'.

Primary Server

Secondary Server

Examine one of the fail-over behaviour.

We will examine the behaviour of the backup server after it re-reads the configuration. First we add a new topic into the active server by using tibemsadmin tool.

1) Open another command prompt, change directory to your EMS installation bin (in my case, it is C:\tibco\ems\5.1\bin).
2) Execute the following command to connect to the primary sever (make sure that you have this server as the active sever)

tibemsadmin -server tcp://192.168.13.200:7222 -user admin

3) Press enter when asked for password, because we don't have one
4) Create a new topic called topiccreatedin7222 by issueing the following command at the admin prompt[tcp://192.168.13.200:7222> ]

tcp://192.168.13.200:7222> create topic topiccreatedin7222



5) Shut down the active server by issuing a 'shutdown' command at the admin prompt and answer 'yes' to the confirmation question.

tcp://192.168.13.200:7222> shutdown

You will see that the active server is shutdown, and the standy server resume it's operation as the primary server.



6) Connect to the now active primary server

tibemsadmin -server tcp://192.168.13.200:7224 -user admin

7) Issue the command 'show topics' at the admin prompt

tcp://192.168.13.200:7224> show topics

You now see that the topic created in the previously active server is now served in this new instance of active server.



Enabling server authorization for TIBCO EMS Fault Tolerance pair -> Available here.