Search code examples
dockercassandracassandra-3.0

apache-cassandra-4.0.7 Dockerfile Unavailable exception


Trying to create docker image from apache-cassandra-4.0.7-bin.tar.gz but getting following error after configring keyspace

$ docker exec -it pidcss /bin/bash

$ ./cqlsh localhost -u cassandra -p cassandra

Connected to Test Cluster at localhost:9042

[cqlsh 6.0.0 | Cassandra 4.0.7 | CQL spec 3.4.5 | Native protocol v5]

Use HELP for help.

cassandra@cqlsh> CREATE KEYSPACE pid
   ...   WITH REPLICATION = { 
   ...    'class' : 'SimpleStrategy', 
   ...    'replication_factor' : 0 
   ...   };
cassandra@cqlsh> use pid
   ... ;
cassandra@cqlsh:pid> CREATE TABLE if not exists vis (parentid text, type text,  PRIMARY 
KEY (parentid));

cassandra@cqlsh:pid> describe tables;

$ ./cqlsh localhost -u cassandra -p cassandra
Connected to Test Cluster at localhost:9042
[cqlsh 6.0.0 | Cassandra 4.0.7 | CQL spec 3.4.5 | Native protocol v5]
Use HELP for help.
cassandra@cqlsh> CREATE KEYSPACE pid WITH REPLICATION = { 
'class' : 'SimpleStrategy', 
'replication_factor' : 0 
 };
cassandra@cqlsh> use pid
   ... ;
cassandra@cqlsh:pid> CREATE TABLE if not exists vis (parentid text, type text,  PRIMARY KEY (parentid));
cassandra@cqlsh:pid> describe tables;
vismenu

cassandra@cqlsh:pid> select * from vis ; NoHostAvailable: ('Unable to complete the operation against any hosts', {<Host: 127.0.0.1:9042 datacenter1>: Unavailable('Error from server: code=1000 [Unavailable exception] message="Cannot achieve consistency level ONE" info={\'consistency\': \'ONE\', \'required_replicas\': 1, \'alive_replicas\': 0}')}) cassandra@cqlsh:pid>

Any idea on what could help resolve this.

Thanks,


Solution

  • It is unclear if the docker image got pulled successfully & set up correct. At a high level the steps would look like,

    • docker pull cassandra:4.0.11 or use the latest tag docker pull cassandra:latest from https://hub.docker.com/_/cassandra/tags?page=1
    • docker network create cassandra
    • docker run --rm -d --name cassandra --hostname cassandra --network cassandra cassandra and let it start up fully
    • docker run --rm -it --network cassandra nuvo/docker-cqlsh cqlsh cassandra 9042 --cqlversion='3.4.5' to start an interactive CQLSHell

    (Optional clean-up activities)

    docker kill cassandra
    docker network rm cassandra
    

    I hope that helps!