Home > Software engineering >  Is the Cassandra Getting Started Instructions Broken?
Is the Cassandra Getting Started Instructions Broken?

Time:12-22

I'm trying to get started with Cassandra by following the directions on https://cassandra.apache.org/_/quickstart.html, but step two doesn't make sense. This command: docker run --name cassandra cassandra starts a container. Then the second command (docker run --rm -d --name cassandra --hostname cassandra --network cassandra cassandra) attempts to start another container with the same name which fails because the container already exists. But if it didn't it refers to a network that doesn't exist.

If instead of the first command I run docker network cassandra and then run the second command as given the command in step four (docker run --rm --network cassandra -v "$(pwd)/data.cql:/scripts/data.cql" -e CQLSH_HOST=cassandra -e CQLSH_PORT=9042 nuvo/docker-cqlsh) fails to connect to cassandra.

CodePudding user response:

The Cassandra quick start guide was written with the assumption that users know how to use Docker because that would be out-of-scope for the Apache Cassandra website.

The first docker run command you referred to is a barebones-method of starting Cassandra in a Docker container in the foreground which means that outputs are sent to stdout/stderr.

The second docker run command is the [preferred] alternative which starts the container in the background in detached mode (-d).

You can choose to run one or the other but not both commands. Cheers!

CodePudding user response:

Yes, the instructions on the Cassandra Quickstart page look to be out of date. The following steps worked for me just now:

# step 1 (same as on the page)
docker pull cassandra:latest

# step 2, create network
docker network create cassandra

# step 2, start server
docker run --rm -d --name cassandra --hostname cassandra --network cassandra cassandra

# step 3, follow directions on page to create cql file

# step 4, run the contents of data.cql
docker run --rm -it --network cassandra  -v "$(pwd)/data.cql:/scripts/data.cql" nuvo/docker-cqlsh cqlsh cassandra 9042 --cqlversion='3.4.5' -f /scripts/data.cql

# step 5, create interactive shell
docker run --rm -it --network cassandra  -v "$(pwd)/data.cql:/scripts/data.cql" nuvo/docker-cqlsh cqlsh cassandra 9042 --cqlversion='3.4.5'
  • Related