Sitemap

Running Single Node Cassandra Container

2 min readJan 1, 2025

Run the cassandra container with docker-compose

Pre-requisites:

  • docker
  • docker compose
Press enter or click to view image in full size
cassandra single node docker-compose
  • Create the directory cassandra && cd cassandra
  • Pull the required verison image docker pull cassandra:5.0
  • Create the .env file in the above directory with the following content:
VERSION=5.0
  • Create the file docker-compose.yml in the above directory with the following content:
networks:
cassandra:
services:
cassandra:
image: cassandra:${VERSION:-5.0}
container_name: cassandra
hostname: cassandra
healthcheck:
test: ["CMD", "cqlsh", "-e", "describe keyspaces" ]
interval: 5s
timeout: 5s
retries: 60
networks:
- cassandra
ports:
- "9042:9042"
volumes:
- ./data:/var/lib/cassandra
environment:
CASSANDRA_CLUSTER_NAME: SolarSystem
CASSANDRA_DC: Mars
CASSANDRA_RACK: West
CASSANDRA_ENDPOINT_SNITCH: GossipingPropertyFileSnitch
CASSANDRA_NUM_TOKENS: 128
  • Run the command docker-compose up -d
  • Check the status of the container: docker ps -a, you will see a container running with
CONTAINER ID   IMAGE           COMMAND                  CREATED         STATUS                   PORTS                                                       NAMES
860be3abecf9 cassandra:5.0 "docker-entrypoint.s…" 4 minutes ago Up 4 minutes (healthy) 7000-7001/tcp, 7199/tcp, 9160/tcp, 0.0.0.0:9042->9042/tcp cassandra
  • Check with the logs docker logs cassandra | grep "9042", you will see the container logs with following, then your container is ready for use:
INFO  [main] 2024-06-09 04:22:32,346 PipelineConfigurator.java:131 - Starting listening for CQL clients on /0.0.0.0:9042 (unencrypted)...
INFO [main] 2024-06-09 04:22:32,353 CassandraDaemon.java:738 - Startup complete
  • SSH into container to interact with cqlsh: docker exec -it cassandra bash
  • Run the command cqlsh
Connected to SolarSystem at 127.0.0.1:9042
[cqlsh 6.2.0 | Cassandra 5.0-beta1 | CQL spec 3.4.7 | Native protocol v5]
Use HELP for help.
cqlsh>

List Default Keyspaces: describe keyspaces or desc keyspaces;

cqlsh> desc keyspaces;
system system_distributed system_traces system_virtual_schema
system_auth system_schema system_views

Ref: My day-to-day activities and hands-on experience with Cassandra operations, covering everything from setup to advanced maintenance and optimization techniques are here

--

--

Jinna Baalu
Jinna Baalu

Written by Jinna Baalu

Devops Solution Architect | Managing Consensus based Distributed Clusters | Centralised Logging 4M/15min | ELK | Prometheus | Kafka | Cassandra | Mongo

No responses yet