In cases where a simple IBM Informix Primary / HDR Secondary server pair exists, it may be considered unnecessary to implement Informix Connection Manager to manage switching between the two, as OLTP applications can simply connect to whichever is the active Primary in a group defined in the sqlhosts file. This article describes a unique method for connecting appropriate applications to the active HDR Secondary in this scenario.
An identical set of sqlhosts file entries on both Primary and HDR Secondary servers can define a fail-over group in this format:
(Note that the asterisk causes the specific Informix server to listen on all available TCP interfaces including “localhost”.)
Prior to starting a read-only application, the relevant INFORMIXSERVER environment variable can be set with
where ifx_server.sh (detailed below) is an executable shell script (bash or ksh) available in the current PATH, with my_server and secondary being arguments to this script.
Applications that should connect to the Primary would continue to use the group name as usual with:
If the script is called with primary as the second argument, the Primary server name (DBSERVERNAME or DBSERVERALIAS) is returned for information.
A listing of shell script ifx_server.sh follows:
It is not necessary to install and maintain Connection Manager for simple HDR server pairs, as the ifx_server.sh script makes it possible to soft-code connection to whichever server is in the appropriate mode.
The code fix suggested above is provided “as is” without warranty of any kind, either express or implied, including without limitation any implied warranties of condition, uninterrupted use, merchantability, fitness for a particular purpose, or non-infringement.