简体   繁体   中英

How to connect to Cassandra using ruby

I am new to Cassandra and was trying to achieve some simple operations like inserting data into cassandra. I am using cassandra gem to achieve this.

client = Cassandra.new('tags_logs', 'ec2-xxx-xxx-xxx.com:9160')
client.disable_node_auto_discovery!
client.get('tag_data','red')

And I get the following error:

ThriftClient::NoServersAvailable - No live servers in ...

I'm running this code from my local machine. And while I've no problem connecting using cassandra-cli (so it is not a firewall issue), the code refuses to work. It works perfectly when accessing Cassandra on my own local machine.

Any ideas? Thanks,

Eden.

I recommend you to use this gem I'm developing: https://github.com/hsgubert/cassandra_migrations

It gives access to Cassandra through CQL3 and manages schema with migrations.

Note: it requires Rails.

For future generations: simply change the timeout ...

client = Cassandra.new('tags_logs', 'ec2-example-example-example.com:9160',:connect_timeout => 10000)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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