Sign inSign up

saradindusamal10/cassandra-test

By saradindusamal10

โ€ขUpdated 10 months ago

Testing Cassandra Replication factors with different consistency levels

Image
Databases & storage
0

224

saradindusamal10/cassandra-test repository overview

โ Apache Cassandra (Docker Image)

This repository contains a Docker image of Apache Cassandra designed for easy local development and learning.
Built from a running container and fully compatible with Docker Desktop on Windows, Linux, and macOS.


โ ๐Ÿ† Features

  • Fully functional Apache Cassandra instance

Connect to Cassandra using CQLSH docker exec -it cassandra-node1 cqlsh

๐Ÿงช Example: Create Keyspace and Table Create Keyspace CREATE KEYSPACE demo WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 2};

Create Table CREATE TABLE demo.users ( id UUID PRIMARY KEY, name text, age int );

Insert Sample Data INSERT INTO demo.users (id, name, age) VALUES (uuid(), 'Alice', 25); INSERT INTO demo.users (id, name, age) VALUES (uuid(), 'Bob', 30);

๐Ÿ“ฌ Read Data SELECT * FROM demo.users;

๐Ÿ›  Troubleshooting Cassandra does not start?

Try increasing WSL2 memory using .wslconfig:

[wsl2] memory=6GB processors=4 swap=1GB

CQLSH connection refused?

Wait 20โ€“40 seconds โ€” Cassandra takes time to bootstrap.

  • Suitable for single-node or multi-node cluster setup
  • Works on Windows (WSL2), Linux, macOS
  • Docker-based โ€” no need to install Cassandra manually
  • Fast startup and simple configuration

โ ๐Ÿš€ Getting Started

โ 1. Pull the Cassandra Image
docker pull saradindusamal10/cassandra-test:node1_v1

2. Run a Single Cassandra Node
docker run -d --name cassandra-node1 \
  -p 9042:9042 \
  --network cassandra-net \
  -e CASSANDRA_CLUSTER_NAME="TestCluster" \
  -e CASSANDRA_SEEDS="cassandra-node1" \
  -e CASSANDRA_LISTEN_ADDRESS=cassandra-node1 \
  -e CASSANDRA_BROADCAST_ADDRESS=cassandra-node1 \
  -e CASSANDRA_ENDPOINT_SNITCH=SimpleSnitch \
  saradindusamal10/cassandra-test:node1_v1

Optional: Create Docker Network (if needed)
docker network create cassandra-net

Multi-Node Cassandra Cluster Example
1. Start Node 1 (Seed Node)
docker run -d --name cassandra-node1 \
  --network cassandra-net \
  -p 9042:9042 \
  -e CASSANDRA_CLUSTER_NAME="TestCluster" \
  -e CASSANDRA_SEEDS="cassandra-node1" \
  -e CASSANDRA_LISTEN_ADDRESS=cassandra-node1 \
  -e CASSANDRA_BROADCAST_ADDRESS=cassandra-node1 \
  saradindusamal10/cassandra-test:node1_v1

2. Start Node 2
docker run -d --name cassandra-node2 \
  --network cassandra-net \
  -e CASSANDRA_CLUSTER_NAME="TestCluster" \
  -e CASSANDRA_SEEDS="cassandra-node1" \
  -e CASSANDRA_LISTEN_ADDRESS=cassandra-node2 \
  -e CASSANDRA_BROADCAST_ADDRESS=cassandra-node2 \
  saradindusamal10/cassandra-test:node1_v2

Verify Cluster Status
docker exec -it cassandra-node1 nodetool status


Expected:

Both nodes should be in UN state (Up/Normal)

Connect to Cassandra using CQLSH
docker exec -it cassandra-node1 cqlsh

๐Ÿงช Example: Create Keyspace and Table
Create Keyspace
CREATE KEYSPACE testks
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 2};

Create Table
CREATE TABLE testks.users (
    id UUID PRIMARY KEY,
    name text,
    age int
);

Insert Sample Data
INSERT INTO testks.users (id, name, age) VALUES (uuid(), 'Alice', 25);
INSERT INTO testks.users (id, name, age) VALUES (uuid(), 'Bob', 30);

๐Ÿ“ฌ Read Data
SELECT * FROM testks.users;

๐Ÿ›  Troubleshooting
Cassandra does not start?

Try increasing WSL2 memory using .wslconfig:

[wsl2]
memory=6GB
processors=4
swap=1GB

CQLSH connection refused?

Wait 20โ€“40 seconds โ€” Cassandra takes time to bootstrap.

Tag summary

Content type

Image

Digest

sha256:8d42ddbdfโ€ฆ

Size

150.9 MB

Last updated

10 months ago

docker pull saradindusamal10/cassandra-test:node1_v1