How to Set up Cassandra Cluster?


Userlevel 4
Badge

 

  1. Launch 3 instances of Cassandra with docker in Cluster mode: https://hub.docker.com/_/cassandra
docker run --name cas1 --net cluster -p 9042:9042 -e CASSANDRA_CLUSTER_NAME=MyCluster -e CASSANDRA_ENDPOINT_SNITCH=GossipingPropertyFileSnitch -e CASSANDRA_DC=datacenter1 -d cassandra:3.11.0

docker run --name cas2 --net cluster -e CASSANDRA_SEEDS="$(docker inspect --format='{{ .NetworkSettings.Networks.cluster.IPAddress }}' cas1)" -e CASSANDRA_CLUSTER_NAME=MyCluster -e CASSANDRA_ENDPOINT_SNITCH=GossipingPropertyFileSnitch -e CASSANDRA_DC=datacenter1 -d cassandra:3.11.0

docker run --name cas3 --net cluster -e CASSANDRA_SEEDS="$(docker inspect --format='{{ .NetworkSettings.Networks.cluster.IPAddress }}' cas1)" -e CASSANDRA_CLUSTER_NAME=MyCluster -e CASSANDRA_ENDPOINT_SNITCH=GossipingPropertyFileSnitch -e CASSANDRA_DC=datacenter2 -d cassandra:3.11.0

        2. Enter in the instance and create a database and tables. 

> cqlsh


CREATE KEYSPACE myKeyspace WITH REPLICATION = { 'class' : 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '2' } AND DURABLE_WRITES = true;CREATE TABLE myKeyspace.myTable (
part_num text,
commodity text,
abbreviation text,
empact_commodity_code text,
site text,
source text,
PRIMARY KEY (part_num, commodity)
) WITH CLUSTERING ORDER BY (commodity ASC)
AND read_repair_chance = 0.0
AND dclocal_read_repair_chance = 0.1
AND gc_grace_seconds = 864000
AND bloom_filter_fp_chance = 0.01
AND caching = { 'keys' : 'ALL', 'rows_per_partition' : 'NONE' }
AND comment = ''
AND compaction = { 'class' : 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold' : 32, 'min_threshold' : 4 }
AND compression = { 'chunk_length_in_kb' : 64, 'class' : 'org.apache.cassandra.io.compress.LZ4Compressor' }
AND default_time_to_live = 0
AND speculative_retry = '99PERCENTILE'
AND min_index_interval = 128
AND max_index_interval = 2048
AND crc_check_chance = 1.0
AND cdc = false
AND memtable_flush_period_in_ms = 0;

      3. Run an SDC docker container in the same network: 

docker run --restart on-failure -p 18630:18630 -d --name streamsets-dc —net cluster streamsets/datacollector dc

 


0 replies

Be the first to reply!

Reply