128 lines
4.4 KiB
Markdown
128 lines
4.4 KiB
Markdown
---
|
||
sidebar_label: Deploy in Docker
|
||
title: Get Started with TDengine Using Docker
|
||
description: Quickly experience TDengine’s efficient insertion and querying using Docker
|
||
slug: /get-started/deploy-in-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](../deploy-from-package/).
|
||
|
||
## Before You Begin
|
||
|
||
- Install Docker. For more information, see the [Docker website](https://www.docker.com/).
|
||
- Ensure that the network ports required by TDengine are not currently in use. For more information, see [Network Port Requirements](../../operations-and-maintenance/system-requirements/#network-port-requirements).
|
||
|
||
## Procedure
|
||
|
||
1. Pull the latest TDengine image:
|
||
|
||
```bash
|
||
docker pull tdengine/tdengine:latest
|
||
```
|
||
|
||
:::note
|
||
You can also pull a specific version of the image. For example:
|
||
|
||
```bash
|
||
docker pull tdengine/tdengine:3.3.0.0
|
||
```
|
||
|
||
:::
|
||
|
||
2. Start a container with the following command:
|
||
|
||
```bash
|
||
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:
|
||
|
||
```bash
|
||
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
|
||
```
|
||
|
||
3. Verify that the container is running properly:
|
||
|
||
```bash
|
||
docker ps
|
||
```
|
||
|
||
4. Enter the container and open a shell:
|
||
|
||
```bash
|
||
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](../../tdengine-reference/tools/taosbenchmark/).
|
||
|
||
Perform the following steps to use taosBenchmark to test TDengine's ingestion performance in your container:
|
||
|
||
1. In a shell inside your container, run taosBenchmark with the default settings:
|
||
|
||
```bash
|
||
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 from `2017-07-14 10:40:00 000` to `2017-07-14 10:40:09 999`
|
||
- `current`
|
||
- `voltage`
|
||
- `phase`
|
||
|
||
Each subtable also has the following two tags:
|
||
|
||
- `groupId`, ranging from `1` to `10`
|
||
- `location`, indicating a city and state such as `California.Campbell` or `California.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:
|
||
|
||
|
||
1. Start the TDengine CLI:
|
||
|
||
```bash
|
||
taos
|
||
```
|
||
|
||
2. Query the total number of records in the `meters` supertable:
|
||
|
||
```sql
|
||
SELECT COUNT(*) FROM test.meters;
|
||
```
|
||
|
||
3. Query the average, maximum, and minimum values of 100 million records:
|
||
|
||
```sql
|
||
SELECT AVG(current), MAX(voltage), MIN(phase) FROM test.meters;
|
||
```
|
||
|
||
4. Query the total number of records where the value of the `location` tag is `California.SanFrancisco`:
|
||
|
||
```sql
|
||
SELECT COUNT(*) FROM test.meters WHERE location = "California.SanFrancisco";
|
||
```
|
||
|
||
5. Query the average, maximum, and minimum values of all records where the value of the `groupId` tag is `10`:
|
||
|
||
```sql
|
||
SELECT AVG(current), MAX(voltage), MIN(phase) FROM test.meters WHERE groupId = 10;
|
||
```
|
||
|
||
6. Calculate the average, maximum, and minimum values for the `d1001` table every 10 seconds:
|
||
|
||
```sql
|
||
SELECT _wstart, AVG(current), MAX(voltage), MIN(phase) FROM test.d1001 INTERVAL(10s);
|
||
```
|