简体   繁体   English

如何连接我的redshift数据库?

[英]How do I connect with my redshift database?

I am setting up a redshift database on AWS and I've followed the instructions on this article - https://chartio.com/resources/tutorials/connecting-to-a-database-within-an-amazon-vpc/ 我正在AWS上建立Redshift数据库,并且已经按照本文中的说明进行操作-https: //chartio.com/resources/tutorials/connecting-to-a-database-within-an-amazon-vpc/

I am unable to connect to the database. 我无法连接到数据库。

Here's my setup - 这是我的设置-

I have a PostgreSQL database instance that I spun up with Amazon RDS. 我有一个使用Amazon RDS旋转的PostgreSQL数据库实例。 That is connected to an Amazon VPC with two subnets. 该服务器通过两个子网连接到Amazon VPC。

Subnet A is set in us-east-2c. 子网A设置在us-east-2c中。 It is associated with a Route Table that has two routes. 它与具有两个路由的路由表关联。 The first has destination 10.0.0.0/16, target 'local', status 'active' and propogated 'no'. 第一个具有目的地10.0.0.0/16,目标“本地”,状态“活动”和传播“否”。 The second has destination 0.0.0.0/0 and is targeted to an Internet Gateway associated with the VPC. 第二个目标为0.0.0.0/0,目标是与VPC关联的Internet网关。

Subnet B is set in us-east-2b. 子网B设置在us-east-2b中。 It has destination 10.0.0.0/16 and target 'local'. 它具有目的地10.0.0.0/16和目标“本地”。

The PostgreSQL db is associated with a Security Group with this inbound rule: Type: Custom TCP Rule, Protocol: TCP, Port Range: 5432 and Source: 10.0.0.0/32. PostgreSQL数据库通过以下入站规则与安全组关联:类型:自定义TCP规则,协议:TCP,端口范围:5432,源:10.0.0.0/32。 There are no outbound rules. 没有出站规则。

Other details on the database: 数据库上的其他详细信息:

-Publicly Accessible is set to No -“公开访问”设置为“否”

-It is running in us-east-2b -它在us-east-2b中运行

Additionally, there is an instance on EC2. 此外,EC2上还有一个实例。 It is on us-east-2c. 它在us-east-2c上。

It is associated with a Security Group with these inbound rules: 它与具有以下入站规则的安全组关联:

First- Type: Custom TCP Rule, Protocol: TCP, Port Range: 5432, Source: 10.0.0.0/32 第一类:自定义TCP规则,协议:TCP,端口范围:5432,源:10.0.0.0/32

Second- Type: SSH, Protocol: TCP, Port Range: 22, Source: (my-ip-address)/32 第二类型:SSH,协议:TCP,端口范围:22,源:(my-ip-address)/ 32

Third- Type: SSH, Protocol: TCP, Port Range: 22, Source: (group id for the security group) 第三类型:SSH,协议:TCP,端口范围:22,源:(安全组的组ID)

Both of the Security Groups are associated with the same VPC that has the following settings: IPv4 CIDR: 10.0.0.0/16, IPv6 CIDR: (blank). 这两个安全组都与具有以下设置的同一VPC关联:IPv4 CIDR:10.0.0.0/16,IPv6 CIDR:(空白)。

My understanding of the set up is that the EC2 instance is public and I can SSH into that from my SQL client (Postico). 我对设置的理解是EC2实例是公共的,我可以从我的SQL客户端(Postico)SSH进入该实例。 And then, the EC2 instance will connect privately to the Redshift Database. 然后,EC2实例将私下连接到Redshift数据库。

Here's my problem- 这是我的问题-

a) I've never set this up before and I may have done something completely wrong without knowing it. a)我以前从未进行过设置,并且可能在不知情的情况下做了完全错误的事情。

b) I am attempting to create an SSH connection from Postico. b)我正在尝试从Postico创建SSH连接。 I do not know what value to fill in for 'Host' or 'Port'. 我不知道要为“主机”或“端口”填写什么值。 Additionally, I do not know whether 'User' and 'Password' refer to the user and password for the account on my computer or whether it refers to something else altogether. 此外,我不知道“用户”和“密码”是指我计算机上帐户的用户名和密码,还是完全指其他名称。

My goal is simply to be able to have a PostgreSQL database that is unavailable to the public, but allows me to access it from my SQL client (Postico). 我的目标只是能够拥有一个公众不可用的PostgreSQL数据库,但允许我从我的SQL客户端(Postico)访问它。

I've attempted to research this problem, but there is a surprising lack of content that I was able to find to address these needs. 我已经尝试研究此问题,但是却找不到满足这些需求的令人惊讶的内容。 I'm new to this, so if I'm missing required pieces to post this or if I've messed up in some way, please alert me and I will update accordingly. 我对此并不陌生,因此,如果我缺少发布此文章所需的部分,或者如果我在某种程度上搞砸了,请提醒我,我会相应地进行更新。

Your inbound security group has "Source: 10.0.0.0/32" This means only 10.0.0.0 can connect to it, which is an invalid host address. 您的入站安全组具有“源:10.0.0.0/32”,这意味着只有10.0.0.0可以连接到它,这是无效的主机地址。 Change the /32 to match your network (/16). 更改/ 32以匹配您的网络(/ 16)。

Redshift's port is usually 5439. You are referencing 5432. Redshift的端口通常是5439。您引用的是5432。

I don't understand your "b" question. 我不明白您的“ b”问题。 What are you trying to connect to? 您要连接到什么?

[Update with new information] [更新新信息]

I just realized an issue with what you are trying to do. 我刚刚意识到您要做什么。

Your goal is to connect to EC2 from your desktop using SSH and then connect to RDS. 您的目标是使用SSH从桌面连接到EC2,然后连接到RDS。 This won't work. 这行不通。

The solution is to setup a VPN such as OpenVPN that allows you to connect to your VPC in AWS and then OpenVPN will forward your client requests to RDS (VPN routing). 解决方案是设置一个VPN,例如OpenVPN,该VPN允许您连接到AWS中的VPC,然后OpenVPN会将您的客户端请求转发到RDS(VPN路由)。

What I do is setup an EC2 instance using OpenVPN. 我要做的是使用OpenVPN设置EC2实例。 I then turn on and off this instance when I need VPN access into AWS. 然后,当我需要对AWS的VPN访问时,可以打开和关闭该实例。 I have batch scripts that do this from my desktop (start and stop an EC2 instance). 我有从我的桌面执行此操作的批处理脚本(启动和停止EC2实例)。

The other choice is to allow Internet access to RDS. 另一个选择是允许Internet访问RDS。 You can use Security Groups to lock down Internet access to only your home/work IP address. 您可以使用安全组来锁定仅对家庭/工作IP地址的Internet访问。 Depending on your Internet provider your IP may change which means updating your security group with the new IP address, but this is simple to do. 根据您的Internet提供商的不同,您的IP可能会更改,这意味着使用新IP地址更新安全组,但这很容易做到。

This page will show you your public IP address that is put into the Security Group: What is my IP 此页面将向您显示您放入安全组的公共IP地址: 什么是我的IP

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

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