简体   繁体   English

在AWC VPC中创建Mongodb副本集

[英]Creating a Mongodb replicaset in an AWC VPC

I'm creating my mongo cluster inside a VPC. 我正在VPC内创建mongo集群。 The issue I have is that the privately assigned hostname is unresolvable. 我的问题是私下分配的主机名无法解析。

An instance is assigned an ip address 10.0.10.20. 实例分配的IP地址为10.0.10.20。 Its hostname will be ip-10-0-10-20. 它的主机名是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): 如果我将条目添加到/ 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. 但是,我的每个节点都是从相同的AMI构建的。 I would need to customise each node as it is created with that nodes ip address in the /etc/hosts file. 我需要自定义每个节点,因为它是使用/ etc / hosts文件中的节点ip地址创建的。

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 [ec2-user @ ip-10-0-10-20〜] $ sudo echo 127.0.0.1 ip-10-0-10-20 >> / etc / hosts -bash:/ etc / hosts:权限被拒绝

I'm not even sure this is the right approach for Mongo inside a VPC. 我什至不确定这对VPC内部的Mongo是否适用。

Any help appreciated. 任何帮助表示赞赏。

see "Updating DNS Support for Your VPC" at http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-dns.html 请参阅http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-dns.html上的 “为VPC更新DNS支持”

It's likely your VPC was created before the DNS Hostname support flag was available. 您的VPC可能是在DNS主机名支持标志可用之前创建的。 Set it to True. 将其设置为True。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM