How should the /etc/hosts file be set up on RHEL cluster nodes?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux (RHEL) with the High Availability Add-On

Issue

  • Should cluster node names and fence device host names be defined in /etc/hosts, or can I just rely on DNS to do lookups?
  • What is the /etc/hosts file used for, and how should it be set up?
  • How can I avoid fencing failing and/or nodes being unable to join a cluster when DNS lookups are not functioning?
  • How to configure /etc/hosts file when configuring a two node Red Hat High Availability cluster?

Resolution

In Red Hat Enterprise Linux with the High Availability Add-On, the /etc/hosts file should be used to define the IP address and host names for:

This is recommended to eliminate DNS as a single point of failure. Configuring the cluster software to use the preferred network interface often involves specifying the correct fully qualified name in the configuration, and so /etc/hosts should also list nodes in this format whenever possible:

    <IP>               <Fully Qualified Domain Name>    <Short Name>
    192.168.2.2        node1.example.com                node1
    192.168.2.3        node2.example.com                node2

If only short names are desired to differentiate a specific node address, they can be specified in /etc/hosts in place of a fully qualified name:

    <IP>               <Short Name>
    192.168.2.2        node1
    192.168.2.3        node2

Below is a complete example /etc/hosts for a three-node cluster with a single fence device per node:

    # Do not remove the following line, or various programs
    # that require network functionality will fail.
    127.0.0.1               localhost.localdomain    localhost
    ::1                     localhost6.localdomain6  localhost6
    # cluster nodes.
    192.168.2.201           cluster-1.example.com    cluster-1
    192.168.2.202           cluster-2.example.com    cluster-2
    192.168.2.203           cluster-3.example.com    cluster-3
    # fence devices.
    192.168.2.204           node1-fence
    192.168.2.205           node2-fence
    192.168.2.206           node3-fence
  • Note: In the place of hostnames, the cluster configuration can use IP addresses for node names and fence device ipaddr values. If no hostnames are used to specify a node in the cluster configuration, then /etc/hosts does not need to contain any specific entries for the cluster nodes.
  • Note: The use of DHCP for obtaining an ip address on an interface being used by corosync for heartbeat communication is unsupported

Related Articles

Root Cause

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments