Managing Serviceguard 12th Edition, March 2006
Designing Highly Available Cluster Applications
Designing Applications to Run on Multiple Systems
Appendix C418
Applications should
not
reference official hostnames or IP addresses.
The official hostname and corresponding IP address for the hostname
refer to the primary LAN card and the
stationary IP address
for that
card. Therefore, any application that refers to, or requires the hostname
or primary IP address may not work in an HA environment where the
network identity of the system that supports a given application moves
from one system to another, but the hostname does not move.
One way to look for problems in this area is to look for calls to
gethostname(2) in the application. HA services should use
gethostname() with caution, since the response may change over time if
the application migrates. Applications that use gethostname() to
determine the name for a call to gethostbyname(2) should also be
avoided for the same reason. Also, the gethostbyaddr() call may return
different answers over time if called with a stationary IP address.
Instead, the application should always refer to the application name and
relocatable IP address rather than the hostname and stationary IP
address. It is appropriate for the application to call gethostbyname(2),
specifying the application name rather than the hostname.
gethostbyname(2) will pass in the IP address of the application. This IP
address will move with the application to the new node.
However, gethostbyname(2) should be used to locate the IP address of
an application only if the application name is configured in DNS. It is
probably best to associate a different application name with each
independent HA service. This allows each application and its IP address
to be moved to another node without affecting other applications. Only
the stationary IP addresses should be associated with the hostname in
DNS.
Use uname(2) With Care
Related to the hostname issue discussed in the previous section is the
application's use of uname(2), which returns the official system name.
The system name is unique to a given system whatever the number of
LAN cards in the system. By convention, the uname and hostname are
the same, but they do not have to be. Some applications, after connection
to a system, might call uname(2) to validate for security purposes that
they are really on the correct system. This is not appropriate in an HA
environment, since the service is moved from one system to another, and
neither the uname nor the hostname are moved. Applications should