Public | Automated Build

Last pushed: 2 years ago
Short Description
Cassandra 2.1.5 (single or clustered). OpsCenter available at abh1nav/opscenter
Full Description

Cassandra 2.1.5 as a Docker container. For development use only.

Quickstart

TL;DR

Paste this into your terminal to start a 5 node cluster with OpsCenter:

bash <(curl -sL http://bit.ly/docker-cassandra)

OR, if you don't trust the one-liner, here are its contents:

#!/bin/bash
docker pull abh1nav/opscenter:latest
docker pull abh1nav/cassandra:latest
echo "Starting OpsCenter"
docker run -d --name opscenter abh1nav/opscenter:latest
sleep 10
OPS_IP=$(docker inspect -f '{{ .NetworkSettings.IPAddress }}' opscenter)
echo "Starting node cass1"
docker run -d --name cass1 -e OPS_IP=$OPS_IP abh1nav/cassandra:latest
sleep 30
SEED_IP=$(docker inspect -f '{{ .NetworkSettings.IPAddress }}' cass1)
for name in cass{2..5}; do
  echo "Starting node $name"
  docker run -d --name $name -e SEED=$SEED_IP -e OPS_IP=$OPS_IP abh1nav/cassandra:latest
  sleep 30
done
echo "Registering cluster with OpsCenter"
curl \
  http://$OPS_IP:8888/cluster-configs \
  -X POST \
  -d \
  "{
      \"cassandra\": {
        \"seed_hosts\": \"$SEED_IP\"
      },
      \"cassandra_metrics\": {},
      \"jmx\": {
        \"port\": \"7199\"
      }
  }" > /dev/null
echo "Go to http://$OPS_IP:8888/"

Manual Mode

OpsCenter

Skip this section if you don't want to run OpsCenter.

Pull the image and launch OpsCenter.

docker pull abh1nav/cassandra:latest
docker run -d --name opscenter abh1nav/opscenter:latest

Grab the OpsCenter IP:

OPS_IP=$(docker inspect -f '{{ .NetworkSettings.IPAddress }}' opscenter)

Single Node

Pull the image.

docker pull abh1nav/cassandra:latest

Launch the node

  • without OpsCenter:
docker run -d --name cass1 abh1nav/cassandra:latest
  • with OpsCenter:
docker run -d --name cass1 -e OPS_IP=$OPS_IP abh1nav/cassandra:latest

Grab the seed node's IP using:

SEED_IP=$(docker inspect -f '{{ .NetworkSettings.IPAddress }}' cass1)

Connect to it using CQLSH:

cqlsh $SEED_IP

Multiple Nodes

Follow the single node setup to get the first node running and keep track of its IP. Run the following to launch the other nodes in the cluster:

  • without OpsCenter:
for name in cass{2..5}; do
  echo "Starting node $name"
  docker run -d --name $name -e SEED=$SEED_IP abh1nav/cassandra:latest
  sleep 30
done
  • with OpsCenter:
for name in cass{2..5}; do
  echo "Starting node $name"
  docker run -d --name $name -e SEED=$SEED_IP -e OPS_IP=$OPS_IP abh1nav/cassandra:latest
  sleep 30
done

Once all the nodes are up, check cluster status using:

nodetool --host $SEED_IP status

or, if you installed OpsCenter, go to http://$OPS_IP:8888 and choose the "Add Existing Cluster option".

Docker Pull Command
Owner
abh1nav
Source Repository

Comments (3)
abh1nav
2 years ago

@moonsyim you can use "-p" to bind to specific IPs. For example, if eth0 is 192.168.1.10 and eth1 is 192.168.1.11, you can:
docker run -d --name cass1 -p 192.168.1.10:7199:7199 192.168.1.10:7000:7000 192.168.1.10:7001:7001 192.168.1.10:9160:9160 192.168.1.10:9042:9042 abh1nav/cassandra:latest

This will effectively bind cass1 to eth0. Then you can run:

SEED_IP=$(docker inspect -f '{{ .NetworkSettings.IPAddress }}' cass1)

docker run -d --name cass2 -e SEED=$SEED_IP -p 192.168.1.11:7199:7199 192.168.1.11:7000:7000 192.168.1.11:7001:7001 192.168.1.11:9160:9160 192.168.1.11:9042:9042 abh1nav/cassandra:latest

This will bind cass2 to eth1.

moonsyim
2 years ago

Hello

seriously I'd like to make 4 nodes Cassandra cluster on 2 servers like

1st Server : Container A, Container B

2st Server : Container C, Container D

Container A, Container C are seed node.

I'd like to make

Container A is linked (bridge) to 1st host eth0

Container B is linked (bridge) to 1st host eth1

Container C is linked (bridge) to 2nd host eth0

Container D is linked (bridge) to 2nd host eth1

but it looks like

Container A, B links to 1st node's eth0 all.

Container C, D links to 2nd node's eth0 all.

–net=host is not good option to me.

Do you have any good suggestion for 4 nodes (4 container) Cassandra cluster on 2 servers ?

lolgolflol
2 years ago

When I run OpsCenter and one node and then I have 2 container right. I do try create table and set data braaa. when I stop them(2 container) but I don't remove containers because I must to use data after all. but when I start container again these ip each container to change already so does not work. how should I do? I am rather newbie docker. thank you.