Get Started with TDengine Using Docker
You can install TDengine in a Docker container and perform some basic tests to verify its performance.
To install TDengine on your local machine instead of in a container, see Get Started with TDengine Using an Installation Package.
Before You Begin
- Install Docker. For more information, see the Docker website.
- Ensure that the network ports required by TDengine are not currently in use. For more information, see Network Port Requirements.
Procedure
-
Pull the latest TDengine image:
docker pull tdengine/tdengine:latest
noteYou can also pull a specific version of the image. For example:
docker pull tdengine/tdengine:3.3.0.0
-
Start a container with the following command:
docker run -d -p 6030:6030 -p 6041:6041 -p 6043-6060:6043-6060 -p 6043-6060:6043-6060/udp tdengine/tdengine
To persist data to your local machine, use the following command:
docker run -d -v <local-data-directory>:/var/lib/taos -v <local-log-directory>:/var/log/taos -p 6030:6030 -p 6041:6041 -p 6043-6060:6043-6060 -p 6043-6060:6043-6060/udp tdengine/tdengine
-
Verify that the container is running properly:
docker ps
-
Enter the container and open a shell:
docker exec -it <container-name> bash
You can now work with TDengine inside your container. For example, you can run the
taos
command to open the TDengine command-line interface.
What to Do Next
Test Data Ingestion
Your TDengine installation includes taosBenchmark, a tool specifically designed to test TDengine’s performance. taosBenchmark can simulate data generated by many devices with a wide range of configuration options so that you can perform tests on sample data similar to your real-world use cases. For more information about taosBenchmark, see taosBenchmark.
Perform the following steps to use taosBenchmark to test TDengine's ingestion performance in your container:
-
In a shell inside your container, run taosBenchmark with the default settings:
taosBenchmark -y
taosBenchmark automatically creates the test
database and the meters
supertable inside that database. This supertable contains 10,000 subtables, named d0
to d9999
, with each subtable containing 10,000 records. Each record includes the following four metrics:
ts
(timestamp), ranging from2017-07-14 10:40:00 000
to2017-07-14 10:40:09 999
current
voltage
phase
Each subtable also has the following two tags:
groupId
, ranging from1
to10
location
, indicating a city and state such asCalifornia.Campbell
orCalifornia.Cupertino
When the ingestion process is finished, taosBenchmark outputs the time taken to ingest the specified sample data. From this, you can estimate how TDengine would perform on your system in a production environment.
Test Data Querying
After inserting data with taosBenchmark as described above, you can use the TDengine CLI to test TDengine's query performance in your container:
-
Start the TDengine CLI:
taos
-
Query the total number of records in the
meters
supertable:SELECT COUNT(*) FROM test.meters;
-
Query the average, maximum, and minimum values of 100 million records:
SELECT AVG(current), MAX(voltage), MIN(phase) FROM test.meters;
-
Query the total number of records where the value of the
location
tag isCalifornia.SanFrancisco
:SELECT COUNT(*) FROM test.meters WHERE location = "California.SanFrancisco";
-
Query the average, maximum, and minimum values of all records where the value of the
groupId
tag is10
:SELECT AVG(current), MAX(voltage), MIN(phase) FROM test.meters WHERE groupId = 10;
-
Calculate the average, maximum, and minimum values for the
d1001
table every 10 seconds:SELECT _wstart, AVG(current), MAX(voltage), MIN(phase) FROM test.d1001 INTERVAL(10s);