Reputation: 141
I have a host with 4 docker containers. On three containers, I have set up Cassandra nodes. On the fourth container, I have a Ruby on Rails application running and I am trying to connect to the Cassandra cluster from it.
I get the following error while trying to connect:
require 'cassandra'
cluster = Cassandra.cluster
irb(main):002:0> require 'cassandra'
=> true
irb(main):003:0> cluster = Cassandra.cluster
Cassandra::Errors::NoHostsAvailable: All attempted hosts failed: 127.0.0.1 (Cassandra::Errors::IOError: Connection refused - connect(2))
from /var/lib/gems/1.9.1/gems/cassandra-driver-2.1.5/lib/cassandra/future.rb:570:in `get'
from /var/lib/gems/1.9.1/gems/cassandra-driver-2.1.5/lib/cassandra/future.rb:363:in `get'
from /var/lib/gems/1.9.1/gems/cassandra-driver-2.1.5/lib/cassandra.rb:211:in `cluster'
from (irb):3
from /usr/bin/irb:12:in `<main>'
In the Cassandra.yaml file, I have set up the following:
cluster_name: 'MyCassandraCluster'
num_tokens: 256
seed_provider:
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
- seeds: "172.17.0.2,172.17.0.3,172.17.0.4"
listen_address: IP of the host of the containers
rpc_address: <seed ip of this instance>
Please help. Thanks
Upvotes: 1
Views: 1336
Reputation: 52
Try specifying the address or hostname of one of the Cassandra containers.
Cassandra.cluster()
Defaults to localhost (127.0.0.1)
Cassandra.cluster(hosts: ['172.17.0.2','172.17.0.3','172.17.0.4'])
Or even better, just link your RoR container to cassandra (--link cassandra:cassandra
) and you might be able to just do:
Cassandra.cluster(hosts: ['cassandra'])
Upvotes: 1