01-docker.md 4.6 KB
Newer Older
1
---
D
danielclow 已提交
2
title: Quick Install on Docker
D
danielclow 已提交
3 4
sidebar_label: Docker
description: This document describes how to install TDengine in a Docker container and perform queries and inserts.
5 6
---

7 8
This document describes how to install TDengine in a Docker container and perform queries and inserts.

9
- The easiest way to explore TDengine is through [TDengine Cloud](http://cloud.tdengine.com).
10 11
- To get started with TDengine in a non-containerized environment, see [Quick Install from Package](../../get-started/package).
- If you want to view the source code, build TDengine yourself, or contribute to the project, see the [TDengine GitHub repository](https://github.com/taosdata/TDengine).
12

D
danielclow 已提交
13
## Run TDengine
14

15 16 17 18 19 20 21 22 23 24 25 26 27
If Docker is already installed on your computer, pull the latest TDengine Docker container image:

```shell
docker pull tdengine/tdengine:latest
```

Or the container image of specific version:

```shell
docker pull tdengine/tdengine:3.0.1.4
```

And then run the following command:
28 29

```shell
D
danielclow 已提交
30
docker run -d -p 6030:6030 -p 6041:6041 -p 6043-6049:6043-6049 -p 6043-6049:6043-6049/udp tdengine/tdengine
31 32
```

33
Note that TDengine Server 3.0 uses TCP port 6030. Port 6041 is used by taosAdapter for the REST API service. Ports 6043 through 6049 are used by taosAdapter for other connectors. You can open these ports as needed.
34

D
danielclow 已提交
35
Run the following command to ensure that your container is running:
36 37 38 39 40

```shell
docker ps
```

41
Enter the container and open the `bash` shell:
42 43 44 45 46

```shell
docker exec -it <container name> bash
```

D
danielclow 已提交
47
You can now access TDengine or run other Linux commands.
48

D
danielclow 已提交
49
Note: For information about installing docker, see the [official documentation](https://docs.docker.com/get-docker/).
50

51
## Open the TDengine CLI
52

53
On the container, run the following command to open the TDengine CLI:
54

55 56
```
$ taos
57

58
taos>
59

60
```
61

62
## Test data insert performance
63

64
After your TDengine Server is running normally, you can run the taosBenchmark utility to test its performance:
65

wafwerar's avatar
wafwerar 已提交
66
Start TDengine service and execute `taosBenchmark` (formerly named `taosdemo`) in a terminal.
67

68 69
```bash
taosBenchmark
70 71
```

72
This command creates the `meters` supertable in the `test` database. In the `meters` supertable, it then creates 10,000 subtables named `d0` to `d9999`. Each table has 10,000 rows and each row has four columns: `ts`, `current`, `voltage`, and `phase`. The timestamps of the data in these columns range from 2017-07-14 10:40:00 000 to 2017-07-14 10:40:09 999. Each table is randomly assigned a `groupId` tag from 1 to 10 and a `location` tag of either `California.Campbell`, `California.Cupertino`, `California.LosAngeles`, `California.MountainView`, `California.PaloAlto`, `California.SanDiego`, `California.SanFrancisco`, `California.SanJose`, `California.SantaClara` or `California.Sunnyvale`.
73 74

The `taosBenchmark` command creates a deployment with 100 million data points that you can use for testing purposes. The time required to create the deployment depends on your hardware. On most modern servers, the deployment is created in ten to twenty seconds.
75

76
You can customize the test deployment that taosBenchmark creates by specifying command-line parameters. For information about command-line parameters, run the `taosBenchmark --help` command. For more information about taosBenchmark, see [taosBenchmark](../../reference/taosbenchmark).
77

78
## Test data query performance
79

80
After using `taosBenchmark` to create your test deployment, you can run queries in the TDengine CLI to test its performance:
81

82
From the TDengine CLI (taos) query the number of rows in the `meters` supertable:
83 84

```sql
85
SELECT COUNT(*) FROM test.meters;
86 87
```

D
danielclow 已提交
88
Query the average, maximum, and minimum values of all 100 million rows of data:
89 90

```sql
91
SELECT AVG(current), MAX(voltage), MIN(phase) FROM test.meters;
92 93
```

94
Query the number of rows whose `location` tag is `California.SanFrancisco`:
95 96

```sql
97
SELECT COUNT(*) FROM test.meters WHERE location = "California.SanFrancisco";
98 99
```

D
danielclow 已提交
100
Query the average, maximum, and minimum values of all rows whose `groupId` tag is `10`:
101 102

```sql
103
SELECT AVG(current), MAX(voltage), MIN(phase) FROM test.meters WHERE groupId = 10;
104 105
```

106
Query the average, maximum, and minimum values for table `d10` in 10 second intervals:
107 108

```sql
109
SELECT FIRST(ts), AVG(current), MAX(voltage), MIN(phase) FROM test.d10 INTERVAL(10s);
110
```
111 112

In the query above you are selecting the first timestamp (ts) in the interval, another way of selecting this would be `\_wstart` which will give the start of the time window. For more information about windowed queries, see [Time-Series Extensions](../../taos-sql/distinguished/).
113

D
danielclow 已提交
114
## Additional Information
115

D
danielclow 已提交
116
For more information about deploying TDengine in a Docker environment, see [Using TDengine in Docker](../../reference/docker).