简体   繁体   English

如何使用mySQLworkbench连接到AWS私有子网VPC中的RDS

[英]How to use mySQLworkbench to connect to RDS in AWS private subnet VPC

I am new in AWS VPC. 我是AWS VPC的新手。 I have question about how to connect mySQLworkbench to RDS in AWS private subnet. 我对如何将mySQLworkbench连接到AWS私有子网中的RDS有疑问。

I use VPC wizard to create scenario 2 : VPC with public and private subnets. 我使用VPC向导创建方案2:具有公共和私有子网的VPC。 From a lot of blogs and forums, most of the people recommend the database should be in private subnet, so I created the database in private subnet. 从很多博客和论坛来看,大多数人都建议数据库应该在私有子网中,所以我在私有子网中创建了数据库。 I also created NAT gateway (not the instance). 我还创建了NAT网关(不是实例)。 Is that anyway I could use mySQLworkbench from public (any) network to connect to the database in private subnet? 无论如何,我可以使用来自公共(任何)网络的mySQLworkbench连接到私有子网中的数据库吗?

Thanks, Angela 谢谢,安吉拉

I also followed the Scenario 2 in the AWS Documentation without the NAT parts. 我还在没有NAT部分的AWS文档中遵循了场景2。 But now I can't access the RDS instance from my computer because RDS is in a private subnet. 但是现在我无法从我的计算机访问RDS实例,因为RDS位于私有子网中。

To solve the accessibility problem I got the idea from this tutorial . 为了解决可访问性问题,我从本教程中得到了这个想法。 I actually did not follow it, so I cannot recommend it. 我实际上没有遵循它,所以我不推荐它。

What I actually did was: 我实际做的是:

1) I created an EC2 instance and gave it an ellastic IP. 1)我创建了一个EC2实例并给它一个弹性IP。

2) Then I allowed the DB to receive traffic from this instance (this was already defined on the AWS tutorial, on the DB server Security Group). 2)然后我允许数据库从此实例接收流量(这已在AWS教程上,在数据库服务器安全组上定义)。

3) Then I allowed an SSH connection from my computer to the EC2 instance. 3)然后我允许从我的计算机到EC2实例的SSH连接。

4) Finnaly I was able to connect to the DB using MySQL WorkBench by establishing a connection "Standard TCP/IP over SSH" 4)Finnaly我能够通过建立连接“通过SSH的标准TCP / IP”使用MySQL WorkBench连接到数据库

The good thing is that this solution can be achieved using only Free Tier resources (at the time of writing) AFAIK. 好处是这个解决方案只能使用免费层资源(在撰写本文时)AFAIK来实现。

Use VPN solution such as OpenVPN. 使用OpenVPN等VPN解决方案。

  • Configure Openvpn server in public subnet. 在公有子网中配置Openvpn服务器。
  • Push route of private subnet in server configuration 在服务器配置中推送私有子网的路由
  • Adjust the private route table to pass the vpn traffic through vpn server 调整私有路由表以通过vpn服务器传递vpn流量
  • Connect to vpn using client configuration from your PC. 使用PC上的客户端配置连接到vpn。
  • Use Mysql workbench to connect to your DB instance 使用Mysql工作台连接到您的数据库实例

Other way as suggested previously, you can configure ssh bastion host and then use it as jump server to ssh into db instance. 如前所述的其他方式,您可以配置ssh堡垒主机,然后将其用作跳转服务器以ssh到db实例中。 Accordingly configure mysqlworkbench connection to reach db 因此配置mysqlworkbench连接以达到db

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

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