01-docker.md 3.9 KB
Newer Older
1 2
---
sidebar_label: Docker
D
danielclow 已提交
3
title: Quick Install on Docker
4 5
---

D
danielclow 已提交
6
This document describes how to install TDengine in a Docker container and perform queries and inserts. To get started with TDengine in a non-containerized environment, see [Quick Install](../../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).
7

D
danielclow 已提交
8
## Run TDengine
9

D
danielclow 已提交
10
If Docker is already installed on your computer, run the following command:
11 12

```shell
D
danielclow 已提交
13
docker run -d -p 6030:6030 -p 6041:6041 -p 6043-6049:6043-6049 -p 6043-6049:6043-6049/udp tdengine/tdengine
14 15
```

D
danielclow 已提交
16
Note that TDengine Server 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.
17

D
danielclow 已提交
18
Run the following command to ensure that your container is running:
19 20 21 22 23

```shell
docker ps
```

D
danielclow 已提交
24
Enter the container and open the bash shell:
25 26 27 28 29

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

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

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

D
danielclow 已提交
34
## Insert Data into TDengine
35

D
danielclow 已提交
36
You can use the `taosBenchmark` tool included with TDengine to write test data into your deployment.
37

D
danielclow 已提交
38
To do so, run the following command:
39 40 41 42 43 44

   ```bash
   $ taosBenchmark
   
   ```

S
Sean Ely 已提交
45
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 `Campbell`, `Cupertino`, `Los Angeles`, `Mountain View`, `Palo Alto`, `San Diego`, `San Francisco`, `San Jose`, `Santa Clara` or `Sunnyvale`.
46

D
danielclow 已提交
47
   The `taosBenchmark` command creates a deployment with 100 million data points that you can use for testing purposes. The time required depends on the hardware specifications of the local system.
48

D
danielclow 已提交
49
   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).
50

51 52 53 54 55 56 57 58 59 60 61
## Open the TDengine CLI

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

```
$ taos

taos> 

```

D
danielclow 已提交
62
## Query Data in TDengine
63

D
danielclow 已提交
64
After using taosBenchmark to create your test deployment, you can run queries in the TDengine CLI to test its performance. For example:
65

66
From the TDengine CLI query the number of rows in the `meters` supertable:
67 68

```sql
69
select count(*) from test.meters;
70 71
```

D
danielclow 已提交
72
Query the average, maximum, and minimum values of all 100 million rows of data:
73 74

```sql
75
select avg(current), max(voltage), min(phase) from test.meters;
76 77
```

78
Query the number of rows whose `location` tag is `San Francisco`:
79 80

```sql
81
select count(*) from test.meters where location="San Francisco";
82 83
```

D
danielclow 已提交
84
Query the average, maximum, and minimum values of all rows whose `groupId` tag is `10`:
85 86

```sql
87
select avg(current), max(voltage), min(phase) from test.meters where groupId=10;
88 89
```

S
Sean Ely 已提交
90
Query the average, maximum, and minimum values for table `d10` in 1 second intervals:
91 92

```sql
S
Sean Ely 已提交
93
select first(ts), avg(current), max(voltage), min(phase) from test.d10 interval(1s);
94
```
S
Sean Ely 已提交
95
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/).
96

D
danielclow 已提交
97
## Additional Information
98

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