Database/Cassandra
[cassandra] docker + cassandra
bisi
2020. 4. 22. 18:19
분산시스템 구성을 위해 docker위에 cassandra를 셋팅하는 법에 대해서 알아보자.
1. docker에 cassandra download
docker pull cassandra:latest
|
2. 노드 0번 (seed node) 실행
docker run --name cassandra-node-0 --p 7000:7000 -p 7001:7001 -p 9042:9042 -p 9160:9160 -e CASSANDRA_CLUSTER_NAME=MyCluster -e CASSANDRA_ENDPOINT_SNITCH=GossipingPropertyFileSnitch -e CASSANDRA_DC=datacenter1 -d cassandra
|
3. seed 노드에 할당된 ip 확인
>docker inspect --format='{{ .NetworkSettings.IPAddress}}' cassandra-node-0
|
4. 노드 1번 실행
docker run --name cassandra-node-1 -p 17000:7000 -p 17001:7001 -p 19042:9042 -p 19160:9160 -e CASSANDRA_SEEDS="$(docker inspect --format='{{ .NetworkSettings.IPAddress}}' cassandra-node-0)" -e CASSANDRA_CLUSTER_NAME=MyCluster -e CASSANDRA_ENDPOINT_SNITCH=GossipingPropertyFileSnitch -e CASSANDRA_DC=datacenter1 -d cassandra
|
5. 노드 2번 실행
docker run --name equal-a-cassandra-node-2 -p 27000:7000 -p 27001:7001 -p 29042:9042 -p 29160:9160 -e CASSANDRA_SEEDS="$(docker inspect --format='{{ .NetworkSettings.IPAddress}}' cassandra-node-0)" -e CASSANDRA_CLUSTER_NAME=MyCluster -e CASSANDRA_ENDPOINT_SNITCH=GossipingPropertyFileSnitch -e CASSANDRA_DC=datacenter1 -d cassandra
|
6. 확인
- cql 실행
docker run -it -e CQLSH_HOST=$(docker inspect --format='{{ .NetworkSettings.IPAddress}}' cassandra-node-0) --name cassandra-client --entrypoint=cqlsh cassandra
|
- nodetool status 실행
docker exec -ti equal-a-cassandra-node-1 nodetool status
|
참고 사이트
https://hub.docker.com/_/cassandra/
https://gokhanatil.com/2018/02/build-a-cassandra-cluster-on-docker.html