/etc/hosts
kind of act like a local DNS, when you don't have real DNS associated with an IP address.
Do you really need a {public dns of 1st instance} node1
mapping if you can use {public dns of 1st instance} directly in the slave and master files?
Moreover, it's better to use the private IP addresses of amazon instances instead of using the public IP addresses. You can do a ifconfig
in the terminal of each instances and determine their private IP addresses if any. They will probably basically will start with 10.x.x.x/172.x.x.x/192.x.x.x? You can probably then map those instead in /etc/hosts in each of the amazon instances.
So, your /etc/hosts in each machine should look something like -
Machine-1:
{IP_address_1st_instance} node1
{IP_address_2st_instance} node2
Machine-2:
{IP_address_1st_instance} node1
{IP_address_2st_instance} node2
And, this is so that the Amazon instances(machines) can resolve each other, if you are anyhow planning to map them.