Once the instances are created, set a hostname for each node and then add an entry to /etc/hosts file so that the nodes can locate each other. You can also use DNS if it’s available in your environment.

  1. use hostnamectl command to set a hostname:
$ sudo su -
# hostname 
ip-10-20-1-10.us-west-2.compute.internal 
# hostnamectl set-hostname node-a
  1. If a DNS server is available, register your hostname(s) using the server. If there is not a DNS server available, using /etc/hosts is recommended to resolve the hostnames.
# cat /etc/hosts 
127.0.0.1	localhost localhost.localdomain localhost4 localhost4.localdomain4 
::1 		localhost localhost.localdomain localhost4 localhost4.localdomain4 
  1. Add the following lines to the /etc/hosts file so that node-a and node-b can be resolved to an IP address(es).
10.20.1.10	node-a
10.20.2.10 	node-b 
10.20.3.10 	node-c 
  1. Create a backup of /etc/hosts, edit the file and confirm the changes.
# cp -p /etc/hosts /etc/hosts.org 
# vi /etc/hosts 
# cat /etc/hosts 
127.0.0.1	localhost localhost.localdomain localhost4 localhost4.localdomain4 
::1 		localhost localhost.localdomain localhost4 localhost4.localdomain4 
10.20.1.10 node-a
10.20.2.10 node-b 
10.20.3.10 node-c
  1. Make sure you can ping these nodes by name.
# ping node-b 
PING node-b (10.20.2.10) 56(84) bytes of data. 
64 bytes from node-b (10.20.2.10): icmp_seq=1 ttl=64 time=0.868 ms 
64 bytes from node-b (10.20.2.10): icmp_seq=1 ttl=64 time=0.892 ms 
^C

Feedback

Was this helpful?

Yes No
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.

Post your comment on this topic.

Post Comment