In this tutorial, you'll learn how to create a multi node Cassandra DB setup using Docker.
—
Facebook: / gokcedbsql
—
Video Transcript:
—
Hi guys, this is Abhi from Gokce DB. In this video, you are going to learn how to create a multi-node Cassandra setup using Docker. Let's start by using the Docker run command to create the first node on port 9042.
Use the Docker inspect command to get the IP Address of this first node. You can also use the Docker UI to check the status of this container. Next, we're going to create the second node on port 9043 and use the IP Address as a Cassandra seed.
Feel free to verify the status of both instances in the Docker UI. Now you can create the third node on port 9044 and use the IP Address of the first and the second node as Cassandra seeds if you look at the status of the third instance on the Docker UI. You'll see that it says exited that's because the first two nodes haven't successfully connected yet you can also use the Docker exact node tool status command to verify the status on the command line.
After restarting the third instance and waiting a few more minutes, now the status of the third instance says UJ which means UP and joining. Wait until the status changes to UN, which means UP and normal. Next use the Docker exec command to start the CQL shell and connect to one of the Cassandra instances.
I'm also going to create a key space called Cassandra underscore gauche DB with a replication factor of 3 using a network topology strategy. Finally, use the describe key spaces command to show all existing key spaces. There you have it.
Make sure you like, subscribe, and turn on the notification bell. Until next time.
// 3 node Cassandra setup listening on ports 9042, 9043, and 9044 for client requests
// Run the first node
docker run --name cassandra-1 -p 9042:9042 -d cassandra
INSTANCE1=$(docker inspect --format="{{ .NetworkSettings.IPAddress }}" cassandra-1)
echo "INSTANCE1: ${INSTANCE1}"
// Run the second node
docker run --name cassandra-2 -p 9043:9042 -d -e CASSANDRA_SEEDS=$INSTANCE1 cassandra
INSTANCE2=$(docker inspect --format="{{ .NetworkSettings.IPAddress }}" cassandra-2)
echo "INSTANCE2: ${INSTANCE2}"
// Run the third node
docker run --name cassandra-3 -p 9044:9042 -d -e CASSANDRA_SEEDS=$INSTANCE1,$INSTANCE2 cassandra
INSTANCE3=$(docker inspect --format="{{ .NetworkSettings.IPAddress }}" cassandra-3)
echo "INSTANCE3: ${INSTANCE3}"
// Check Status of Nodes
docker exec cassandra-3 nodetool status
// Start cqlsh shell
docker exec -it cassandra-1 cqlsh
// Create a keyspace with replication factor of 3 using NetworkTopologyStrategy
CREATE KEYSPACE cassandra_gokcedb
WITH REPLICATION = {
'class' : 'NetworkTopologyStrategy',
'datacenter1' : 3
};
// Show all existing keyspaces
DESCRIBE keyspaces;
Смотрите видео How To: Multi Node Cassandra Setup In Docker (2 Min) онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал Gokce DB 29 Июнь 2022. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 2,374 раз и оно понравилось 31 посетителям.