The objective of this scenario is to demonstrate how to create a CockroachDB cluster running under Docker Compose. Then, once the cluster is created, you'll seed it with data so that you make queries against the data.
What is CockroachDB?
CockroachDB is an distributed SQL database. It's intended to run in a cluster across many machines. You can read up on the details of how CockroachDB uses key-value architecture to store data, but allows the data to be reported via SQL queries.
This video provides an informative explanation of the technology.
What you'll be doing
In this scenario you're going to create a CockroachDB cluster along with a database named,
blogs. You'll seed the
blogs database with random data.
In order to seed the database you'll use a Node.JS/TypeScript application designed especially for this scenario. The application defines two entities,
Writer entity has the fields:
BlogEntry entity has the fields:
Writer will have many
The Node.Js application uses TypeOrm to intermediate between the Node.JS/TypeScript code and CockroachDB.
This scenario is divided into the following steps.
- Step 1 - Get the source code
- Step 2 - Create the CockroachDB cluster
- Step 3 - Create the CockroachDB database
- Step 4 - Seed the database with data
- Step 5 - Run a query against the seed data
Executing command line instructions
This scenario is completely interactive. The instructions you'll be given will be executed directly in the terminal window that is embedded directly in the Katacoda interactive learning environment. In the steps to come, when you see a command line instruction with a black background and check mark at the end, like so:
just click on it and the command will execute in the interative terminal window.
Congratulations! You've completed the scenario, Running a CockroachDB Cluster Under Docker Compose.
In this scenario you:
- Got the source code from GitHub
- Created the CockroachDB cluster
- Created the CockroachDB database
- Seeded the database with data
- Viewed the CockroachDB and HAProxy Admin websites for the cluster you created
- Ran a SQL query against the seed data in the CockroachDB database that produced ordered results
Read more about CockroachDB.
Running a CockroachDB Cluster Under Docker Compose
Get the source code
The objective of this lesson is to clone the source code for the data seeding application from GitHub into the Katacoda interactive learning environment
Step 1: Clone the scenario's source code into the Katacoda interactive learning environment.
git clone https://github.com/reselbob/simplecockroachdb.git
Next: Create the CockroachDB cluster