Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

eduardopezzi avatar image
eduardopezzi asked Erick Ramirez edited

How do I access a Docker volume in a new container?

After update my Cassandra docker container it raised the following error:

CassandraDaemon.java:911 - Fatal configuration error
org.apache.cassandra.exceptions.ConfigurationException: \
    Cannot change the number of tokens from 256 to 16

I am using cassandra:latest image, and probably its updated its version, and after that the server shutdown every time I try to run it again.

docker
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

steve.lacerda avatar image
steve.lacerda answered eduardopezzi commented

It sounds like your cassandra.yaml was updated whenever you ran your update. Check the num_tokens value to verify it’s the same as before you did your update.

1 comment Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Indeed, but as it is a container I was struggling to use the console as the container shutdown all the time. I manage to stop doing that and edit cassandra.yaml

Thank you

0 Likes 0 ·
Erick Ramirez avatar image
Erick Ramirez answered Erick Ramirez edited

We do not recommend updating a Cassandra container to a newer version. Cassandra 4.0+ is pre-configured with a new default of 16 virtual nodes (CASSANDRA-13701):

num_tokens: 16

Older versions of Cassandra had a default of 256. It is not possible to change the number of tokens allocated to a node once Cassandra has joined a cluster (even for single-node clusters). As you have already discovered, changing the allocated tokens will prevent Cassandra from starting.

You will need to edit the cassandra.yaml in order to allow Cassandra to start. Provided you named your container cassandra:

$ docker ps -a
CONTAINER ID  IMAGE      COMMAND  CREATED  STATUS  PORTS              NAMES
788db79a03d3  cassandra  ...      ...      Up      7000-7001/tcp,...  cassandra

you can view the cassandra container's configuration with:

$ docker inspect cassandra

and you will see that the configuration directory is set to:

                "CASSANDRA_CONF=/etc/cassandra",

Make a local copy of the configuration file:

$ docker cp cassandra:/etc/cassandra/cassandra.yaml .

Edit your local copy then copy the modified version to the the container with:

$ docker cp cassandra.yaml cassandra:/etc/cassandra/cassandra.yaml

Cheers!

Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.