About Routine Load
Routine load is a method using Apache Kafka, or in this lab, Redpanda, to continuously stream data into the database. The data is streamed into a Kafka topic, and a Routine Load job consumes the data into the database. More details on Routine Load are provided at the end of the lab.About shared-data
In systems that separate storage from compute, data is stored in low-cost reliable remote storage systems such as Amazon S3, Google Cloud Storage, Azure Blob Storage, and other S3-compatible storage like MinIO. Hot data is cached locally and when the cache is hit, the query performance is comparable to that of storage-compute coupled architecture. Compute nodes (CN) can be added or removed on demand within seconds. This architecture reduces storage costs, ensures better resource isolation, and provides elasticity and scalability. This tutorial covers:- Running the database, Redpanda, and MinIO with Docker Compose
- Using MinIO as the database storage layer
- Configuring the database for shared-data
- Adding a Routine Load job to consume data from Redpanda
- Configure Routine Load.
- Allow the reader to load data in a shared-data deployment and analyze that data.
- Provide the configuration details for shared-data deployments.
Prerequisites
Docker
- Docker
- 4 GB RAM assigned to Docker
- 20 GB free disk space assigned to Docker
SQL client
You can use the SQL client provided in the Docker environment, or use one on your system. Many MySQL-compatible clients will work, and this guide covers the configuration of DBeaver and MySQL Workbench.curl
curl is used to download the Compose file and the script to generate the data. Check to see if you have it installed by running curl or curl.exe at your OS prompt. If curl is not installed, get curl here.
MinIO AIStor license
This guide uses MinIO AIStor for object storage, which requires a license. A free tier license is sufficient. The instructions for acquiring a license are provided later in this guide.Python
Python 3 and the Python client for Apache Kafka,kafka-python, are required.
Terminology
FE
Frontend nodes are responsible for metadata management, client connection management, query planning, and query scheduling. Each FE stores and maintains a complete copy of metadata in its memory, which guarantees indiscriminate services among the FEs.CN
Compute Nodes are responsible for executing query plans in shared-data deployments.BE
Backend nodes are responsible for both data storage and executing query plans in shared-nothing deployments. Note This guide does not use BEs, this information is included here so that you understand the difference between BEs and CNs.Launch the database
To run the database with shared-data using Object Storage you need:- A frontend engine (FE)
- A compute node (CN)
- Object Storage
Download the lab files
docker-compose.yml
gen.py
gen.py is a script that uses the Python client for Apache Kafka to publish (produce) data to a Kafka topic. The script has been written with the address and port of the Redpanda container.
Acquire a MinIO AIStor license
MinIO AIStor requires a license to run. You can use an existing license, or you can request a new MinIO AIStor Free Tier license. To request a new MinIO AIStor Free Tier license, go to the MinIO AIStor pricing page and select Get Started under the Free tier to obtain a free license. The free tier license allows you to run MinIO AIStor on a single compute resource with one or more drives. Save the license file asminio.license in the same directory as the docker-compose.yml file. The Docker Compose file mounts minio.license into the MinIO AIStor container. Without a valid license, MinIO AIStor starts but denies all S3 operations.
Start the database, MinIO, and Redpanda
routineload-minio_mc-1 container will not show a health indicator, and it will exit once it is done configuring MinIO with the access key that the database will use. Wait for routineload-minio_mc-1 to exit with a 0 code and the rest of the services to be Healthy.
Run docker compose ps until the services are healthy:
Examine MinIO credentials
In order to use MinIO for Object Storage with the database, the database needs a MinIO access key. The access key was generated during the startup of the Docker services. To help you better understand the way that the database connects to MinIO you should verify that the key exists.Open the MinIO web UI
Browse to http://localhost:9001/console/identity The username and password are specified in the Docker compose file, and areminiouser and miniopassword. You should see that there is one access key. The Key is AAAAAAAAAAAAAAAAAAAA, you cannot see the secret in the MinIO Console, but it is in the Docker compose file and is BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB:

Create a bucket for your data
When you create a storage volume in the database you will specify theLOCATION for the data:
my-starrocks-bucket. Accept the defaults for the three listed options.
SQL Clients
These three clients are tested with this tutorial, you only need one:
- mysql CLI: You can run this from the Docker environment or your machine.
- DBeaver is available as a community version and a Pro version.
- MySQL Workbench
Configuring the client
mysql CLI The easiest way to use the mysql CLI is to run it from the containerstarrocks-fe:
docker compose commands must be run from the directory containing the docker-compose.yml file.
If you would like to install the mysql CLI expand mysql client install below:
mysql client install
- macOS: If you use Homebrew and do not need MySQL Server run
brew install mysql-client@8.0to install the CLI. - Linux: Check your repository system for the
mysqlclient. For example,yum install mariadb. - Microsoft Windows: Install the MySQL Community Server and run the provided client, or run
mysqlfrom WSL.
- Install DBeaver, and add a connection:

- Configure the port, IP, and username. Test the connection, and click Finish if the test succeeds:

- Install the MySQL Workbench, and add a connection.
- Configure the port, IP, and username and then test the connection:

- You will see warnings from the Workbench as it is checking for a specific MySQL version. You can ignore the warnings and when prompted, you can configure Workbench to stop displaying the warnings:

The database configuration for shared-data
At this point you have the database running, and you have MinIO running. The MinIO access key is used to connect the database and Minio. This is the part of theFE configuration that specifies that the database deployment will use shared data. This was added to the file fe.conf when Docker Compose created the deployment.
quickstart directory and looking at the end of the file:
Connect to the database with a SQL client
Tip Run this command from the directory containing thedocker-compose.yml file.
If you are using a client other than the mysql CLI, open that now.
Examine the storage volumes
Create a shared-data storage volume
Earlier you created a bucket in MinIO namedmy-starrocks-volume, and you verified that MinIO has an access key named AAAAAAAAAAAAAAAAAAAA. The following SQL will create a storage volume in the MionIO bucket using the access key and secret.
\G instead
of a semicolon. The \G causes the mysql CLI to render the query results vertically.
Many SQL clients do not interpret vertical formatting output, so you should replace \G with ;.
Set the default storage volume
Create a table
These SQL commands are run in your SQL client.quickstart is using the storage volume s3_volume:
Open the Redpanda Console
There will be no topics yet, a topic will be created in the next step. http://localhost:8080/overviewPublish data to a Redpanda topic
From a command shell in theroutineload/ folder run this command to generate data:
python3 in place of python in the command.
If you are missing kafka-python try:
Verify in the Redpanda Console
Navigate to http://localhost:8080/topics in the Redpanda Console, and you will see one topic namedtest2. Select that topic and then the Messages tab and you will see five messages matching the output of gen.py.
Consume the messages
In the database you will create a Routine Load job to:- Consume the messages from the Redpanda topic
test2 - Load those messages into the table
site_clicks
site_clicks table will be stored in MinIO.
Create a Routine Load job
Run this command in the SQL client to create the Routine Load job, the command will be explained in detail at the end of the lab.Verify the Routine Load job
- The state should be
RUNNING - The topic should be
test2and the broker should beredpanda:2092 - The statistics should show either 0 or 5 loaded rows depending on how soon you ran the
SHOW ROUTINE LOADcommand. If there are 0 loaded rows run it again.
Verify that data is stored in MinIO
Open MinIO http://localhost:9001/console/browser/ and verify that there are objects stored undermy-starrocks-bucket.
Query the data from the database
Publish additional data
Runninggen.py again will publish another five records to Redpanda.
Verify that data is added
Since the Routine Load job runs on a schedule (every 10 seconds by default), the data will be loaded within a few seconds.Configuration details
Now that you have experienced using the database with shared-data it is important to understand the configuration.CN configuration
The CN configuration used here is the default, as the CN is designed for shared-data use. The default configuration is shown below. You do not need to make any changes.FE configuration
The FE configuration is slightly different from the default as the FE must be configured to expect that data is stored in Object Storage rather than on local disks on BE nodes. Thedocker-compose.yml file generates the FE configuration in the command.
s3_. This prefix is used for all Amazon S3 compatible storage types (for example: S3, GCS, and MinIO). When using Azure Blob Storage the prefix is azure_.
run_mode=shared_data
This enables shared-data use.
cloud_native_storage_type=S3
This specifies whether S3 compatible storage or Azure Blob Storage is used. For MinIO this is always S3.
Details of CREATE storage volume
aws_s3_endpoint=minio:9000
The MinIO endpoint, including port number.
aws_s3_path=starrocks
The bucket name.
aws_s3_access_key=AAAAAAAAAAAAAAAAAAAA
The MinIO access key.
aws_s3_secret_key=BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
The MinIO access key secret.
aws_s3_use_instance_profile=false
When using MinIO an access key is used, and so instance profiles are not used with MinIO.
aws_s3_use_aws_sdk_default_behavior=false
When using MinIO this parameter is always set to false.
Notes on the Routine Load command
Routine Load takes many arguments. Only the ones used in this tutorial are described here, the rest will be linked to in the more information section.Parameters
CREATE ROUTINE LOAD ON are:
- database_name.job_name
- table_name
database_name is optional. In this lab, it is quickstart and is specified.
job_name is required, and is clicks
table_name is required, and is site_clicks
Job properties
Property format
JSON. The other valid formats are: CSV, JSON, and Avro. CSV is the default.
Property jsonpaths
Data source properties
kafka_broker_list
<kafka_broker_name_or_ip>:<broker_ port>. Multiple brokers are separated by commas.
kafka_topic
kafka_partitions and kafka_offsets
kafka_offset required for each kafka_partitions entry.
kafka_partitions is a list of one or more partitions to consume. If this property is not set, then all partitions are consumed.
kafka_offsets is a list of offsets, one for each partition listed in kafka_partitions. In this case the value is OFFSET_BEGINNING which causes all of the data to be consumed. The default is to only consume new data.
Summary
In this tutorial you:- Deployed the database, Reedpanda, and Minio in Docker
- Created a Routine Load job to consume data from a Kafka topic
- Learned how to configure a database Storage Volume that uses MinIO