新部署到 ElasticBeanstalk 的版本需要几分钟才能可用,所以我希望有人可以省去我所有的测试/实验 :-)
场景 1:我需要从另一个 EC2 实例连接到运行 MySQL 但属于不同安全组的 EC2 实例。我是使用公共 DNS 还是私有 IP 来指定 MySQL 主机?
场景二:同上,只是两个实例属于同一个安全组。我相信在这种情况下我需要使用私有 IP,对吗?公共 DNS 也可以工作吗?
谢谢!
新部署到 ElasticBeanstalk 的版本需要几分钟才能可用,所以我希望有人可以省去我所有的测试/实验 :-)
场景 1:我需要从另一个 EC2 实例连接到运行 MySQL 但属于不同安全组的 EC2 实例。我是使用公共 DNS 还是私有 IP 来指定 MySQL 主机?
场景二:同上,只是两个实例属于同一个安全组。我相信在这种情况下我需要使用私有 IP,对吗?公共 DNS 也可以工作吗?
谢谢!
You should always use the private IP when possible for ec2 instances communicating with each other.
Among other reasons, you will get charged money for using the public ip even though the machines are started in the same availability zone.
Also, the security group is just a set of inbound and outbound rules, it doesn't matter that the two machines are in different groups with different rules so long as your mysql server can accept traffic on the port from the other ec2 instance based on the ruleset.
If you're going to be starting and stopping instances frequently, you might benefit from creating an elastic IP and attaching it to instances as needed instead of constantly changing configuration files.