Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fee081c7
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
fee081c7
编写于
8月 19, 2022
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' into feature/3.0_interval_hash_optimize
上级
a9fcc12c
48a2510a
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
243 addition
and
225 deletion
+243
-225
docs/zh/14-reference/11-docker/index.md
docs/zh/14-reference/11-docker/index.md
+215
-216
source/libs/transport/src/thttp.c
source/libs/transport/src/thttp.c
+25
-6
tools/CMakeLists.txt
tools/CMakeLists.txt
+3
-3
未找到文件。
docs/zh/14-reference/11-docker/index.md
浏览文件 @
fee081c7
...
@@ -25,10 +25,11 @@ curl -u root:taosdata -d "show databases" localhost:6041/rest/sql
...
@@ -25,10 +25,11 @@ curl -u root:taosdata -d "show databases" localhost:6041/rest/sql
$
docker
exec
-it
tdengine taos
$
docker
exec
-it
tdengine taos
taos> show databases
;
taos> show databases
;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache
(
MB
)
| blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status |
name |
====================================================================================================================================================================================================================================================================================
=================================
log | 2022-01-17 13:57:22.270 | 10 | 1 | 1 | 1 | 10 | 30 | 1 | 3 | 100 | 4096 | 1 | 3000 | 2 | 0 | us | 0 | ready |
information_schema |
Query OK, 1 row
(
s
)
in
set
(
0.002843s
)
performance_schema |
Query OK, 2 rows
in
database
(
0.033802s
)
```
```
因为运行在容器中的 TDengine 服务端使用容器的 hostname 建立连接,使用 taos shell 或者各种连接器(例如 JDBC-JNI)从容器外访问容器内的 TDengine 比较复杂,所以上述方式是访问容器中 TDengine 服务的最简单的方法,适用于一些简单场景。如果在一些复杂场景下想要从容器化使用 taos shell 或者各种连接器访问容器中的 TDengine 服务,请参考下一节。
因为运行在容器中的 TDengine 服务端使用容器的 hostname 建立连接,使用 taos shell 或者各种连接器(例如 JDBC-JNI)从容器外访问容器内的 TDengine 比较复杂,所以上述方式是访问容器中 TDengine 服务的最简单的方法,适用于一些简单场景。如果在一些复杂场景下想要从容器化使用 taos shell 或者各种连接器访问容器中的 TDengine 服务,请参考下一节。
...
@@ -45,10 +46,11 @@ docker run -d --name tdengine --network host tdengine/tdengine
...
@@ -45,10 +46,11 @@ docker run -d --name tdengine --network host tdengine/tdengine
$
taos
$
taos
taos> show dnodes
;
taos> show dnodes
;
id
| end_point | vnodes | cores | status | role | create_time | offline reason |
id
| endpoint | vnodes | support_vnodes | status | create_time | note |
======================================================================================================================================
=================================================================================================================================================
1 | myhost:6030 | 1 | 8 | ready | any | 2022-01-17 22:10:32.619 | |
1 | vm98:6030 | 0 | 32 | ready | 2022-08-19 14:50:05.337 | |
Query OK, 1 row
(
s
)
in
set
(
0.003233s
)
Query OK, 1 rows
in
database
(
0.010654s
)
```
```
## 以指定的 hostname 和 port 启动 TDengine
## 以指定的 hostname 和 port 启动 TDengine
...
@@ -59,12 +61,13 @@ Query OK, 1 row(s) in set (0.003233s)
...
@@ -59,12 +61,13 @@ Query OK, 1 row(s) in set (0.003233s)
docker run
-d
\
docker run
-d
\
--name
tdengine
\
--name
tdengine
\
-e
TAOS_FQDN
=
tdengine
\
-e
TAOS_FQDN
=
tdengine
\
-p
6030-6049:6030-6049
\
-p
6030:6030
\
-p
6030-6049:6030-6049/udp
\
-p
6041-6049:6041-6049
\
-p
6041-6049:6041-6049/udp
\
tdengine/tdengine
tdengine/tdengine
```
```
上面的命令在容器中启动一个 TDengine 服务,其所监听的 hostname 为 tdengine ,并将容器的 6030
到 6049 端口段映射到主机的 6030 到 6049 端口段 (tcp 和 udp 都需要映射)。如果主机上该端口段已经被占用,可以修改上述命令指定一个主机上空闲的端口段。如果
`rpcForceTcp`
被设置为
`1`
,可以只映射 tcp 协议
。
上面的命令在容器中启动一个 TDengine 服务,其所监听的 hostname 为 tdengine ,并将容器的 6030
端口映射到主机的 6030 端口(TCP,只能映射主机 6030 端口),6041-6049 端口段映射到主机 6041-6049 端口段(tcp 和 udp 都需要映射,如果主机上该端口段已经被占用,可以修改上述命令指定一个主机上空闲的端口段)
。
接下来,要确保 "tdengine" 这个 hostname 在
`/etc/hosts`
中可解析。
接下来,要确保 "tdengine" 这个 hostname 在
`/etc/hosts`
中可解析。
...
@@ -103,9 +106,9 @@ taos -h tdengine -P 6030
...
@@ -103,9 +106,9 @@ taos -h tdengine -P 6030
3.
在同一网络上的另一容器中启动 TDengine 客户端
3.
在同一网络上的另一容器中启动 TDengine 客户端
```
shell
```
shell
docker run
--rm
-it
--network
td-net
-e
TAOS_FIRST_EP
=
tdengine
tdengine/tdengine taos
docker run
--rm
-it
--network
td-net
-e
TAOS_FIRST_EP
=
tdengine
--entrypoint
=
taos tdengine/tdengine
# or
# or
#docker run --rm -it --network td-net -
e tdengine/tdengine taos
-h tdengine
#docker run --rm -it --network td-net -
-entrypoint=taos tdengine/tdengine
-h tdengine
```
```
## 在容器中启动客户端应用
## 在容器中启动客户端应用
...
@@ -115,7 +118,7 @@ taos -h tdengine -P 6030
...
@@ -115,7 +118,7 @@ taos -h tdengine -P 6030
```
docker
```
docker
FROM
ubuntu:20.04
FROM
ubuntu:20.04
RUN
apt-get update
&&
apt-get
install
-y
wget
RUN
apt-get update
&&
apt-get
install
-y
wget
ENV
TDENGINE_VERSION=
2.4
.0.0
ENV
TDENGINE_VERSION=
3.0
.0.0
RUN
wget
-c
https://www.taosdata.com/assets-download/TDengine-client-
${
TDENGINE_VERSION
}
-Linux-x64
.tar.gz
\
RUN
wget
-c
https://www.taosdata.com/assets-download/TDengine-client-
${
TDENGINE_VERSION
}
-Linux-x64
.tar.gz
\
&&
tar
xvf TDengine-client-
${
TDENGINE_VERSION
}
-Linux-x64
.tar.gz
\
&&
tar
xvf TDengine-client-
${
TDENGINE_VERSION
}
-Linux-x64
.tar.gz
\
&&
cd
TDengine-client-
${
TDENGINE_VERSION
}
\
&&
cd
TDengine-client-
${
TDENGINE_VERSION
}
\
...
@@ -129,6 +132,14 @@ RUN wget -c https://www.taosdata.com/assets-download/TDengine-client-${TDENGINE_
...
@@ -129,6 +132,14 @@ RUN wget -c https://www.taosdata.com/assets-download/TDengine-client-${TDENGINE_
以下是一个 go 应用程序的示例:
以下是一个 go 应用程序的示例:
*
创建 go mod 项目:
```
bash
go mod init app
```
*
创建 main.go:
```
go
```
go
/*
/*
* In this test program, we'll create a database and insert 4 records then select out.
* In this test program, we'll create a database and insert 4 records then select out.
...
@@ -212,12 +223,18 @@ func checkErr(err error, prompt string) {
...
@@ -212,12 +223,18 @@ func checkErr(err error, prompt string) {
}
}
```
```
如下是完整版本的 dockerfile
*
更新 go mod
```
docker
```
bash
FROM
golang:1.17.6-buster as builder
go mod tidy
ENV
TDENGINE_VERSION=2.4.0.0
```
RUN
wget
-c
https://www.taosdata.com/assets-download/TDengine-client-
${
TDENGINE_VERSION
}
-Linux-x64
.tar.gz
\
如下是完整版本的 dockerfile:
```
dockerfile
FROM
golang:1.19.0-buster as builder
ENV
TDENGINE_VERSION=3.0.0.0
RUN
wget
-c
https://www.taosdata.com/assets-download/3.0/TDengine-client-
${
TDENGINE_VERSION
}
-Linux-x64
.tar.gz
\
&&
tar
xvf TDengine-client-
${
TDENGINE_VERSION
}
-Linux-x64
.tar.gz
\
&&
tar
xvf TDengine-client-
${
TDENGINE_VERSION
}
-Linux-x64
.tar.gz
\
&&
cd
TDengine-client-
${
TDENGINE_VERSION
}
\
&&
cd
TDengine-client-
${
TDENGINE_VERSION
}
\
&&
./install_client.sh
\
&&
./install_client.sh
\
...
@@ -232,8 +249,8 @@ RUN go build
...
@@ -232,8 +249,8 @@ RUN go build
FROM
ubuntu:20.04
FROM
ubuntu:20.04
RUN
apt-get update
&&
apt-get
install
-y
wget
RUN
apt-get update
&&
apt-get
install
-y
wget
ENV
TDENGINE_VERSION=
2.4
.0.0
ENV
TDENGINE_VERSION=
3.0
.0.0
RUN
wget
-c
https://www.taosdata.com/assets-download/TDengine-client-
${
TDENGINE_VERSION
}
-Linux-x64
.tar.gz
\
RUN
wget
-c
https://www.taosdata.com/assets-download/
3.0/
TDengine-client-
${
TDENGINE_VERSION
}
-Linux-x64
.tar.gz
\
&&
tar
xvf TDengine-client-
${
TDENGINE_VERSION
}
-Linux-x64
.tar.gz
\
&&
tar
xvf TDengine-client-
${
TDENGINE_VERSION
}
-Linux-x64
.tar.gz
\
&&
cd
TDengine-client-
${
TDENGINE_VERSION
}
\
&&
cd
TDengine-client-
${
TDENGINE_VERSION
}
\
&&
./install_client.sh
\
&&
./install_client.sh
\
...
@@ -248,46 +265,32 @@ CMD ["app"]
...
@@ -248,46 +265,32 @@ CMD ["app"]
目前我们已经有了
`main.go`
,
`go.mod`
,
`go.sum`
,
`app.dockerfile`
, 现在可以构建出这个应用程序并在
`td-net`
网络上启动它
目前我们已经有了
`main.go`
,
`go.mod`
,
`go.sum`
,
`app.dockerfile`
, 现在可以构建出这个应用程序并在
`td-net`
网络上启动它
```
shell
```
shell
$
docker build
-t
app
-f
app.dockerfile
$
docker build
-t
app
-f
app.dockerfile
.
$
docker run
--rm
--network
td-net app
-h
tdengine
-p
6030
$
docker run
--rm
--network
td-net app
app
-h
tdengine
-p
6030
=============
args parse result:
=============
=============
args parse result:
=============
hostName: tdengine
hostName: tdengine
serverPort: 6030
serverPort: 6030
usr: root
usr: root
password: taosdata
password: taosdata
================================================
================================================
2022-01-17 15:56:55.48 +0000 UTC 0
2022-08-19 07:43:51.68 +0000 UTC 0
2022-01-17 15:56:56.48 +0000 UTC 1
2022-08-19 07:43:52.68 +0000 UTC 1
2022-01-17 15:56:57.48 +0000 UTC 2
2022-08-19 07:43:53.68 +0000 UTC 2
2022-01-17 15:56:58.48 +0000 UTC 3
2022-08-19 07:43:54.68 +0000 UTC 3
2022-01-17 15:58:01.842 +0000 UTC 0
2022-01-17 15:58:02.842 +0000 UTC 1
2022-01-17 15:58:03.842 +0000 UTC 2
2022-01-17 15:58:04.842 +0000 UTC 3
2022-01-18 01:43:48.029 +0000 UTC 0
2022-01-18 01:43:49.029 +0000 UTC 1
2022-01-18 01:43:50.029 +0000 UTC 2
2022-01-18 01:43:51.029 +0000 UTC 3
```
```
## 用 docker-compose 启动 TDengine 集群
## 用 docker-compose 启动 TDengine 集群
1.
如下 docker-compose 文件启动一个
2 副本、2 管理节点、2 数据节点以及 1 个 arbitrator 的
TDengine 集群。
1.
如下 docker-compose 文件启动一个
三节点
TDengine 集群。
```
docker
```
yml
version: "3"
version
:
"
3"
services:
services
:
arbitrator:
image: tdengine/tdengine:$VERSION
command: tarbitrator
td-1
:
td-1
:
image
:
tdengine/tdengine:$VERSION
image
:
tdengine/tdengine:$VERSION
environment
:
environment
:
TAOS_FQDN
:
"
td-1"
TAOS_FQDN
:
"
td-1"
TAOS_FIRST_EP
:
"
td-1"
TAOS_FIRST_EP
:
"
td-1"
TAOS_NUM_OF_MNODES: "2"
TAOS_REPLICA: "2"
TAOS_ARBITRATOR: arbitrator:6042
volumes
:
volumes
:
-
taosdata-td1:/var/lib/taos/
-
taosdata-td1:/var/lib/taos/
-
taoslog-td1:/var/log/taos/
-
taoslog-td1:/var/log/taos/
...
@@ -296,65 +299,78 @@ password: taosdata
...
@@ -296,65 +299,78 @@ password: taosdata
environment
:
environment
:
TAOS_FQDN
:
"
td-2"
TAOS_FQDN
:
"
td-2"
TAOS_FIRST_EP
:
"
td-1"
TAOS_FIRST_EP
:
"
td-1"
TAOS_NUM_OF_MNODES: "2"
TAOS_REPLICA: "2"
TAOS_ARBITRATOR: arbitrator:6042
volumes
:
volumes
:
-
taosdata-td2:/var/lib/taos/
-
taosdata-td2:/var/lib/taos/
-
taoslog-td2:/var/log/taos/
-
taoslog-td2:/var/log/taos/
td-3
:
image
:
tdengine/tdengine:$VERSION
environment
:
TAOS_FQDN
:
"
td-3"
TAOS_FIRST_EP
:
"
td-1"
volumes
:
volumes
:
-
taosdata-td3:/var/lib/taos/
-
taoslog-td3:/var/log/taos/
volumes
:
taosdata-td1
:
taosdata-td1
:
taoslog-td1
:
taoslog-td1
:
taosdata-td2
:
taosdata-td2
:
taoslog-td2
:
taoslog-td2
:
```
taosdata-td3
:
taoslog-td3
:
```
:::note
:::note
-
`VERSION`
环境变量被用来设置 tdengine image tag
*
`VERSION`
环境变量被用来设置 tdengine image tag
-
在新创建的实例上必须设置
`TAOS_FIRST_EP`
以使其能够加入 TDengine 集群;如果有高可用需求,则需要同时使用
`TAOS_SECOND_EP`
*
在新创建的实例上必须设置
`TAOS_FIRST_EP`
以使其能够加入 TDengine 集群;如果有高可用需求,则需要同时使用
`TAOS_SECOND_EP`
-
`TAOS_REPLICA`
用来设置缺省的数据库副本数量,其取值范围为[1,3]
:::
在双副本环境下,推荐使用 arbitrator, 用 TAOS_ARBITRATOR 来设置
:::
2.
启动集群
2.
启动集群
```
shell
```
shell
$ VERSION
=
2.4.0.0 docker-compose up
-d
$ VERSION
=
3.0.0.0 docker-compose up
-d
Creating network
"test_default"
with the default driver
Creating network
"test-docker_default"
with the default driver
Creating volume
"test_taosdata-td1"
with default driver
Creating volume
"test-docker_taosdata-td1"
with default driver
Creating volume
"test_taoslog-td1"
with default driver
Creating volume
"test-docker_taoslog-td1"
with default driver
Creating volume
"test_taosdata-td2"
with default driver
Creating volume
"test-docker_taosdata-td2"
with default driver
Creating volume
"test_taoslog-td2"
with default driver
Creating volume
"test-docker_taoslog-td2"
with default driver
Creating test_td-1_1 ...
done
Creating volume
"test-docker_taosdata-td3"
with default driver
Creating test_arbitrator_1 ...
done
Creating volume
"test-docker_taoslog-td3"
with default driver
Creating test_td-2_1 ...
done
```
Creating test-docker_td-3_1 ...
done
Creating test-docker_td-1_1 ...
done
Creating test-docker_td-2_1 ...
done
```
3.
查看节点状态
3.
查看节点状态
```
shell
```
shell
$
docker-compose ps
docker-compose ps
Name Command State Ports
Name Command State Ports
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_arbitrator_1 /usr/bin/entrypoint.sh
tar
... Up 6030/tcp, 6031/tcp, 6032/tcp, 6033/tcp, 6034/tcp, 6035/tcp, 6036/tcp, 6037/tcp, 6038/tcp, 6039/tcp, 6040/tcp, 6041/tcp, 6042/tcp
-------------------------------------------------------------------
test_td-1_1 /usr/bin/entrypoint.sh taosd Up 6030/tcp, 6031/tcp, 6032/tcp, 6033/tcp, 6034/tcp, 6035/tcp, 6036/tcp, 6037/tcp, 6038/tcp, 6039/tcp, 6040/tcp, 6041/tcp, 6042/tcp
test-docker_td-1_1 /tini
--
/usr/bin/entrypoi ... Up
test_td-2_1 /usr/bin/entrypoint.sh taosd Up 6030/tcp, 6031/tcp, 6032/tcp, 6033/tcp, 6034/tcp, 6035/tcp, 6036/tcp, 6037/tcp, 6038/tcp, 6039/tcp, 6040/tcp, 6041/tcp, 6042/tcp
test-docker_td-2_1 /tini
--
/usr/bin/entrypoi ... Up
```
test-docker_td-3_1 /tini
--
/usr/bin/entrypoi ... Up
```
4.
用 taos shell 查看 dnodes
4.
用 taos shell 查看 dnodes
```
shell
```
shell
$
docker-compose
exec
td-1 taos
-s
"show dnodes"
$
docker-compose
exec
td-1 taos
-s
"show dnodes"
taos> show dnodes
id
| end_point | vnodes | cores | status | role | create_time | offline reason |
taos> show dnodes
======================================================================================================================================
1 | td-1:6030 | 1 | 8 | ready | any | 2022-01-18 02:47:42.871 | |
id
| endpoint | vnodes | support_vnodes | status | create_time | note |
2 | td-2:6030 | 0 | 8 | ready | any | 2022-01-18 02:47:43.518 | |
=================================================================================================================================================
0 | arbitrator:6042 | 0 | 0 | ready | arb | 2022-01-18 02:47:43.633 | - |
Query OK, 3 row
(
s
)
in
set
(
0.000811s
)
1 | td-1:6030 | 0 | 32 | ready | 2022-08-19 07:57:29.971 | |
```
2 | td-2:6030 | 0 | 32 | ready | 2022-08-19 07:57:31.415 | |
3 | td-3:6030 | 0 | 32 | ready | 2022-08-19 07:57:31.417 | |
Query OK, 3 rows
in
database
(
0.021262s
)
```
## taosAdapter
## taosAdapter
...
@@ -362,29 +378,23 @@ password: taosdata
...
@@ -362,29 +378,23 @@ password: taosdata
2.
同时为了部署灵活起见,可以在独立的容器中启动 taosAdapter
2.
同时为了部署灵活起见,可以在独立的容器中启动 taosAdapter
```
docker
```
docker
services:
services:
# ...
# ...
adapter:
adapter:
image: tdengine/tdengine:$VERSION
image: tdengine/tdengine:$VERSION
command: taosadapter
command: taosadapter
```
```
如果要部署多个 taosAdapter 来提高吞吐量并提供高可用性,推荐配置方式为使用 nginx 等反向代理来提供统一的访问入口。具体配置方法请参考 nginx 的官方文档。如下是示例:
如果要部署多个 taosAdapter 来提高吞吐量并提供高可用性,推荐配置方式为使用 nginx 等反向代理来提供统一的访问入口。具体配置方法请参考 nginx 的官方文档。如下是示例:
```
docker
```
yml
version: "3"
version
:
"
3"
networks:
networks
:
inter
:
inter
:
api:
services:
services
:
arbitrator:
image: tdengine/tdengine:$VERSION
command: tarbitrator
networks:
- inter
td-1
:
td-1
:
image
:
tdengine/tdengine:$VERSION
image
:
tdengine/tdengine:$VERSION
networks
:
networks
:
...
@@ -392,9 +402,6 @@ password: taosdata
...
@@ -392,9 +402,6 @@ password: taosdata
environment
:
environment
:
TAOS_FQDN
:
"
td-1"
TAOS_FQDN
:
"
td-1"
TAOS_FIRST_EP
:
"
td-1"
TAOS_FIRST_EP
:
"
td-1"
TAOS_NUM_OF_MNODES: "2"
TAOS_REPLICA: "2"
TAOS_ARBITRATOR: arbitrator:6042
volumes
:
volumes
:
-
taosdata-td1:/var/lib/taos/
-
taosdata-td1:/var/lib/taos/
-
taoslog-td1:/var/log/taos/
-
taoslog-td1:/var/log/taos/
...
@@ -405,15 +412,12 @@ password: taosdata
...
@@ -405,15 +412,12 @@ password: taosdata
environment
:
environment
:
TAOS_FQDN
:
"
td-2"
TAOS_FQDN
:
"
td-2"
TAOS_FIRST_EP
:
"
td-1"
TAOS_FIRST_EP
:
"
td-1"
TAOS_NUM_OF_MNODES: "2"
TAOS_REPLICA: "2"
TAOS_ARBITRATOR: arbitrator:6042
volumes
:
volumes
:
-
taosdata-td2:/var/lib/taos/
-
taosdata-td2:/var/lib/taos/
-
taoslog-td2:/var/log/taos/
-
taoslog-td2:/var/log/taos/
adapter
:
adapter
:
image
:
tdengine/tdengine:$VERSION
image
:
tdengine/tdengine:$VERSION
command: taosadapter
entrypoint
:
"
taosadapter"
networks
:
networks
:
-
inter
-
inter
environment
:
environment
:
...
@@ -427,7 +431,6 @@ password: taosdata
...
@@ -427,7 +431,6 @@ password: taosdata
-
adapter
-
adapter
networks
:
networks
:
-
inter
-
inter
- api
ports
:
ports
:
-
6041:6041
-
6041:6041
-
6044:6044/udp
-
6044:6044/udp
...
@@ -443,12 +446,12 @@ password: taosdata
...
@@ -443,12 +446,12 @@ password: taosdata
>>
/etc/nginx/nginx.conf;cat
/etc/nginx/nginx.conf;
>>
/etc/nginx/nginx.conf;cat
/etc/nginx/nginx.conf;
nginx
-g
'daemon
off;'"
,
nginx
-g
'daemon
off;'"
,
]
]
volumes:
volumes
:
taosdata-td1
:
taosdata-td1
:
taoslog-td1
:
taoslog-td1
:
taosdata-td2
:
taosdata-td2
:
taoslog-td2
:
taoslog-td2
:
```
```
## 使用 docker swarm 部署
## 使用 docker swarm 部署
...
@@ -457,14 +460,12 @@ password: taosdata
...
@@ -457,14 +460,12 @@ password: taosdata
docker-compose 文件可以参考上节。下面是使用 docker swarm 启动 TDengine 的命令:
docker-compose 文件可以参考上节。下面是使用 docker swarm 启动 TDengine 的命令:
```
shell
```
shell
$ VERSION
=
2.4
.0 docker stack deploy
-c
docker-compose.yml taos
$ VERSION
=
3.0.0
.0 docker stack deploy
-c
docker-compose.yml taos
Creating network taos_inter
Creating network taos_inter
Creating network taos_api
Creating service taos_nginx
Creating service taos_arbitrator
Creating service taos_td-1
Creating service taos_td-1
Creating service taos_td-2
Creating service taos_td-2
Creating service taos_adapter
Creating service taos_adapter
Creating service taos_nginx
```
```
查看和管理
查看和管理
...
@@ -472,24 +473,22 @@ Creating service taos_nginx
...
@@ -472,24 +473,22 @@ Creating service taos_nginx
```
shell
```
shell
$
docker stack ps taos
$
docker stack ps taos
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
79ni8temw59n taos_nginx.1 nginx:latest TM1701 Running Running about a minute ago
7m3sbf532bqp taos_adapter.1 tdengine/tdengine:3.0.0.0 vm98 Running Running about a minute ago
3e94u72msiyg taos_adapter.1 tdengine/tdengine:2.4.0 TM1702 Running Running 56 seconds ago
pj403n6ofmmh taos_adapter.2 tdengine/tdengine:3.0.0.0 vm98 Running Running about a minute ago
100amjkwzsc6 taos_td-2.1 tdengine/tdengine:2.4.0 TM1703 Running Running about a minute ago
rxqfwsyk5q1h taos_adapter.3 tdengine/tdengine:3.0.0.0 vm98 Running Running about a minute ago
pkjehr2vvaaa taos_td-1.1 tdengine/tdengine:2.4.0 TM1704 Running Running 2 minutes ago
qj40lpxr40oc taos_adapter.4 tdengine/tdengine:3.0.0.0 vm98 Running Running about a minute ago
tpzvgpsr1qkt taos_arbitrator.1 tdengine/tdengine:2.4.0 TM1705 Running Running 2 minutes ago
oe3455ulxpze taos_nginx.1 nginx:latest vm98 Running Running about a minute ago
rvss3g5yg6fa taos_adapter.2 tdengine/tdengine:2.4.0 TM1706 Running Running 56 seconds ago
o0tsg70nrrc6 taos_td-1.1 tdengine/tdengine:3.0.0.0 vm98 Running Running about a minute ago
i2augxamfllf taos_adapter.3 tdengine/tdengine:2.4.0 TM1707 Running Running 56 seconds ago
q5m1oxs589cp taos_td-2.1 tdengine/tdengine:3.0.0.0 vm98 Running Running about a minute ago
lmjyhzccpvpg taos_adapter.4 tdengine/tdengine:2.4.0 TM1708 Running Running 56 seconds ago
$
docker service
ls
$
docker service
ls
ID NAME MODE REPLICAS IMAGE PORTS
ID NAME MODE REPLICAS IMAGE PORTS
561t4lu6nfw6 taos_adapter replicated 4/4 tdengine/tdengine:2.4.0
ozuklorgl8bs taos_adapter replicated 4/4 tdengine/tdengine:3.0.0.0
3hk5ct3q90sm taos_arbitrator replicated 1/1 tdengine/tdengine:2.4.0
crmhdjw6vxw0 taos_nginx replicated 1/1 nginx:latest
*
:6041->6041/tcp,
*
:6044->6044/udp
d8qr52envqzu taos_nginx replicated 1/1 nginx:latest
*
:6041->6041/tcp,
*
:6044->6044/udp
o86ngy7csv5n taos_td-1 replicated 1/1 tdengine/tdengine:3.0.0.0
2isssfvjk747 taos_td-1 replicated 1/1 tdengine/tdengine:2.4.0
rma040ny4tb0 taos_td-2 replicated 1/1 tdengine/tdengine:3.0.0.0
9pzw7u02ichv taos_td-2 replicated 1/1 tdengine/tdengine:2.4.0
```
```
从上面的输出可以看到有两个 dnode, 和
两
个 taosAdapter,以及一个 nginx 反向代理服务。
从上面的输出可以看到有两个 dnode, 和
四
个 taosAdapter,以及一个 nginx 反向代理服务。
接下来,我们可以减少 taosAdapter 服务的数量
接下来,我们可以减少 taosAdapter 服务的数量
...
@@ -502,5 +501,5 @@ verify: Service converged
...
@@ -502,5 +501,5 @@ verify: Service converged
$
docker service
ls
-f
name
=
taos_adapter
$
docker service
ls
-f
name
=
taos_adapter
ID NAME MODE REPLICAS IMAGE PORTS
ID NAME MODE REPLICAS IMAGE PORTS
561t4lu6nfw6 taos_adapter replicated 1/1 tdengine/tdengine:2.4.0
ozuklorgl8bs taos_adapter replicated 1/1 tdengine/tdengine:3.0.0.0
```
```
source/libs/transport/src/thttp.c
浏览文件 @
fee081c7
...
@@ -21,11 +21,14 @@
...
@@ -21,11 +21,14 @@
#include "taoserror.h"
#include "taoserror.h"
#include "tlog.h"
#include "tlog.h"
#define HTTP_RECV_BUF_SIZE 1024
typedef
struct
SHttpClient
{
typedef
struct
SHttpClient
{
uv_connect_t
conn
;
uv_connect_t
conn
;
uv_tcp_t
tcp
;
uv_tcp_t
tcp
;
uv_write_t
req
;
uv_write_t
req
;
uv_buf_t
*
buf
;
uv_buf_t
*
wbuf
;
char
*
rbuf
;
char
*
addr
;
char
*
addr
;
uint16_t
port
;
uint16_t
port
;
}
SHttpClient
;
}
SHttpClient
;
...
@@ -122,14 +125,30 @@ _OVER:
...
@@ -122,14 +125,30 @@ _OVER:
}
}
static
void
destroyHttpClient
(
SHttpClient
*
cli
)
{
static
void
destroyHttpClient
(
SHttpClient
*
cli
)
{
taosMemoryFree
(
cli
->
buf
);
taosMemoryFree
(
cli
->
wbuf
);
taosMemoryFree
(
cli
->
rbuf
);
taosMemoryFree
(
cli
->
addr
);
taosMemoryFree
(
cli
->
addr
);
taosMemoryFree
(
cli
);
taosMemoryFree
(
cli
);
}
}
static
void
clientCloseCb
(
uv_handle_t
*
handle
)
{
static
void
clientCloseCb
(
uv_handle_t
*
handle
)
{
SHttpClient
*
cli
=
handle
->
data
;
SHttpClient
*
cli
=
handle
->
data
;
destroyHttpClient
(
cli
);
destroyHttpClient
(
cli
);
}
}
static
void
clientAllocBuffCb
(
uv_handle_t
*
handle
,
size_t
suggested_size
,
uv_buf_t
*
buf
)
{
SHttpClient
*
cli
=
handle
->
data
;
buf
->
base
=
cli
->
rbuf
;
buf
->
len
=
HTTP_RECV_BUF_SIZE
;
}
static
void
clientRecvCb
(
uv_stream_t
*
handle
,
ssize_t
nread
,
const
uv_buf_t
*
buf
)
{
SHttpClient
*
cli
=
handle
->
data
;
if
(
nread
<
0
)
{
uError
(
"http-report read error:%s"
,
uv_err_name
(
nread
));
}
else
{
uInfo
(
"http-report succ to read %d bytes, just ignore it"
,
nread
);
}
uv_close
((
uv_handle_t
*
)
&
cli
->
tcp
,
clientCloseCb
);
}
static
void
clientSentCb
(
uv_write_t
*
req
,
int32_t
status
)
{
static
void
clientSentCb
(
uv_write_t
*
req
,
int32_t
status
)
{
SHttpClient
*
cli
=
req
->
data
;
SHttpClient
*
cli
=
req
->
data
;
if
(
status
!=
0
)
{
if
(
status
!=
0
)
{
...
@@ -138,7 +157,7 @@ static void clientSentCb(uv_write_t* req, int32_t status) {
...
@@ -138,7 +157,7 @@ static void clientSentCb(uv_write_t* req, int32_t status) {
}
else
{
}
else
{
uInfo
(
"http-report succ to send data"
);
uInfo
(
"http-report succ to send data"
);
}
}
uv_
close
((
uv_handle_t
*
)
&
cli
->
tcp
,
clientCloseCb
);
uv_
read_start
((
uv_stream_t
*
)
&
cli
->
tcp
,
clientAllocBuffCb
,
clientRecvCb
);
}
}
static
void
clientConnCb
(
uv_connect_t
*
req
,
int32_t
status
)
{
static
void
clientConnCb
(
uv_connect_t
*
req
,
int32_t
status
)
{
SHttpClient
*
cli
=
req
->
data
;
SHttpClient
*
cli
=
req
->
data
;
...
@@ -148,7 +167,7 @@ static void clientConnCb(uv_connect_t* req, int32_t status) {
...
@@ -148,7 +167,7 @@ static void clientConnCb(uv_connect_t* req, int32_t status) {
uv_close
((
uv_handle_t
*
)
&
cli
->
tcp
,
clientCloseCb
);
uv_close
((
uv_handle_t
*
)
&
cli
->
tcp
,
clientCloseCb
);
return
;
return
;
}
}
uv_write
(
&
cli
->
req
,
(
uv_stream_t
*
)
&
cli
->
tcp
,
cli
->
buf
,
2
,
clientSentCb
);
uv_write
(
&
cli
->
req
,
(
uv_stream_t
*
)
&
cli
->
tcp
,
cli
->
w
buf
,
2
,
clientSentCb
);
}
}
static
int32_t
taosBuildDstAddr
(
const
char
*
server
,
uint16_t
port
,
struct
sockaddr_in
*
dest
)
{
static
int32_t
taosBuildDstAddr
(
const
char
*
server
,
uint16_t
port
,
struct
sockaddr_in
*
dest
)
{
...
@@ -189,7 +208,8 @@ int32_t taosSendHttpReport(const char* server, uint16_t port, char* pCont, int32
...
@@ -189,7 +208,8 @@ int32_t taosSendHttpReport(const char* server, uint16_t port, char* pCont, int32
cli
->
conn
.
data
=
cli
;
cli
->
conn
.
data
=
cli
;
cli
->
tcp
.
data
=
cli
;
cli
->
tcp
.
data
=
cli
;
cli
->
req
.
data
=
cli
;
cli
->
req
.
data
=
cli
;
cli
->
buf
=
wb
;
cli
->
wbuf
=
wb
;
cli
->
rbuf
=
taosMemoryCalloc
(
1
,
HTTP_RECV_BUF_SIZE
);
cli
->
addr
=
tstrdup
(
server
);
cli
->
addr
=
tstrdup
(
server
);
cli
->
port
=
port
;
cli
->
port
=
port
;
...
@@ -199,7 +219,6 @@ int32_t taosSendHttpReport(const char* server, uint16_t port, char* pCont, int32
...
@@ -199,7 +219,6 @@ int32_t taosSendHttpReport(const char* server, uint16_t port, char* pCont, int32
int32_t
fd
=
taosCreateSocketWithTimeout
(
5
);
int32_t
fd
=
taosCreateSocketWithTimeout
(
5
);
uv_tcp_open
((
uv_tcp_t
*
)
&
cli
->
tcp
,
fd
);
uv_tcp_open
((
uv_tcp_t
*
)
&
cli
->
tcp
,
fd
);
int32_t
ret
=
uv_tcp_connect
(
&
cli
->
conn
,
&
cli
->
tcp
,
(
const
struct
sockaddr
*
)
&
dest
,
clientConnCb
);
int32_t
ret
=
uv_tcp_connect
(
&
cli
->
conn
,
&
cli
->
tcp
,
(
const
struct
sockaddr
*
)
&
dest
,
clientConnCb
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
uError
(
"http-report failed to connect to server, reason:%s, dst:%s:%d"
,
uv_strerror
(
ret
),
cli
->
addr
,
cli
->
port
);
uError
(
"http-report failed to connect to server, reason:%s, dst:%s:%d"
,
uv_strerror
(
ret
),
cli
->
addr
,
cli
->
port
);
...
...
tools/CMakeLists.txt
浏览文件 @
fee081c7
...
@@ -174,15 +174,15 @@ ELSE ()
...
@@ -174,15 +174,15 @@ ELSE ()
BUILD_COMMAND
BUILD_COMMAND
COMMAND set CGO_CFLAGS=-I
${
CMAKE_CURRENT_SOURCE_DIR
}
/../include/client
COMMAND set CGO_CFLAGS=-I
${
CMAKE_CURRENT_SOURCE_DIR
}
/../include/client
COMMAND set CGO_LDFLAGS=-L
${
CMAKE_BINARY_DIR
}
/build/lib
COMMAND set CGO_LDFLAGS=-L
${
CMAKE_BINARY_DIR
}
/build/lib
COMMAND go build -ldflags
"-s -w -X github.com/taosdata/taosadapter/version.Version=
${
taos_version
}
-X github.com/taosdata/taosadapter/version.CommitID=
${
taosadapter_commit_sha1
}
"
COMMAND go build -
a -o taosadapter.exe -
ldflags
"-s -w -X github.com/taosdata/taosadapter/version.Version=
${
taos_version
}
-X github.com/taosdata/taosadapter/version.CommitID=
${
taosadapter_commit_sha1
}
"
COMMAND go build -
o taosadapter-debug
-ldflags
"-X github.com/taosdata/taosadapter/version.Version=
${
taos_version
}
-X github.com/taosdata/taosadapter/version.CommitID=
${
taosadapter_commit_sha1
}
"
COMMAND go build -
a -o taosadapter-debug.exe
-ldflags
"-X github.com/taosdata/taosadapter/version.Version=
${
taos_version
}
-X github.com/taosdata/taosadapter/version.CommitID=
${
taosadapter_commit_sha1
}
"
INSTALL_COMMAND
INSTALL_COMMAND
COMMAND
${
_upx_prefix
}
/src/upx/upx taosadapter.exe
COMMAND
${
_upx_prefix
}
/src/upx/upx taosadapter.exe
COMMAND cmake -E copy taosadapter.exe
${
CMAKE_BINARY_DIR
}
/build/bin
COMMAND cmake -E copy taosadapter.exe
${
CMAKE_BINARY_DIR
}
/build/bin
COMMAND cmake -E make_directory
${
CMAKE_BINARY_DIR
}
/test/cfg/
COMMAND cmake -E make_directory
${
CMAKE_BINARY_DIR
}
/test/cfg/
COMMAND cmake -E copy ./example/config/taosadapter.toml
${
CMAKE_BINARY_DIR
}
/test/cfg/
COMMAND cmake -E copy ./example/config/taosadapter.toml
${
CMAKE_BINARY_DIR
}
/test/cfg/
COMMAND cmake -E copy ./taosadapter.service
${
CMAKE_BINARY_DIR
}
/test/cfg/
COMMAND cmake -E copy ./taosadapter.service
${
CMAKE_BINARY_DIR
}
/test/cfg/
COMMAND cmake -E copy taosadapter-debug
${
CMAKE_BINARY_DIR
}
/build/bin
COMMAND cmake -E copy taosadapter-debug
.exe
${
CMAKE_BINARY_DIR
}
/build/bin
)
)
unset
(
_upx_prefix
)
unset
(
_upx_prefix
)
ELSE
()
ELSE
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录