I'm creating my mongo cluster inside a VPC. The issue I have is that the privately assigned hostname is unresolvable.
An instance is assigned an ip address 10.0.10.20. Its hostname will be ip-10-0-10-20.
[ec2-user@ip-10-0-10-20 ~]$ ping ip-10-0-10-20
ping: unknown host ip-10-0-10-20
If I add an entry to /etc/hosts (127.0.0.1 ip-10-0-10-20):
ping ip-10-0-10-20
PING ip-10-0-10-20 (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.027 ms
However, each of my nodes are built from the same AMI. I would need to customise each node as it is created with that nodes ip address in the /etc/hosts file.
There's a possibility of putting a command into a launch script but I can't seem to get it to work. The command line equivalent of adding a line to the end of a file keeps giving me permission problems:
[ec2-user@ip-10-0-10-20 ~]$ sudo echo 127.0.0.1 ip-10-0-10-20 >> /etc/hosts -bash: /etc/hosts: Permission denied
I'm not even sure this is the right approach for Mongo inside a VPC.
Any help appreciated.
see "Updating DNS Support for Your VPC" at http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-dns.html
It's likely your VPC was created before the DNS Hostname support flag was available. Set it to True.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.