How should the /etc/hosts file be set up on RHEL cluster nodes?
- Red Hat Enterprise Linux (RHEL) with the High Availability Add-On
- 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/hostsfile 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/hostsfile when configuring a two node Red Hat High Availability cluster?
- In Red Hat Enterprise Linux with the High Availability Add-On, the
/etc/hostsfile should be used to define the IP address and host names for all cluster nodes and fence devices. 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/hostsshould 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 shortnames are desired to differentiate a specific node's 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/hostsfor 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/hostsdoes 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
Further information on configuring a dedicated heartbeat network:
How do I configure cluster nodes to use a dedicated heartbeat interface?
Further information on how cluster resolves the configured node names:
What should I name my cluster nodes?
- Red Hat Enterprise Linux
- Learn more
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.
the .201 node name has a typo, and the spacing is off.