如何解决EC2 实例 (Elastic Beanstalk) 上的 Amazon Cassandra 连接超时
我无法从我的 EC2 实例连接到 Amazon 托管的 Cassandra(密钥空间)。 EC2 实例位于 VPC 的私有子网中,具有用于密钥空间的 VPC 终端节点。
EC2 出站规则:
All TCP 0.0.0.0/0
VPC 端点入站规则:
Custom TCP TCP 9142 0.0.0.0/0
VPC Endpoint 出站规则:
Custom TCP TCP 9142 0.0.0.0/0
这些规则实际上可能过于宽松。
C# 驱动程序错误:
Cassandra.NoHostAvailableException:
All hosts tried for query Failed (tried 10.16.192.201:9142:
TimeoutException 'The timeout period elapsed prior to completion of SSL authentication operation.'; 10.16.224.203:9142:
TimeoutException 'The timeout period elapsed prior to completion of SSL authentication operation.')
我可以通过 SSH 连接到 EC2。
DNS 似乎正确:
$ nslookup cassandra.eu-west-2.amazonaws.com
Server: 10.16.0.2
Address: 10.16.0.2#53
Non-authoritative answer:
Name: cassandra.eu-west-2.amazonaws.com
Address: 10.16.192.201
Name: cassandra.eu-west-2.amazonaws.com
Address: 10.16.224.203
我无法卷曲端点(超时):
$ curl cassandra.eu-west-2.amazonaws.com:9142
和 Telnet:
$ sudo yum -y install telnet
$ telnet cassandra.eu-west-2.amazonaws.com
Trying 10.16.192.201...
^C
# Gave up after 60s
VPC 端点的安全组允许 9142
流量进出任何地方。 EC2 实例的安全组允许出口到任何地方。
如何连接到 Cassandra?
更新
我现在可以将 VPC 端点添加到公有子网:
$ telnet cassandra.eu-west-2.amazonaws.com 9142
Trying 10.16.224.203...
Connected to cassandra.eu-west-2.amazonaws.com.
Escape character is '^]'.
更新
如果证书吊销检查被禁用,我可以连接。
sslOptions.SetCertificateRevocationCheck false
这让我认为问题在于从 EC2 到托管 CRL 的任何地方的连接。但是,我不想将我的 EC2 移动到公共 VPC,那么这里有什么好的策略?
解决方法
根据文档 Using a Cassandra .NET Core Client Driver to Access Amazon Keyspaces Programmatically
,我认为您需要一个密钥才能连接到Cassandra
$client = new-object System.Net.WebClient
$client.DownloadFile("https://www.amazontrust.com/repository/AmazonRootCA1.pem","path_to_file\AmazonRootCA1.pem")
,
您可以使用私有接口 VPC 端点连接到密钥空间。这将允许您使用只能从 vpc 访问的不同端点,这样网络流量就不会离开 Amazon 网络。
https://docs.aws.amazon.com/keyspaces/latest/devguide/vpc-endpoints.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。