Kafka and Scylla Lesson Now Available!
Learn More >

Lab 1 – Overview and Setup

9 min to complete

Lab 1 – Overview and Setup

In this lab, we’ll bring up a three-node cluster and demonstrate how the WRITE and READ look, in a cluster where our Replication Factor (RF) is set to 3. We’ll simulate a situation where some nodes are down and see how changing the Consistency Level affects the read and write operations and failure conditions in a Scylla cluster.

Note: In addition to the instructions provided in this document, which allow you to run the lab on a machine with Docker, you can find this lab in the Katacoda learning environment here. The Katacoda environment provides an interactive virtual machine where you can execute all the commands directly from your browser without the need to configure anything.

If you decide not to use the Katacoda platform and run docker on your own machine, please ensure that your environment meets the following prerequisites:

  1. Docker for Linux, Mac, or Windows. Please note that running Scylla in Docker is only recommended to evaluate and try Scylla. For best performance, a regular OS install is recommended.
  2. 3GB of RAM or greater for Docker.
  3. If you are using Linux, you will need docker-compose.
First, we’ll bring up a 3-node Scylla Docker cluster.
  • Set up a Docker Container with one node, called Node_X:
 docker run --name Node_X -d scylladb/scylla:4.3.0 
  • Create two more nodes, Node_Y and Node_Z, and add them to the cluster of Node_X. The command “$(docker inspect –format='{{ .NetworkSettings.IPAddress }}’ Node_X)” translates to the IP address of Node-X:
docker run --name Node_Y -d scylladb/scylla:4.3.0 --seeds="$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' Node_X)" 

docker run --name Node_Z -d scylladb/scylla:4.3.0 --seeds="$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' Node_X)" 
  • Wait a minute or so and check the node status: 
docker exec -it Node_Z nodetool status  

  • You’ll see that eventually, all the nodes have UN for status. U means up, and N means normal. Read more about Nodetool Status Here.

Once the nodes are up, and the cluster is set, we can use the CQL shell to create a table.

  • Run a CQL shell: 
docker exec -it Node_Z cqlsh 
  • Create a keyspace called “mykeyspace”, with a Replication Factor of three: 
CREATE KEYSPACE mykeyspace WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 3};
  • Next, create a table with three columns: user id, first name, and last name, and insert some data: 
use mykeyspace; 
CREATE TABLE users ( user_id int, fname text, lname text, PRIMARY KEY((user_id))); 
  • Insert into the newly created table two rows: 
insert into users(user_id, fname, lname) values (1, 'rick', 'sanchez'); 
insert into users(user_id, fname, lname) values (4, 'rust', 'cohle'); 
  • Read the table contents:
select * from users;

To summarize, we saw how to create a three-node cluster with RF=3, how to open a CQL Shell, create a table, insert data into it, and read the data. In the next topic, we will see what happens when nodes are down and how the Consistency Level impacts the read/write operations.