Cassandra Up

I’ve always thought “Cassandra” was a particularly ill-omened name, so I went with the picture, not the logo.

Subtitle: How did I function before the Internet?

It was a bit painful, but I did it. A three node Cassandra cluster configured in docker-compose inside a CentOS VM running on Windows 10.

The volume configuration is wrong. I know this because I brought it down, then back up again and all my data was gone. This might have had something to do with the fact that I moved the .yaml file, which changed the docker-compose project while using the auto-allocate storage. I’ll point it somewhere explicitly, but not today.

For posterity, my first YAML file:

version: '3'
services:
    trio-seed:
        image: cassandra
        environment:
          - CASSANDRA_CLUSTER_NAME=trio 
            # - LOCAL_JMX=no -- allows out-of-container access to JMX, which nodetool uses
            # The alternative:
            # docker exec trio-seed nodetool status 
        ports:
          - 7000:7000
          - 9042:9042  # Native Transport (i.e. client)
          - 7199:7199  # JMX
          - 9160:9160  # Thrift
        volumes:
          - cass-dataA:/var/lib/cassandra
        networks:
          - cass-net
    # The seed node must be up-and-running, first, so give it some time
    trio-nodeB:
        image: cassandra
        command: /bin/bash -c "echo 'Waiting for seed node' && sleep 30 && docker-entrypoint.sh cassandra -f"
        environment:
          - CASSANDRA_CLUSTER_NAME=trio 
          - CASSANDRA_SEEDS=trio-seed
        depends_on:
          - trio-seed
        ports:
          - 9043:9042
        volumes:
          - cass-dataB:/var/lib/cassandra
        networks:
          - cass-net
    # Multiple nodes cannot join at the same time, so give it a different amount of time
    # nodeB is taking a long time to come up because it pauses inside startup:
    # JOINING: sleeping 30000 ms for pending range setup
    # make this YUGE
    trio-nodeC:
        image: cassandra
        command: /bin/bash -c "echo 'Waiting for seed node' && sleep 120 && docker-entrypoint.sh cassandra -f"
        environment:
          - CASSANDRA_CLUSTER_NAME=trio 
          - CASSANDRA_SEEDS=trio-seed
        depends_on:
          - trio-nodeB
        ports:
          - 9044:9042
        volumes:
          - cass-dataC:/var/lib/cassandra
        networks:
          - cass-net
volumes:
    cass-dataA:
        driver: local
    cass-dataB:
        driver: local
    cass-dataC:
        driver: local
networks:
    cass-net:
        name: cass-net

Update: The trick is noticing that docker-compose down has a “remove” step and that docker ps -a does not show the “downed” containers. This destroys their disk. I mapped explicit directories and all is fine.

One thought on “Cassandra Up

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: