Sfoglia il codice sorgente

deploy: taos-explorer 改 native 直连 + taosAdapter 独立容器化

- explorer.toml: 改为 cluster_native 直连 taosd:6031,注释掉 REST API
- 新增 taosadapter.toml: 独立 REST API 服务配置 (port 6041)
- 新增 start-taos-explorer.sh: bridge 网络,挂载数据目录和配置
- 新增 start-taosadapter.sh: bridge 网络,映射 6041 端口
- 新增 start-tdengine-operator.sh: host 网络,仅启动 taosd
- README.md: 更新容器架构、添加 TDengine 管理说明和架构图
mqy20260511
humanleft 2 settimane fa
parent
commit
a7e8f5d60c

+ 65
- 2
deploy/README.md Vedi File

@@ -33,8 +33,9 @@
33 33
 
34 34
 | 容器 | 网络模式 | 端口映射 | 数据持久化 |
35 35
 |------|---------|---------|-----------|
36
-| `tdengine-operator` | host | 6031, 6041 | `/mnt/tdengine-operator/data` |
36
+| `tdengine-operator` | host | 6031 | `/mnt/tdengine-operator/data` |
37 37
 | `taos-explorer` | bridge | `127.0.0.1:6060->6060` | `/mnt/taos-explorer-data` |
38
+| `taosadapter` | bridge | 6041 | 无(无状态服务) |
38 39
 | `iot-platform` | bridge | `0.0.0.0:8887->8887` | `/mnt/iot-platform/logs` |
39 40
 
40 41
 ## 快速开始
@@ -183,6 +184,67 @@ podman run -d \
183 184
     localhost/iot-platform:latest
184 185
 ```
185 186
 
187
+## TDengine 容器管理
188
+
189
+```bash
190
+# 查看所有 TDengine 相关容器
191
+podman ps | grep -E 'tdengine|taos'
192
+
193
+# 重启 taos-explorer(native 直连模式)
194
+podman restart taos-explorer
195
+
196
+# 重启 taosadapter(REST API 服务)
197
+podman restart taosadapter
198
+
199
+# 查看 taos-explorer 日志
200
+podman logs -f taos-explorer
201
+
202
+# 查看 taosadapter 日志
203
+podman logs -f taosadapter
204
+
205
+# 验证 taosadapter REST API
206
+curl -s http://127.0.0.1:6041/rest/sql -X POST -d "SHOW DATABASES"
207
+```
208
+
209
+### 启动脚本位置
210
+
211
+| 脚本 | 用途 |
212
+|------|------|
213
+| `scripts/start-tdengine-operator.sh` | 启动 tdengine-operator(host 网络,taosd) |
214
+| `scripts/start-taos-explorer.sh` | 启动 taos-explorer(bridge 网络,native 直连) |
215
+| `scripts/start-taosadapter.sh` | 启动 taosadapter(bridge 网络,REST API) |
216
+
217
+## 架构说明
218
+
219
+```
220
+┌─────────────────────────────────────────────┐
221
+│                    宿主机                     │
222
+│  ┌─────────────┐      ┌─────────────────┐   │
223
+│  │ nginx :6060 │─────▶│ taos-explorer   │   │
224
+│  └─────────────┘      │ (native 直连)   │   │
225
+│                       └────────┬────────┘   │
226
+│                                │            │
227
+│  ┌─────────────────────────────┼────────┐   │
228
+│  │         iot-platform        │        │   │
229
+│  │         (bridge)            │        │   │
230
+│  └─────────────────────────────┘        │   │
231
+│                                         │   │
232
+│  ┌──────────────────────────────────────┘   │
233
+│  │  tdengine-operator (host网络)            │
234
+│  │  taosd :6031                             │
235
+│  └──────────────────────────────────────────┘
236
+│
237
+│  ┌─────────────────────────────────────────┐
238
+│  │  taosadapter (bridge) :6041             │
239
+│  │  为 Node.js 查询服务提供 REST API        │
240
+│  └─────────────────────────────────────────┘
241
+└─────────────────────────────────────────────┘
242
+```
243
+
244
+- `taos-explorer` 使用 **native 直连**(`taos://172.21.185.173:6031`),不依赖 taosadapter
245
+- `taosadapter` 独立部署,为第三方服务(如 Node.js)提供 **REST API** 接入
246
+- `tdengine-operator` 使用 **host 网络**,保证 FQDN 机制正常工作
247
+
186 248
 ## 配置文件说明
187 249
 
188 250
 | 文件 | 说明 |
@@ -194,5 +256,6 @@ podman run -d \
194 256
 | `start-container.sh` | 容器内启动脚本(加载 .env) |
195 257
 | `iot-platform.service` | systemd 服务定义(已废弃,保留备用) |
196 258
 | `config/taos.cfg` | TDengine 服务端配置 |
197
-| `config/explorer.toml` | taos-explorer 配置 |
259
+| `config/explorer.toml` | taos-explorer 配置(native 直连) |
260
+| `config/taosadapter.toml` | taosadapter 独立服务配置 |
198 261
 | `config/tdengine-explorer.conf` | nginx 代理配置 |

+ 4
- 3
deploy/config/explorer.toml Vedi File

@@ -32,17 +32,18 @@ log_level = "info"
32 32
 
33 33
 # REST API endpoint to connect to the cluster.
34 34
 # This configuration is also the target for data migration tasks.
35
-# 
35
+#
36 36
 # Default is "http://localhost:6041" - the default endpoint for REST API.
37
+# Note: taos-explorer now uses native connection instead of REST API.
37 38
 #
38
-cluster = "http://172.21.185.173:6041"
39
+# cluster = "http://localhost:6041"
39 40
 
40 41
 # native endpoint to connect to the cluster.
41 42
 # Default is disabled. To enable it, set it to the native API URL like "taos://localhost:6030" and uncomment it.
42 43
 # If you enable it, you will get more performance for data migration tasks.
43 44
 # If modify this config item, you must relogin to clear the cache in browser local storage.
44 45
 #
45
-# cluster_native = "taos://localhost:6030"
46
+cluster_native = "taos://172.21.185.173:6031"
46 47
 
47 48
 # API endpoint for data replication/backup/data sources. No default option.
48 49
 #   Set it to API URL like "http://localhost:6050".

+ 96
- 0
deploy/config/taosadapter.toml Vedi File

@@ -0,0 +1,96 @@
1
+# taosAdapter configuration file
2
+# Deployed as independent container for Node.js service REST API access
3
+
4
+debug = true
5
+taosConfigDir = ""
6
+port = 6041
7
+logLevel = "info"
8
+
9
+[cors]
10
+allowAllOrigins = true
11
+
12
+[ssl]
13
+enable = false
14
+certFile = ""
15
+keyFile = ""
16
+
17
+[log]
18
+rotationCount = 30
19
+rotationTime = "24h"
20
+rotationSize = "1GB"
21
+enableRecordHttpSql = false
22
+sqlRotationCount = 2
23
+sqlRotationTime =  "24h"
24
+sqlRotationSize = "1GB"
25
+
26
+[monitor]
27
+collectDuration = "3s"
28
+incgroup = false
29
+pauseQueryMemoryThreshold = 70
30
+pauseAllMemoryThreshold = 80
31
+identity = ""
32
+writeToTD = false
33
+user = "root"
34
+password = "taosdata"
35
+writeInterval = "30s"
36
+
37
+[opentsdb]
38
+enable = true
39
+
40
+[influxdb]
41
+enable = true
42
+
43
+[statsd]
44
+enable = false
45
+port = 6044
46
+db = "statsd"
47
+user = "root"
48
+password = "taosdata"
49
+worker = 10
50
+gatherInterval = "5s"
51
+protocol = "udp"
52
+maxTCPConnections = 250
53
+tcpKeepAlive = false
54
+allowPendingMessages = 50000
55
+deleteCounters = true
56
+deleteGauges = true
57
+deleteSets = true
58
+deleteTimings = true
59
+
60
+[collectd]
61
+enable = false
62
+port = 6045
63
+db = "collectd"
64
+user = "root"
65
+password = "taosdata"
66
+worker = 10
67
+
68
+[opentsdb_telnet]
69
+enable = false
70
+maxTCPConnections = 250
71
+tcpKeepAlive = false
72
+dbs = ["opentsdb_telnet", "collectd", "icinga2", "tcollector"]
73
+ports = [6046, 6047, 6048, 6049]
74
+user = "root"
75
+password = "taosdata"
76
+batchSize = 1
77
+flushInterval = "0s"
78
+
79
+[node_exporter]
80
+enable = false
81
+db = "node_exporter"
82
+user = "root"
83
+password = "taosdata"
84
+urls = ["http://localhost:9100"]
85
+responseTimeout = "5s"
86
+httpUsername = ""
87
+httpPassword = ""
88
+httpBearerTokenString = ""
89
+caCertFile = ""
90
+certFile = ""
91
+keyFile = ""
92
+insecureSkipVerify = true
93
+gatherDuration = "5s"
94
+
95
+[prometheus]
96
+enable = true

+ 31
- 0
deploy/scripts/start-taos-explorer.sh Vedi File

@@ -0,0 +1,31 @@
1
+#!/bin/bash
2
+# Start taos-explorer container
3
+# Uses native connection (cluster_native) to connect directly to taosd
4
+# REST API (taosAdapter) is no longer required
5
+
6
+set -e
7
+
8
+CONTAINER_NAME="taos-explorer"
9
+IMAGE="docker.io/tdengine/tdengine:3.3.6.13"
10
+DATA_DIR="/mnt/taos-explorer-data"
11
+CFG_FILE="/mnt/iot-platform/config/explorer.toml"
12
+
13
+echo "Starting ${CONTAINER_NAME}..."
14
+
15
+# Stop and remove existing container if present
16
+podman rm -f "${CONTAINER_NAME}" 2>/dev/null || true
17
+
18
+podman run -d \
19
+    --name "${CONTAINER_NAME}" \
20
+    --network bridge \
21
+    --restart unless-stopped \
22
+    -p 127.0.0.1:6060:6060 \
23
+    -v "${DATA_DIR}:/var/lib/taos/explorer" \
24
+    -v "${CFG_FILE}:/etc/taos/explorer.toml:ro" \
25
+    -e EXPLORER_SKIP_REGISTER=true \
26
+    "${IMAGE}" \
27
+    taos-explorer
28
+
29
+echo "${CONTAINER_NAME} started."
30
+echo "Port: 127.0.0.1:6060 (nginx proxy)"
31
+echo "Connection: native (taos://172.21.185.173:6031), no taosAdapter required"

+ 30
- 0
deploy/scripts/start-taosadapter.sh Vedi File

@@ -0,0 +1,30 @@
1
+#!/bin/bash
2
+# Start taosAdapter as independent container
3
+# Provides REST API (port 6041) for Node.js service and third-party tools
4
+# Connects to tdengine-operator (host network, port 6031)
5
+
6
+set -e
7
+
8
+CONTAINER_NAME="taosadapter"
9
+IMAGE="docker.io/tdengine/tdengine:3.3.6.13"
10
+CFG_FILE="/mnt/iot-platform/config/taosadapter.toml"
11
+TAOS_CFG="/mnt/tdengine-operator/taos.cfg"
12
+
13
+echo "Starting ${CONTAINER_NAME}..."
14
+
15
+# Stop and remove existing container if present
16
+podman rm -f "${CONTAINER_NAME}" 2>/dev/null || true
17
+
18
+podman run -d \
19
+    --name "${CONTAINER_NAME}" \
20
+    --network bridge \
21
+    --restart unless-stopped \
22
+    -p 6041:6041 \
23
+    -v "${CFG_FILE}:/etc/taos/taosadapter.toml:ro" \
24
+    -v "${TAOS_CFG}:/etc/taos/taos.cfg:ro" \
25
+    "${IMAGE}" \
26
+    taosadapter -c /etc/taos/taosadapter.toml
27
+
28
+echo "${CONTAINER_NAME} started."
29
+echo "Port: 6041 (REST API)"
30
+echo "Connects to taosd at 172.21.185.173:6031 via taos.cfg"

+ 30
- 0
deploy/scripts/start-tdengine-operator.sh Vedi File

@@ -0,0 +1,30 @@
1
+#!/bin/bash
2
+# Start tdengine-operator container (taosd only)
3
+# Data directory: /mnt/tdengine-operator/data
4
+# Network: host (required for TDengine FQDN mechanism)
5
+
6
+set -e
7
+
8
+CONTAINER_NAME="tdengine-operator"
9
+IMAGE="docker.io/tdengine/tdengine:3.3.6.13"
10
+DATA_DIR="/mnt/tdengine-operator/data"
11
+LOG_DIR="/mnt/tdengine-operator/log"
12
+CFG_FILE="/mnt/tdengine-operator/taos.cfg"
13
+
14
+echo "Starting ${CONTAINER_NAME}..."
15
+
16
+# Stop and remove existing container if present
17
+podman rm -f "${CONTAINER_NAME}" 2>/dev/null || true
18
+
19
+podman run -d \
20
+    --name "${CONTAINER_NAME}" \
21
+    --network host \
22
+    --restart unless-stopped \
23
+    -v "${DATA_DIR}:/var/lib/taos" \
24
+    -v "${LOG_DIR}:/var/log/taos" \
25
+    -v "${CFG_FILE}:/etc/taos/taos.cfg:ro" \
26
+    "${IMAGE}" \
27
+    taosd
28
+
29
+echo "${CONTAINER_NAME} started."
30
+echo "Port: 6031 (native), taosd on host network"

Loading…
Annulla
Salva