Created
February 15, 2018 03:15
-
-
Save alfredormz/20545f8a1fb09f532040ba4f80fff851 to your computer and use it in GitHub Desktop.
Running Cassandra Cluster on Docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker pull spotify/cassandra:cluster | |
docker volume create cassandra_data_c1 | |
docker volume create cassandra_data_c2 | |
docker volume create cassandra_data_c3 | |
#create tokens | |
python -c 'print([int(((2**64 / 3) * i) - 2**63) for i in range(3)])' | |
#[-9223372036854775808, -3074457345618258944, 3074457345618257920] | |
docker run -d -v cassandra_data_c1:/var/lib/cassandra \ | |
-e "CASSANDRA_TOKEN=-9223372036854775808" \ | |
--name c1 spotify/cassandra:cluster | |
# Get the IP address of the node | |
docker inspect -f '{{.NetworkSettings.IPAddress}}' c1 | |
#172.17.0.2 | |
docker run -d -v cassandra_data_c2:/var/lib/cassandra \ | |
-e "CASSANDRA_TOKEN=-3074457345618258603" \ | |
-e "CASSANDRA_SEEDS=172.17.0.2" \ | |
--name c2 spotify/cassandra:cluster | |
docker run -d -v cassandra_data_c3:/var/lib/cassandra \ | |
-e "CASSANDRA_TOKEN=3074457345618257920" \ | |
-e "CASSANDRA_SEEDS=172.17.0.2" \ | |
--name c3 spotify/cassandra:cluster | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment