[英]How to connect to an EC2 cassandra instance in ruby
I am new to cassandra so I followed this guide on how to get Cassandra set up on an EC2 instance. 我是Cassandra的新手,所以我按照本指南介绍了如何在EC2实例上设置Cassandra。 I have gotten it all set up and ready to go but for some reason I'm not able to connect from ruby.
我已经完成所有设置并准备就绪,但是由于某种原因,我无法从ruby进行连接。 Here is what I have been trying:
这是我一直在尝试的方法:
require 'cassandra'
client = Cassandra.new('PERSON', 'ec2-xx-xx-xxx-xxx.compute-1.amazonaws.com:9160')
# =>
# <Cassandra:0x100cda3b0
# @auto_discover_nodes = true,
# @column_name_class = {},
# @column_name_maker = {},
# @is_super = {},
# @sub_column_name_class = {},
# @sub_column_name_maker = {},
# attr_accessor :keyspace = "PERSON",
# attr_reader :servers = [
# [0] "ec2-xx-xx-xxx-xxx.compute-1.amazonaws.com:9160"
# ],
# attr_reader :thrift_client_class = ThriftClient < AbstractThriftClient,
# attr_reader :thrift_client_options = {
# :transport_wrapper => Thrift::FramedTransport < Thrift::BaseTransport,
# :thrift_client_class => ThriftClient < AbstractThriftClient,
# :protocol => Thrift::BinaryProtocolAccelerated < Thrift::BinaryProtocol
# }
# >
Then when I tried to use the client, I get this error: 然后,当我尝试使用客户端时,出现此错误:
client.keyspaces
#=> ThriftClient::NoServersAvailable: No live servers in [ec2-xx-xx-xxx-xxx.compute-1.amazonaws.com:9160].
I am able to connect via SSH so I'm not sure what I'm doing wrong here. 我可以通过SSH进行连接,所以我不确定在这里做错了什么。
Update: 更新:
My security group includes: 我的安全组包括:
port: 9160 端口: 9160
protocol: tcp 通讯协定: tcp
source: sg-xxxxxxxx 来源: sg-xxxxxxxx
Where is the "source" of the connection into the Cassandra server? 与Cassandra服务器的连接“源”在哪里?
The security group you are using only opens up port 9160 to instances in the group sg-xxxxxxxx . 您使用的安全组仅向组sg-xxxxxxxx中的实例打开端口9160。 If you are trying to connect from anywhere else (like the outside world) you will not be successful.
如果您尝试从其他任何地方(例如外部世界)进行连接,那么您将不会成功。
There are two things to check: 有两件事要检查:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.