简体   繁体   English

亚马逊AWS RDS:如何使数据库公开访问互联网

[英]Amazon AWS RDS: how to make the database Publicly Accessible to the internet

I have a database running inside AWS, region South America (Sao Paulo) that I could access with no problems from anywhere in the internet. 我有一个在南美洲(圣保罗)地区的AWS内部运行的数据库,我可以在互联网的任何地方访问它。

Then I wanted to create the same database on US East (North Virginia), but I wasn't able to access it from the internet. 然后我想在美国东部(北弗吉尼亚州)创建相同的数据库,但我无法从互联网访问它。 I compared creating a database on both regions to see the diferences and noticed the US East region doesn't list me any VPC to make it available to the internet. 我比较了在两个地区创建数据库以查看差异,并注意到美国东部地区没有列出任何VPC以使其可用于互联网。

Sout美国地区

美国东部地区

I've been trying to create this VPC with subnet DB, etc, but no success! 我一直在尝试用子网DB等创建这个VPC,但没有成功! Anybody know what steps I need to do in order to make the database available to the internet? 有人知道我需要做什么步骤才能使数据库可用于互联网吗?

Thanks! 谢谢!

First made sure that you have a DB-subnet group in my VPC with an associated VPC subnet in each of the availability regions, then 首先确保在我的VPC中有一个DB子网组,然后在每个可用区域中都有一个关联的VPC子网

  1. Create two subnets within the VPC one each in a different AZ for DB use (take a note of the Subnet IDs). 在VPC中创建两个子网,每个子网在不同的AZ中供DB使用(记下子网ID)。

  2. From RDS create a "Subnet Group" which you add the two subnets to one from each AZ so cover multi-az deployments. 从RDS创建一个“子网组”,您可以将两个子网添加到每个AZ中的一个子网,以覆盖多个部署。 Now the "Choose a VPC" dropdown should be available when you create a new RDS instance. 现在,在创建新的RDS实例时,应该可以使用“选择VPC”下拉列表。

for further info Go here please >> 了解更多信息请访问>>

ANSWER FOR YOUR SECOND QUESTION: 回答你的第二个问题:

Q. Why there are only 251 IPs available when I created the subnet as 172.31.0.0/24? 问:为什么当我创建子网为172.31.0.0/24时,只有251个IP可用?

A. When you create each subnet, you provide the VPC ID and the CIDR block you want for the subnet. A.创建每个子网时,您需要为子网提供所需的VPC ID和CIDR块。 After you create a subnet, you can't change its CIDR block. 创建子网后,您无法更改其CIDR块。 The subnet's CIDR block can be the same as the VPC's CIDR block (assuming you want only a single subnet in the VPC), or a subset of the VPC's CIDR block. 子网的CIDR块可以与VPC的CIDR块相同(假设您只需要VPC中的单个子网),或者VPC的CIDR块的子集。 If you create more than one subnet in a VPC, the subnets' CIDR blocks must not overlap. 如果在VPC中创建多个子网,则子网的CIDR块不得重叠。 The smallest subnet (and VPC) you can create uses a /28 netmask (16 IP addresses), and the largest uses a /16 netmask (65,536 IP addresses). 您可以创建的最小子网(和VPC)使用/ 28网络掩码(16个IP地址),最大的使用/ 16网络掩码(65,536个IP地址)。

Important 重要

AWS reserves both the first four and the last IP address in each subnet's CIDR block. AWS保留每个子网的CIDR块中的前四个和最后一个IP地址。 They're not available for use. 它们无法使用。 If you add more than one subnet to a VPC, they're set up in a star topology with a logical router in the middle. 如果向VPC添加多个子网,则它们将设置为星型拓扑,中间有逻辑路由器。 By default, you can create up to 20 subnets in a VPC. 默认情况下,您最多可以在VPC中创建20个子网。 If you need more than 20 subnets, you can request more by going to 'Request to Increase Amazon VPC Limits' 如果您需要超过20个子网,可以通过'Request to Increase Amazon VPC Limits'来请求更多子网

for further info GO here please. 了解更多信息请访问此处

I had this same issue and I found the following alternative (instead of recreating my RDS instance and setting the "Publicly Accessible" setting to "Yes"). 我有同样的问题,我找到了以下替代方案(而不是重新创建我的RDS实例并将“Publicly Accessible”设置设置为“Yes”)。 This involves setting up an SSH tunnel then connecting to the RDS instance via that tunnel: 这涉及设置SSH隧道,然后通过该隧道连接到RDS实例:

Setup SSH Tunnel: 设置SSH隧道:

ssh -N -L 3306:RDS_HOST:3306 USER@EC2HOST -i SSH-KEY &

Connect to the RDS instance: 连接到RDS实例:

mysql -u rdsuser -p -h 127.0.0.1

source: http://thekeesh.com/2014/01/connecting-to-a-rds-server-from-a-local-computer-using-ssh-tunneling-on-a-mac/#comment-27252 来源: http//thekeesh.com/2014/01/connecting-to-a-rds-server-from-a-local-computer-using-ssh-tunneling-on-a-mac/#comment-27252

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

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