diff --git a/.drone.yml b/.drone.yml index 085a07acf94a57cbcaf076c149cebdf243f8ff74..457301b89ca1628d62ba50f2875ae612f7873bc1 100644 --- a/.drone.yml +++ b/.drone.yml @@ -12,6 +12,7 @@ steps: commands: - apt-get update - apt-get install -y cmake build-essential + - git submodule update --init --recursive - mkdir debug - cd debug - cmake .. @@ -37,6 +38,7 @@ steps: commands: - apt-get update - apt-get install -y cmake build-essential + - git submodule update --init --recursive - mkdir debug - cd debug - cmake .. -DCPUTYPE=aarch64 > /dev/null @@ -64,6 +66,7 @@ steps: - echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections - apt-get update - apt-get install -y -qq cmake build-essential + - git submodule update --init --recursive - mkdir debug - cd debug - cmake .. -DCPUTYPE=aarch64 > /dev/null @@ -89,6 +92,7 @@ steps: image: arm64v8/centos:7 commands: - yum install -y gcc gcc-c++ make cmake git + - git submodule update --init --recursive - mkdir debug - cd debug - cmake .. -DCPUTYPE=aarch64 > /dev/null @@ -114,6 +118,7 @@ steps: image: arm64v8/centos:8 commands: - dnf install -y gcc gcc-c++ make cmake epel-release git libarchive + - git submodule update --init --recursive - mkdir debug - cd debug - cmake .. -DCPUTYPE=aarch64 > /dev/null @@ -140,6 +145,7 @@ steps: commands: - apt-get update - apt-get install -y cmake build-essential + - git submodule update --init --recursive - mkdir debug - cd debug - cmake .. -DCPUTYPE=aarch32 > /dev/null @@ -166,7 +172,7 @@ steps: commands: - apt-get update - apt-get install -y gcc cmake3 build-essential git binutils-2.26 - + - git submodule update --init --recursive - mkdir debug - cd debug - cmake .. @@ -193,6 +199,7 @@ steps: commands: - apt-get update - apt-get install -y gcc cmake build-essential + - git submodule update --init --recursive - mkdir debug - cd debug - cmake .. @@ -218,6 +225,7 @@ steps: commands: - apt-get update - apt-get install -y gcc cmake build-essential + - git submodule update --init --recursive - mkdir debug - cd debug - cmake .. @@ -242,6 +250,7 @@ steps: image: ansible/centos7-ansible commands: - yum install -y gcc gcc-c++ make cmake + - git submodule update --init --recursive - mkdir debug - cd debug - cmake .. diff --git a/.gitmodules b/.gitmodules index 3d721fa8954023f92f8dcc70b09a1424d0104bbe..dbb02d4ef7ed65d11418e271cac7e61b95c2a482 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,3 +16,6 @@ [submodule "deps/TSZ"] path = deps/TSZ url = https://github.com/taosdata/TSZ.git +[submodule "src/plugins/blm3"] + path = src/plugins/blm3 + url = https://github.com/taosdata/blm3 diff --git a/Jenkinsfile b/Jenkinsfile index 95c1012a2e9c82f88bc9520c890c6717ff5ae6ef..1a05f42384cce6a1308838f51e397ad81aed30a9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -72,6 +72,7 @@ def pre_test(){ git fetch origin +refs/pull/${CHANGE_ID}/merge git checkout -qf FETCH_HEAD git clean -dfx + git submodule update --init --recursive cd ${WK} git reset --hard HEAD~10 ''' @@ -98,7 +99,7 @@ def pre_test(){ sh ''' cd ${WK} git pull >/dev/null - + git submodule update --init --recursive export TZ=Asia/Harbin date git clean -dfx diff --git a/README.md b/README.md index 2f45d9618ecdb08a0d360dfcadb90c02bb8290fa..02bca32e5c2091880c6d1d353c6b7160bcc1eca2 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,15 @@ To install Apache Maven: sudo dnf install -y maven ``` +### Setup golang environment +TDengine includes few components developed by Go language. Please refer to golang.org official documentation for golang environment setup. + +Please use version 1.14+. For the user in China, we recommend using a proxy to accelerate package downloading. +``` +go env -w GO111MODULE=on +go env -w GOPROXY=https://goproxy.cn,direct +``` + ## Get the source codes First of all, you may clone the source codes from github: diff --git a/alert/release.sh b/alert/release.sh index 20317e41663de528c0fcaa42621db57b7b5a82dc..93f1291ae520a02489fa96d545ff8cc9bf28c9b3 100755 --- a/alert/release.sh +++ b/alert/release.sh @@ -52,7 +52,7 @@ echo "cpuType=${cpuType}" echo "osType=${osType}" echo "version=${version}" -GOOS=${osType} GOARCH=${cpuType} go build -ldflags '-X main.version='${version} +GOOS=${osType} GOARCH=${cpuType} go mod tidy && go build -ldflags '-X main.version='${version} mkdir -p TDengine-alert/driver diff --git a/cmake/define.inc b/cmake/define.inc index a5fbd8abe959fb8530dd8cc26c79eefd47ec6b9f..10134a94d2e5d40b7528af1ca205105d3235c6d2 100755 --- a/cmake/define.inc +++ b/cmake/define.inc @@ -87,7 +87,7 @@ IF (TD_ARM_64) ADD_DEFINITIONS(-DUSE_LIBICONV) MESSAGE(STATUS "arm64 is defined") SET(COMMON_FLAGS "-Wall -Werror -fPIC -fsigned-char -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") - + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/lua/src) ENDIF () @@ -124,7 +124,17 @@ IF (TD_APLHINE) MESSAGE(STATUS "aplhine is defined") ENDIF () -IF (TD_BUILD_HTTP) +IF (TD_LINUX) + IF (TD_ARM_32) + SET(TD_BUILD_HTTP TRUE) + ADD_DEFINITIONS(-DHTTP_EMBEDDED) + ELSE () + IF (TD_BUILD_HTTP) + ADD_DEFINITIONS(-DHTTP_EMBEDDED) + ENDIF () + ENDIF () +ELSE () + SET(TD_BUILD_HTTP TRUE) ADD_DEFINITIONS(-DHTTP_EMBEDDED) ENDIF () diff --git a/cmake/input.inc b/cmake/input.inc index e053c66d9d8c11dbdd3ffdd4df1011967b837acb..a6eaaa97898bbba5b4ba79fac35b0d96c6a9391f 100755 --- a/cmake/input.inc +++ b/cmake/input.inc @@ -90,10 +90,10 @@ IF (${BUILD_JDBC} MATCHES "false") SET(TD_BUILD_JDBC FALSE) ENDIF () -SET(TD_BUILD_HTTP TRUE) +SET(TD_BUILD_HTTP FALSE) -IF (${BUILD_HTTP} MATCHES "false") - SET(TD_BUILD_HTTP FALSE) +IF (${BUILD_HTTP} MATCHES "true") + SET(TD_BUILD_HTTP TRUE) ENDIF () SET(TD_MEMORY_SANITIZER FALSE) @@ -108,10 +108,10 @@ IF (${VERBOSE} MATCHES "true") ENDIF () IF (${TSZ_ENABLED} MATCHES "true") - # define add + # define add MESSAGE(STATUS "build with TSZ enabled") ADD_DEFINITIONS(-DTD_TSZ) set(VAR_TSZ "TSZ" CACHE INTERNAL "global variant tsz" ) ELSE() set(VAR_TSZ "" CACHE INTERNAL "global variant empty" ) -ENDIF() +ENDIF() diff --git a/documentation20/cn/00.index/docs.md b/documentation20/cn/00.index/docs.md index df5a82517183f967aaaeb6767804cefa795301a1..8f22a1d85e13dc88ee78ad2ed1450933707cce3b 100644 --- a/documentation20/cn/00.index/docs.md +++ b/documentation20/cn/00.index/docs.md @@ -118,6 +118,11 @@ TDengine是一个高效的存储、查询、分析时序大数据的平台,专 * [数据复制](/architecture/replica):支持实时同步、异步复制,保证系统的High Availibility * [技术博客](https://www.taosdata.com/cn/blog/?categories=3):更多的技术分析和架构设计文章 +## [应用 TDengine 快速搭建 IT 运维系统](/devops) + +* [devops](/devops/telegraf):使用 TDengine + Telegraf + Grafana 快速搭建 IT 运维系统 +* [devops](/devops/collectd):使用 TDengine + collectd_statsd + Grafana 快速搭建 IT 运维系统 + ## 常用工具 * [TDengine样例导入工具](https://www.taosdata.com/blog/2020/01/18/1166.html) diff --git a/documentation20/cn/05.insert/docs.md b/documentation20/cn/05.insert/docs.md index bd6698251ac96b4fff300461d7e12a9e350bdfb7..b61d94f408008e7eb6ac92442a55895458e697d3 100644 --- a/documentation20/cn/05.insert/docs.md +++ b/documentation20/cn/05.insert/docs.md @@ -183,7 +183,73 @@ use prometheus; select * from apiserver_request_latencies_bucket; ``` -## Telegraf 直接写入 +## Telegraf 直接写入(通过 BLM v3) +TDengine 新版本(2.3.0.0+)将包含一个 BLM3 独立程序,负责接受其他多种应用的数据写入。 + +配置方法,假设 TDengine 使用默认用户名 root 和密码 taosdata。在 /etc/telegraf/telegraf.conf 增加如下文字: +``` +[[outputs.http]] + url = "http://:6041/influxdb/v1/write?db=metrics" + method = "POST" + timeout = "5s" + username = "root" + password = "taosdata" + data_format = "influx" + influx_max_line_bytes = 250 +``` + +然后重启 telegraf: +``` +sudo systemctl start telegraf +``` +即可在 TDengine 中查询 metrics 数据库中 Telegraf 写入的数据。 + +BLM v3 相关配置参数请参考 blm3 --help 命令输出以及相关文档。 + +## collectd 直接写入(通过 BLM v3) +安装 collectd +``` +apt-get install collectd +``` + +在 /etc/collectd/collectd.conf 文件中增加如下内容: +``` +LoadPlugin network + + Server "192.168.17.180" "25826" + +``` +重启 collectd +``` +sudo systemctl start collectd +``` +BLM v3 相关配置参数请参考 blm3 --help 命令输出以及相关文档。 + +## StatsD 直接写入(通过 BLM v3) +安装 StatsD +请参考[官方文档](https://github.com/statsd/statsd)。 + +在 config.js 文件中增加如下内容后启动 StatsD: +``` +backends 部分添加 "./backends/repeater" +repeater 部分添加 { host:'', port: 8126 } +``` + +实例配置文件: +``` +{ +port: 8125 +, backends: ["./backends/repeater"] +, repeater: [{ host: '127.0.0.1', port: 8126}] +} +``` + +BLM v3 相关配置参数请参考 blm3 --help 命令输出以及相关文档。 + + +## 使用 Bailongma 2.0 接入 Telegraf 数据写入 + +*注意:TDengine 新版本(2.3.0.0+)提供新版本 Bailongma ,命名为 BLM v3,提供更简便的 Telegraf 数据写入以及其他更强大的功能,Bailongma v2 即之前版本将逐步不再维护。 [Telegraf](https://www.influxdata.com/time-series-platform/telegraf/)是一流行的IT运维数据采集开源工具,TDengine提供一个小工具[Bailongma](https://github.com/taosdata/Bailongma),只需在Telegraf做简单配置,无需任何代码,就可将Telegraf采集的数据直接写入TDengine,并按规则在TDengine自动创建库和相关表项。博文[用Docker容器快速搭建一个Devops监控Demo](https://www.taosdata.com/blog/2020/02/03/1189.html)即是采用bailongma将Prometheus和Telegraf的数据写入TDengine中的示例,可以参考。 diff --git a/documentation20/cn/08.connector/docs.md b/documentation20/cn/08.connector/docs.md index 8cf3a889ceedb6cedcb5b7f1e581297b61986bcd..bbac768316e47e34ea56107eed81416f518cd42a 100644 --- a/documentation20/cn/08.connector/docs.md +++ b/documentation20/cn/08.connector/docs.md @@ -407,9 +407,9 @@ typedef struct TAOS_MULTI_BIND { 除了使用 SQL 方式或者使用参数绑定 API 写入数据外,还可以使用 Schemaless 的方式完成写入。Schemaless 可以免于预先创建超级表/数据子表的数据结构,而是可以直接写入数据,TDengine 系统会根据写入的数据内容自动创建和维护所需要的表结构。Schemaless 的使用方式详见 [Schemaless 写入](https://www.taosdata.com/cn/documentation/insert#schemaless) 章节,这里介绍与之配套使用的 C/C++ API。 +2.2.0.0版本接口: - `int taos_insert_lines(TAOS* taos, char* lines[], int numLines)` - (2.2.0.0 版本新增) 以 Schemaless 格式写入多行数据。其中: * taos:调用 taos_connect 返回的数据库连接。 * lines:由 char 字符串指针组成的数组,指向本次想要写入数据库的多行数据。 @@ -421,6 +421,65 @@ typedef struct TAOS_MULTI_BIND { 1. 此接口是一个同步阻塞式接口,使用时机与 `taos_query()` 一致。 2. 在调用此接口之前,必须先调用 `taos_select_db()` 来确定目前是在向哪个 DB 来写入。 +2.3.0.0版本接口: +- `int taos_schemaless_insert(TAOS* taos, const char* lines[], int numLines, int protocol, const char* precision, int* affectedRows, char* msg, int msgBufLen)` + **参数说明** + taos: 数据库连接,通过taos_connect 函数建立的数据库连接。 + lines:文本数据。满足解析格式要求的无模式文本字符串。 + numLines:文本数据的行数,不能为 0 。 + protocol: 行协议类型,用于标识文本数据格式。 + precision:文本数据中的时间戳精度字符串。 + affectedRows:插入操作完成以后,正确写入到数据库中的记录行数。 + msg: 如果出现错误(函数返回值不为 0)情况下,错误提示信息。该参数是输入参数,需要用户指定消息输出缓冲区,如果不指定该缓冲区(输入为NULL),即使出现错误也不会得到错误提示信息。 + msgBufLen: 缓冲区的长度,避免错误提示消息越界。 + + **返回值** + 0:无错误发生。 + 非 0 值:发生了错误。此时可以通过msg获取错误信息的提示。该返回值含义可以参考taoserror.h文件中的错误码定义。 + + **说明** + 协议类型是枚举类型,包含以下三种格式: + SML_LINE_PROTOCOL:InfluxDB行协议(Line Protocol) + SML_TELNET_PROTOCOL: OpenTSDB文本行协议 + SML_JSON_PROTOCOL: OpenTSDB Json协议格式 + + 时间戳分辨率的说明使用如下字符串:“h“ (小时)、”m“(分钟)、”s“ (秒) ”ms“(毫秒)、”u“ (微秒)、”ns”(纳秒),不区分大小写。需要注意的是,时间戳分辨率参数只在协议类型为 SML_LINE_PROTOCOL 的时候生效。对于 OpenTSDB的文本协议,时间戳的解析遵循其官方解析规则 — 按照时间戳包含的字符的数量来确认时间精度。 + +```c +#include +#include +#include + +int main() { + const char* host = "127.0.0.1"; + const char* user = "root"; + const char* passwd = "taosdata"; + + // error message buffer + char msg[512] = {0}; + + // connect to server + TAOS* taos = taos_connect(host, user, passwd, "test", 0); + + // prepare the line string + char* lines1[] = { + "stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", + "stg,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833641000000" + }; + + // schema-less insert + int code = taos_schemaless_insert(taos, lines1, 2, SML_LINE_PROTOCOL, "ns", msg, sizeof(msg)/sizeof(msg[0])); + if (code != 0) { + printf("failed to insert schema-less data, reason: %s\n", msg); + } + + // close the connection + taos_close(taos); + return (code); +} +``` +**注**:后续2.2.0.0版本也更新成2.3.0.0版本的接口。 + ### 连续查询接口 TDengine提供时间驱动的实时流式计算API。可以每隔一指定的时间段,对一张或多张数据库的表(数据流)进行各种实时聚合计算操作。操作简单,仅有打开、关闭流的API。具体如下: diff --git a/documentation20/cn/12.taos-sql/docs.md b/documentation20/cn/12.taos-sql/docs.md index 8e62ab1ae5b10f4f1bd43a98c7eaaa2c97349f40..ebf344ca94200d37585cc9af57b91cccaedc3a5c 100644 --- a/documentation20/cn/12.taos-sql/docs.md +++ b/documentation20/cn/12.taos-sql/docs.md @@ -1472,6 +1472,39 @@ Query OK, 1 row(s) in set (0.001238s) Query OK, 1 row(s) in set (0.000836s) ``` +- **CEIL** + ```mysql + SELECT CEIL(field_name) FROM { tb_name | stb_name } [WHERE clause]; + ``` + 功能说明:获得指定列的向上取整数的结果。 + + 返回结果类型:与指定列的原始数据类型一致。例如,如果指定列的原始数据类型为 Float,那么返回的数据类型也为 Float;如果指定列的原始数据类型为 Double,那么返回的数据类型也为 Double。 + + 适用数据类型:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列,无论 tag 列的类型是什么类型。 + + 嵌套子查询支持:适用于内层查询和外层查询。 + + 说明: + 支持 +、-、*、/ 运算,如 ceil(col1) + ceil(col2)。 + 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 + 该函数可以应用在普通表和超级表上。 + + 支持版本:指定计算算法的功能从 2.2.0.x 版本开始,2.2.0.0 之前的版本不支持指定使用算法的功能。 + +- **FLOOR** + ```mysql + SELECT FLOOR(field_name) FROM { tb_name | stb_name } [WHERE clause]; + ``` + 功能说明:获得指定列的向下取整数的结果。 + 其他使用说明参见CEIL函数描述。 + +- **ROUND** + ```mysql + SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; + ``` + 功能说明:获得指定列的四舍五入的结果。 + 其他使用说明参见CEIL函数描述。 + - **四则运算** ```mysql diff --git a/documentation20/cn/14.devops/01.telegraf/docs.md b/documentation20/cn/14.devops/01.telegraf/docs.md new file mode 100644 index 0000000000000000000000000000000000000000..c9ffe0342b10349b562f49105a1c5e277fc3c4a5 --- /dev/null +++ b/documentation20/cn/14.devops/01.telegraf/docs.md @@ -0,0 +1,70 @@ +# 使用 TDengine + Telegraf + Grafana 快速搭建 IT 运维展示系统 + +## 背景介绍 +TDengine是涛思数据专为物联网、车联网、工业互联网、IT运维等设计和优化的大数据平台。自从 2019年 7 月开源以来,凭借创新的数据建模设计、快捷的安装方式、易用的编程接口和强大的数据写入查询性能博得了大量时序数据开发者的青睐。 + +IT 运维监测数据通常都是对时间特性比较敏感的数据,例如: +- 系统资源指标:CPU、内存、IO、带宽等。 +- 软件系统指标:存活状态、连接数目、请求数目、超时数目、错误数目、响应时间、服务类型及其他与业务有关的指标。 + +当前主流的 IT 运维系统通常包含一个数据采集模块,一个数据存储模块,和一个可视化显示模块。Telegraf 和 Grafana 分别是当前最流行的数据采集模块和可视化显示模块之一。而数据存储模块可供选择的软件比较多,其中 OpenTSDB 或 InfluxDB 比较流行。而 TDengine 作为新兴的时序大数据平台,具备极强的高性能、高可靠、易管理、易维护的优势。 + +本文介绍不需要写一行代码,通过简单修改几行配置文件,就可以快速搭建一个基于 TDengine + Telegraf + Grafana 的 IT 运维系统。架构如下图: + +![IT-DevOps-Solutions-Telegraf.png](../../images/IT-DevOps-Solutions-Telegraf.png) + + +## 安装步骤 + +### 安装 Telegraf,Grafana 和 TDengine +安装 Telegraf、Grafana 和 TDengine 请参考相关官方文档。 + +### Telegraf +请参考[官方文档](https://portal.influxdata.com/downloads/)。 + +### Grafana +请参考[官方文档](https://grafana.com/grafana/download)。 + +### 安装 TDengine +从涛思数据官网[下载](http://taosdata.com/cn/all-downloads/)页面下载最新 TDengine-server 2.3.0.0 或以上版本安装。 + + +## 数据链路设置 +### 复制 TDengine 插件到 grafana 插件目录 +``` +1. sudo cp -r /usr/local/taos/connector/grafanaplugin /var/lib/grafana/plugins/tdengine +2. sudo chown grafana:grafana -R /var/lib/grafana/plugins/tdengine +3. echo -e "[plugins]\nallow_loading_unsigned_plugins = taosdata-tdengine-datasource\n" | sudo tee -a /etc/grafana/grafana.ini +4. sudo systemctl restart grafana-server.service +``` + +### 修改 /etc/telegraf/telegraf.conf +假设 TDengine 使用默认用户名 root 和密码 taosdata。增加如下文字: +``` +[[outputs.http]] + url = "http://:6041/influxdb/v1/write?db=metrics" + method = "POST" + timeout = "5s" + username = "root" + password = "taosdata" + data_format = "influx" + influx_max_line_bytes = 250 +``` +然后重启 telegraf: +``` +sudo systemctl start telegraf +``` + + +### 导入 Dashboard + +使用 Web 浏览器访问 IP:3000 登录 Grafana 界面,系统初始用户名密码为 admin/admin。 +点击左侧齿轮图标并选择 Plugins,应该可以找到 TDengine data source 插件图标。 +点击左侧加号图标并选择 Import,按照界面提示选择 /usr/local/taos/connector/grafanaplugin/examples/telegraf/grafana/dashboards/telegraf-dashboard-v0.1.0.json 文件。如果按照 Grafana 的机器上没有安装 TDengine,可以从 https://github.com/taosdata/grafanaplugin/blob/master/examples/telegraf/grafana/dashboards/telegraf-dashboard-v0.1.0.json 下载 dashboard JSON 文件再导入。之后可以看到如下界面的仪表盘: + +![IT-DevOps-Solutions-telegraf-dashboard.png](../../images/IT-DevOps-Solutions-telegraf-dashboard.png) + + +## 总结 + +以上演示如何快速搭建一个完整的 IT 运维展示系统。得力于 TDengine 2.3.0.0 版本中新增的 schemaless 协议解析功能,以及强大的生态软件适配能力,用户可以短短数分钟就可以搭建一个高效易用的 IT 运维系统。TDengine 强大的数据写入查询性能和其他丰富功能请参考官方文档和产品落地案例。 diff --git a/documentation20/cn/14.devops/02.collectd/docs.md b/documentation20/cn/14.devops/02.collectd/docs.md new file mode 100644 index 0000000000000000000000000000000000000000..7d391c8b80d77de4d178ce160417c1107dbb9d83 --- /dev/null +++ b/documentation20/cn/14.devops/02.collectd/docs.md @@ -0,0 +1,77 @@ +# 使用 TDengine + collectd/StatsD + Grafana 快速搭建 IT 运维监控系统 + +## 背景介绍 +TDengine是涛思数据专为物联网、车联网、工业互联网、IT运维等设计和优化的大数据平台。自从 2019年 7 月开源以来,凭借创新的数据建模设计、快捷的安装方式、易用的编程接口和强大的数据写入查询性能博得了大量时序数据开发者的青睐。 + +IT 运维监测数据通常都是对时间特性比较敏感的数据,例如: +- 系统资源指标:CPU、内存、IO、带宽等。 +- 软件系统指标:存活状态、连接数目、请求数目、超时数目、错误数目、响应时间、服务类型及其他与业务有关的指标。 + +当前主流的 IT 运维系统通常包含一个数据采集模块,一个数据存储模块,和一个可视化显示模块。collectd / statsD 作为老牌开源数据采集工具,具有广泛的用户群。但是 collectd / StatsD 自身功能有限,往往需要配合 Telegraf、Grafana 以及时序数据库组合搭建成为完整的监控系统。而 TDengine 新版本支持多种数据协议接入,可以直接接受 collectd 和 statsD 的数据写入,并提供 Grafana dashboard 进行图形化展示。 + +本文介绍不需要写一行代码,通过简单修改几行配置文件,就可以快速搭建一个基于 TDengine + collectd / statsD + Grafana 的 IT 运维系统。架构如下图: + +![IT-DevOps-Solutions-Collectd-StatsD.png](../../images/IT-DevOps-Solutions-Collectd-StatsD.png) + +## 安装步骤 +安装 collectd, StatsD, Grafana 和 TDengine 请参考相关官方文档。 + +### 安装 collectd +请参考[官方文档](https://collectd.org/documentation.shtml)。 + +### 安装 StatsD +请参考[官方文档](https://github.com/statsd/statsd)。 + +### 安装 Grafana +请参考[官方文档](https://grafana.com/grafana/download)。 + +### 安装 TDengine +从涛思数据官网[下载](http://taosdata.com/cn/all-downloads/)页面下载最新 TDengine-server 2.3.0.0 或以上版本安装。 + +## 数据链路设置 +### 复制 TDengine 插件到 grafana 插件目录 +``` +1. sudo cp -r /usr/local/taos/connector/grafanaplugin /var/lib/grafana/plugins/tdengine +2. sudo chown grafana:grafana -R /var/lib/grafana/plugins/tdengine +3. echo -e "[plugins]\nallow_loading_unsigned_plugins = taosdata-tdengine-datasource\n" | sudo tee -a /etc/grafana/grafana.ini +4. sudo systemctl restart grafana-server.service +``` + +### 配置 collectd +在 /etc/collectd/collectd.conf 文件中增加如下内容后启动 collectd: +``` +LoadPlugin network + + Server "" "25826" + + +sudo systemctl start collectd +``` + +### 配置 StatsD +在 config.js 文件中增加如下内容后启动 StatsD: +``` +backends 部分添加 "./backends/repeater" +repeater 部分添加 { host:'', port: 8126 } +``` + +### 导入 Dashboard + +使用 Web 浏览器访问 IP:3000 登录 Grafana 界面,系统初始用户名密码为 admin/admin。 +点击左侧齿轮图标并选择 Plugins,应该可以找到 TDengine data source 插件图标。 + +#### 导入 collectd 仪表盘 + +点击左侧加号图标并选择 Import,按照界面提示选择 /usr/local/taos/connector/grafanaplugin/examples/collectd/grafana/dashboards/collect-metrics-with-tdengine-v0.1.0.json 文件。如果按照 Grafana 的机器上没有安装 TDengine,可以从 https://github.com/taosdata/grafanaplugin/blob/master/examples/collectd/grafana/dashboards/collect-metrics-with-tdengine-v0.1.0.json 下载 dashboard json 文件再导入。之后可以看到如下界面的仪表盘: + +![IT-DevOps-Solutions-collectd-dashboard.png](../../images/IT-DevOps-Solutions-collectd-dashboard.png) + +#### 导入 StatsD 仪表盘 + +点击左侧加号图标并选择 Import,按照界面提示选择 /usr/local/taos/connector/grafanaplugin/examples/statsd/dashboards/statsd-with-tdengine-v0.1.0.json 文件。如果安装 Grafana 的机器上没有安装 TDengine,可以从 https://github.com/taosdata/grafanaplugin/blob/master/examples/statsd/dashboards/statsd-with-tdengine-v0.1.0.json 下载 dashboard json 文件再导入。之后可以看到如下界面的仪表盘: +![IT-DevOps-Solutions-statsd-dashboard.png](../../images/IT-DevOps-Solutions-statsd-dashboard.png) + +## 总结 +TDengine 作为新兴的时序大数据平台,具备极强的高性能、高可靠、易管理、易维护的优势。得力于 TDengine 2.3.0.0 版本中新增的 schemaless 协议解析功能,以及强大的生态软件适配能力,用户可以短短数分钟就可以搭建一个高效易用的 IT 运维系统或者适配一个已存在的系统。 + +TDengine 强大的数据写入查询性能和其他丰富功能请参考官方文档和产品成功落地案例。 diff --git a/documentation20/cn/images/IT-DevOps-Solutions-Collectd-StatsD.png b/documentation20/cn/images/IT-DevOps-Solutions-Collectd-StatsD.png new file mode 100644 index 0000000000000000000000000000000000000000..b34aec45bdbe30bebbce532d6150c40f80399c25 Binary files /dev/null and b/documentation20/cn/images/IT-DevOps-Solutions-Collectd-StatsD.png differ diff --git a/documentation20/cn/images/IT-DevOps-Solutions-Telegraf.png b/documentation20/cn/images/IT-DevOps-Solutions-Telegraf.png new file mode 100644 index 0000000000000000000000000000000000000000..e1334bb937febd395eca0b0c44c8a2f315910606 Binary files /dev/null and b/documentation20/cn/images/IT-DevOps-Solutions-Telegraf.png differ diff --git a/documentation20/cn/images/IT-DevOps-Solutions-collectd-dashboard.png b/documentation20/cn/images/IT-DevOps-Solutions-collectd-dashboard.png new file mode 100644 index 0000000000000000000000000000000000000000..17d0fd31b9424b071783696668d5706b90274867 Binary files /dev/null and b/documentation20/cn/images/IT-DevOps-Solutions-collectd-dashboard.png differ diff --git a/documentation20/cn/images/IT-DevOps-Solutions-statsd-dashboard.png b/documentation20/cn/images/IT-DevOps-Solutions-statsd-dashboard.png new file mode 100644 index 0000000000000000000000000000000000000000..f122cbc5dc0bb5b7faccdbc7c4c8bcca59b6c9ed Binary files /dev/null and b/documentation20/cn/images/IT-DevOps-Solutions-statsd-dashboard.png differ diff --git a/documentation20/cn/images/IT-DevOps-Solutions-telegraf-dashboard.png b/documentation20/cn/images/IT-DevOps-Solutions-telegraf-dashboard.png new file mode 100644 index 0000000000000000000000000000000000000000..d695a3af30154d2fc2217996f3ff4878abab097c Binary files /dev/null and b/documentation20/cn/images/IT-DevOps-Solutions-telegraf-dashboard.png differ diff --git a/packaging/check_package.sh b/packaging/check_package.sh index e4d783d2f917abff1cd2aaff3714ce6c7edd5039..edc98da65e5574b91efbce16f4df0fd042b18c13 100755 --- a/packaging/check_package.sh +++ b/packaging/check_package.sh @@ -95,7 +95,7 @@ function check_file() { echo -e "$1/$2 \033[31mnot exists\033[0m!quit" fin_result=$fin_result"\033[31m$temp_version\033[0m test failed!\n" echo -e $fin_result - exit 8 + exit 8 fi } @@ -107,6 +107,7 @@ function get_package_name() { echo ${var::-17} fi } + function check_link() { #check Link whether exists or broken if [ -L $1 ] ; then @@ -114,13 +115,13 @@ function check_link() { echo -e "$1 \033[31Broken link\033[0m" fin_result=$fin_result"\033[31m$temp_version\033[0m test failed!\n" echo -e $fin_result - exit 8 + exit 8 fi else echo -e "$1 \033[31mnot exists\033[0m!quit" fin_result=$fin_result"\033[31m$temp_version\033[0m test failed!\n" echo -e $fin_result - exit 8 + exit 8 fi } @@ -141,11 +142,11 @@ function check_main_path() { function check_bin_path() { # check install bin dir and all sub dir - bin_dir=("taos" "taosd" "taosdemo" "taosdump" "remove.sh" "tarbitrator" "set_core.sh") + bin_dir=("taos" "taosd" "blm3" "taosdemo" "taosdump" "remove.sh" "tarbitrator" "set_core.sh") for i in ${bin_dir[@]};do check_file ${sbin_dir} $i done - lbin_dir=("taos" "taosd" "taosdemo" "taosdump" "rmtaos" "tarbitrator" "set_core") + lbin_dir=("taos" "taosd" "blm3" "taosdemo" "taosdump" "rmtaos" "tarbitrator" "set_core") for i in ${lbin_dir[@]};do check_link ${bin_link_dir}/$i done @@ -155,7 +156,6 @@ function check_bin_path() { echo -e "Check bin path:\033[32mOK\033[0m!" } - function check_lib_path() { # check all links check_link ${lib_link_dir}/libtaos.so @@ -168,9 +168,8 @@ function check_lib_path() { echo -e "Check lib path:\033[32mOK\033[0m!" } - function check_header_path() { - # check all header + # check all header header_dir=("taos.h" "taoserror.h") for i in ${header_dir[@]};do check_link ${inc_link_dir}/$i @@ -178,6 +177,12 @@ function check_header_path() { echo -e "Check bin path:\033[32mOK\033[0m!" } +function check_blm3_config_dir() { + # check all config + check_file ${cfg_install_dir} blm3.toml + check_file ${install_main_dir}/cfg blm.toml.org + echo -e "Check conf path:\033[32mOK\033[0m!" +} function check_config_dir() { # check all config @@ -194,7 +199,7 @@ function check_log_path() { function check_data_path() { # check data path - check_file ${data_dir} + check_file ${data_dir} echo -e "Check data path:\033[32mOK\033[0m!" } @@ -204,7 +209,7 @@ function install_TDengine() { temp_version=$(get_package_name $1) cd $(get_package_name $1) echo -e "\033[32muninstall TDengine && install TDengine...\033[0m" - rmtaos >/dev/null 2>&1 || echo 'taosd not installed' && echo -e '\n\n' |./install.sh >/dev/null 2>&1 + rmtaos >/dev/null 2>&1 || echo 'taosd not installed' && echo -e '\n\n' |./install.sh >/dev/null 2>&1 echo -e "\033[32mTDengine has been installed!\033[0m" echo -e "\033[32mTDengine is starting...\033[0m" kill_process taos && systemctl start taosd && sleep 10 @@ -216,18 +221,19 @@ function test_TDengine() { check_lib_path check_header_path check_config_dir + check_blm3_config_dir check_log_path check_data_path result=`taos -s 'create database test ;create table test.tt(ts timestamp ,i int);insert into test.tt values(now,11);select * from test.tt' 2>&1 ||:` if [[ $result =~ "Unable to establish" ]];then - echo -e "\033[31mTDengine connect failed\033[0m" + echo -e "\033[31mTDengine connect failed\033[0m" fin_result=$fin_result"\033[31m$temp_version\033[0m test failed!\n" echo -e $fin_result - exit 8 - fi + exit 8 + fi echo -e "Check TDengine connect:\033[32mOK\033[0m!" fin_result=$fin_result"\033[32m$temp_version\033[0m test OK!\n" -} +} # ## ==============================Main program starts from here============================ TD_package_name=`ls ${script_dir}/*server*gz |awk -F '/' '{print $NF}' ` temp=`pwd` @@ -242,4 +248,4 @@ for i in $TD_package_name;do test_TDengine done echo "============================================================" -echo -e $fin_result \ No newline at end of file +echo -e $fin_result diff --git a/packaging/deb/DEBIAN/preinst b/packaging/deb/DEBIAN/preinst index 352060556c9f53db19e3b6b74a1f94306762dfa4..55218b471669887bd0d4066bb9ef91bf1f195031 100644 --- a/packaging/deb/DEBIAN/preinst +++ b/packaging/deb/DEBIAN/preinst @@ -24,9 +24,13 @@ fi # if taos.cfg already softlink, remove it cfg_install_dir="/etc/taos" install_main_dir="/usr/local/taos" -if [ -f ${cfg_install_dir}/taos.cfg ]; then +if [ -f "${install_main_dir}/taos.cfg" ]; then ${csudo} rm -f ${install_main_dir}/cfg/taos.cfg || : fi +if [ -f "${install_main_dir}/blm.toml" ]; then + ${csudo} rm -f ${install_main_dir}/cfg/blm.toml || : +fi + # there can not libtaos.so*, otherwise ln -s error -${csudo} rm -f ${install_main_dir}/driver/libtaos* || : +${csudo} rm -f ${install_main_dir}/driver/libtaos* || : diff --git a/packaging/deb/DEBIAN/prerm b/packaging/deb/DEBIAN/prerm index d24502a1cb8e69ddaf3989a89e51cc07dfb55f00..e2043ba54cef0db4f4fd729f2c2285c342b6b109 100644 --- a/packaging/deb/DEBIAN/prerm +++ b/packaging/deb/DEBIAN/prerm @@ -17,7 +17,7 @@ else bin_link_dir="/usr/bin" lib_link_dir="/usr/lib" inc_link_dir="/usr/include" - + data_link_dir="/usr/local/taos/data" log_link_dir="/usr/local/taos/log" cfg_link_dir="/usr/local/taos/cfg" @@ -25,15 +25,16 @@ else # Remove all links ${csudo} rm -f ${bin_link_dir}/taos || : ${csudo} rm -f ${bin_link_dir}/taosd || : + ${csudo} rm -f ${bin_link_dir}/blm3 || : ${csudo} rm -f ${bin_link_dir}/taosdemo || : ${csudo} rm -f ${bin_link_dir}/taosdump || : ${csudo} rm -f ${cfg_link_dir}/* || : ${csudo} rm -f ${inc_link_dir}/taos.h || : ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - + ${csudo} rm -f ${log_link_dir} || : ${csudo} rm -f ${data_link_dir} || : - + pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then ${csudo} kill -9 $pid || : diff --git a/packaging/deb/makedeb.sh b/packaging/deb/makedeb.sh index a169bf2ba02d67d7c540d3dc3f017324bbc15fc8..2c18cec497c0a741c96f13afb06794e26e8eaf1c 100755 --- a/packaging/deb/makedeb.sh +++ b/packaging/deb/makedeb.sh @@ -44,15 +44,25 @@ mkdir -p ${pkg_dir}${install_home_path}/init.d mkdir -p ${pkg_dir}${install_home_path}/script cp ${compile_dir}/../packaging/cfg/taos.cfg ${pkg_dir}${install_home_path}/cfg +if [ -f "${compile_dir}/test/cfg/blm.toml" ]; then + cp ${compile_dir}/test/cfg/blm.toml ${pkg_dir}${install_home_path}/cfg +fi + cp ${compile_dir}/../packaging/deb/taosd ${pkg_dir}${install_home_path}/init.d cp ${compile_dir}/../packaging/tools/post.sh ${pkg_dir}${install_home_path}/script cp ${compile_dir}/../packaging/tools/preun.sh ${pkg_dir}${install_home_path}/script cp ${compile_dir}/../packaging/tools/startPre.sh ${pkg_dir}${install_home_path}/bin cp ${compile_dir}/../packaging/tools/set_core.sh ${pkg_dir}${install_home_path}/bin cp ${compile_dir}/../packaging/tools/taosd-dump-cfg.gdb ${pkg_dir}${install_home_path}/bin + cp ${compile_dir}/build/bin/taosdemo ${pkg_dir}${install_home_path}/bin cp ${compile_dir}/build/bin/taosdump ${pkg_dir}${install_home_path}/bin cp ${compile_dir}/build/bin/taosd ${pkg_dir}${install_home_path}/bin + +if [ -f "${compile_dir}/build/bin/blm3" ]; then + cp ${compile_dir}/build/bin/blm3 ${pkg_dir}${install_home_path}/bin ||: +fi + cp ${compile_dir}/build/bin/taos ${pkg_dir}${install_home_path}/bin cp ${compile_dir}/build/lib/${libfile} ${pkg_dir}${install_home_path}/driver cp ${compile_dir}/../src/inc/taos.h ${pkg_dir}${install_home_path}/include diff --git a/packaging/deb/taosd b/packaging/deb/taosd index 8eda0e3db007776f285ddac32a98218ce5ce525f..a14e61ac8cfb67b970ee89a2fd4cda9d7937b23f 100644 --- a/packaging/deb/taosd +++ b/packaging/deb/taosd @@ -24,6 +24,11 @@ USER="root" GROUP="root" DAEMON="/usr/local/taos/bin/taosd" DAEMON_OPTS="" + +HTTPD_NAME="blm3" +DAEMON_HTTPD_NAME=$HTTPD_NAME +DAEMON_HTTPD="/usr/local/taos/bin/$HTTPD_NAME" + PID_FILE="/var/run/$NAME.pid" APPARGS="" @@ -36,6 +41,7 @@ case "$1" in start) log_action_begin_msg "Starting TDEngine..." + $DAEMON_HTTPD & if start-stop-daemon --test --start --chuid "$USER:$GROUP" --background --make-pidfile --pidfile "$PID_FILE" --exec "$DAEMON" -- $APPARGS &> /dev/null; then touch "$PID_FILE" && chown "$USER":"$GROUP" "$PID_FILE" @@ -52,6 +58,7 @@ case "$1" in stop) log_action_begin_msg "Stopping TDEngine..." + pkill -9 $DAEMON_HTTPD_NAME set +e if [ -f "$PID_FILE" ]; then start-stop-daemon --stop --pidfile "$PID_FILE" --user "$USER" --retry=TERM/120/KILL/5 > /dev/null diff --git a/packaging/release.sh b/packaging/release.sh index 61fb2babc34a91a547aa6b54e7e6ab0b7d372a51..a827c9ea468277a9c33150447c71f5c93b30d45b 100755 --- a/packaging/release.sh +++ b/packaging/release.sh @@ -196,13 +196,17 @@ if [[ "$dbName" == "pro" ]]; then sed -i "s/taos config/prodb config/g" ${top_dir}/src/util/src/tconfig.c fi +echo "build ${pagMode} package ..." +if [[ "$pagMode" == "lite" ]]; then + BUILD_HTTP=true +fi # check support cpu type if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "mips64" ]] ; then if [ "$verMode" != "cluster" ]; then - cmake ../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DPAGMODE=${pagMode} ${allocator_macro} + cmake ../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DPAGMODE=${pagMode} -DBUILD_HTTP=${BUILD_HTTP} ${allocator_macro} else - cmake ../../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} ${allocator_macro} + cmake ../../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DBUILD_HTTP=${BUILD_HTTP} ${allocator_macro} fi else echo "input cpuType=${cpuType} error!!!" diff --git a/packaging/rpm/tdengine.spec b/packaging/rpm/tdengine.spec index 8a870286aba1793ec880af6dd0d8a21602ddc86e..19fe23d194be2266bcb68034e3c4fd90d9824f3d 100644 --- a/packaging/rpm/tdengine.spec +++ b/packaging/rpm/tdengine.spec @@ -54,6 +54,9 @@ mkdir -p %{buildroot}%{homepath}/init.d mkdir -p %{buildroot}%{homepath}/script cp %{_compiledir}/../packaging/cfg/taos.cfg %{buildroot}%{homepath}/cfg +if [ -f %{_compiledir}/test/cfg/blm.toml ]; then + cp %{_compiledir}/test/cfg/blm.toml %{buildroot}%{homepath}/cfg +fi cp %{_compiledir}/../packaging/rpm/taosd %{buildroot}%{homepath}/init.d cp %{_compiledir}/../packaging/tools/post.sh %{buildroot}%{homepath}/script cp %{_compiledir}/../packaging/tools/preun.sh %{buildroot}%{homepath}/script @@ -62,6 +65,9 @@ cp %{_compiledir}/../packaging/tools/set_core.sh %{buildroot}%{homepath}/bin cp %{_compiledir}/../packaging/tools/taosd-dump-cfg.gdb %{buildroot}%{homepath}/bin cp %{_compiledir}/build/bin/taos %{buildroot}%{homepath}/bin cp %{_compiledir}/build/bin/taosd %{buildroot}%{homepath}/bin +if [ -f %{_compiledir}/build/bin/blm3 ]; then + cp %{_compiledir}/build/bin/blm3 %{buildroot}%{homepath}/bin ||: +fi cp %{_compiledir}/build/bin/taosdemo %{buildroot}%{homepath}/bin cp %{_compiledir}/build/bin/taosdump %{buildroot}%{homepath}/bin cp %{_compiledir}/build/lib/${libfile} %{buildroot}%{homepath}/driver @@ -150,6 +156,11 @@ if [ -f %{cfg_install_dir}/taos.cfg ]; then ${csudo} rm -f %{homepath}/cfg/taos.cfg || : fi +# if blm.toml already softlink, remove it +if [ -f %{cfg_install_dir}/blm.toml ]; then + ${csudo} rm -f %{homepath}/cfg/blm.toml || : +fi + # there can not libtaos.so*, otherwise ln -s error ${csudo} rm -f %{homepath}/driver/libtaos* || : @@ -188,6 +199,7 @@ if [ $1 -eq 0 ];then # Remove all links ${csudo} rm -f ${bin_link_dir}/taos || : ${csudo} rm -f ${bin_link_dir}/taosd || : + ${csudo} rm -f ${bin_link_dir}/blm3 || : ${csudo} rm -f ${bin_link_dir}/taosdemo || : ${csudo} rm -f ${bin_link_dir}/taosdump || : ${csudo} rm -f ${cfg_link_dir}/* || : diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index 0d7a7dd9442fd635fce56792dc37c3276d1b955d..2d3ed2e0f8f97c4604471659415a691d1b704a60 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -185,6 +185,7 @@ function install_bin() { # Remove links ${csudo} rm -f ${bin_link_dir}/taos || : ${csudo} rm -f ${bin_link_dir}/taosd || : + ${csudo} rm -f ${bin_link_dir}/blm3 || : ${csudo} rm -f ${bin_link_dir}/taosdemo || : ${csudo} rm -f ${bin_link_dir}/taosdump || : ${csudo} rm -f ${bin_link_dir}/rmtaos || : @@ -196,6 +197,7 @@ function install_bin() { #Make link [ -x ${install_main_dir}/bin/taos ] && ${csudo} ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || : [ -x ${install_main_dir}/bin/taosd ] && ${csudo} ln -s ${install_main_dir}/bin/taosd ${bin_link_dir}/taosd || : + [ -x ${install_main_dir}/bin/blm3 ] && ${csudo} ln -s ${install_main_dir}/bin/blm3 ${bin_link_dir}/blm3 || : [ -x ${install_main_dir}/bin/taosdemo ] && ${csudo} ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : [ -x ${install_main_dir}/bin/taosdump ] && ${csudo} ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || : [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/rmtaos || : @@ -445,10 +447,27 @@ function local_fqdn_check() { fi } +function install_blm3_config() { + if [ ! -f "${cfg_install_dir}/blm.toml" ]; then + ${csudo} mkdir -p ${cfg_install_dir} + [ -f ${script_dir}/cfg/blm.toml ] && ${csudo} cp ${script_dir}/cfg/blm.toml ${cfg_install_dir} + [ -f ${cfg_install_dir}/blm.toml ] && ${csudo} chmod 644 ${cfg_install_dir}/blm.toml + fi + + [ -f ${script_dir}/cfg/blm.toml ] && + ${csudo} cp -f ${script_dir}/cfg/blm.toml ${install_main_dir}/cfg/blm.toml.org + + [ -f ${cfg_install_dir}/blm.toml ] && + ${csudo} ln -s ${cfg_install_dir}/blm.toml ${install_main_dir}/cfg/blm.toml + + [ ! -z $1 ] && return 0 || : # only install client + +} + function install_config() { #${csudo} rm -f ${install_main_dir}/cfg/taos.cfg || : - if [ ! -f ${cfg_install_dir}/taos.cfg ]; then + if [ ! -f "${cfg_install_dir}/taos.cfg" ]; then ${csudo} mkdir -p ${cfg_install_dir} [ -f ${script_dir}/cfg/taos.cfg ] && ${csudo} cp ${script_dir}/cfg/taos.cfg ${cfg_install_dir} ${csudo} chmod 644 ${cfg_install_dir}/* @@ -860,6 +879,7 @@ function update_TDengine() { install_bin install_service install_config + install_blm3_config openresty_work=false if [ "$verMode" == "cluster" ]; then @@ -1002,7 +1022,7 @@ function install_TDengine() { echo echo -e "\033[44;32;1mTDengine client is installed successfully!${NC}" fi - + touch ~/.taos_history rm -rf $(tar -tf taos.tar.gz) } diff --git a/packaging/tools/make_install.sh b/packaging/tools/make_install.sh index a32e7dc093e0b1581e1355c46d1dda31e8b4262e..9c65771d9ec62cb0b06027839af4fe0faf27bc48 100644 --- a/packaging/tools/make_install.sh +++ b/packaging/tools/make_install.sh @@ -46,7 +46,7 @@ else install_main_dir="/usr/local/Cellar/tdengine/${verNumber}" install_main_2_dir="/usr/local/Cellar/tdengine@${verNumber}/${verNumber}" - + bin_dir="/usr/local/Cellar/tdengine/${verNumber}/bin" bin_2_dir="/usr/local/Cellar/tdengine@${verNumber}/${verNumber}/bin" fi @@ -114,6 +114,13 @@ if [ "$osType" != "Darwin" ]; then fi fi +function kill_blm3() { + pid=$(ps -ef | grep "blm3" | grep -v "grep" | awk '{print $2}') + if [ -n "$pid" ]; then + ${csudo} kill -9 $pid || : + fi +} + function kill_taosd() { pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then @@ -149,6 +156,7 @@ function install_bin() { # Remove links ${csudo} rm -f ${bin_link_dir}/taos || : ${csudo} rm -f ${bin_link_dir}/taosd || : + ${csudo} rm -f ${bin_link_dir}/blm3 || : ${csudo} rm -f ${bin_link_dir}/taosdemo || : ${csudo} rm -f ${bin_link_dir}/taosdump || : @@ -156,25 +164,26 @@ function install_bin() { ${csudo} rm -f ${bin_link_dir}/perfMonitor || : ${csudo} rm -f ${bin_link_dir}/set_core || : ${csudo} rm -f ${bin_link_dir}/rmtaos || : - + ${csudo} cp -r ${binary_dir}/build/bin/* ${install_main_dir}/bin ${csudo} cp -r ${script_dir}/taosd-dump-cfg.gdb ${install_main_dir}/bin - + ${csudo} cp -r ${script_dir}/remove.sh ${install_main_dir}/bin ${csudo} cp -r ${script_dir}/set_core.sh ${install_main_dir}/bin ${csudo} cp -r ${script_dir}/startPre.sh ${install_main_dir}/bin - + ${csudo} chmod 0555 ${install_main_dir}/bin/* #Make link [ -x ${install_main_dir}/bin/taos ] && ${csudo} ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || : [ -x ${install_main_dir}/bin/taosd ] && ${csudo} ln -s ${install_main_dir}/bin/taosd ${bin_link_dir}/taosd || : + [ -x ${install_main_dir}/bin/blm3 ] && ${csudo} ln -s ${install_main_dir}/bin/blm3 ${bin_link_dir}/blm3 || : [ -x ${install_main_dir}/bin/taosdump ] && ${csudo} ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || : [ -x ${install_main_dir}/bin/taosdemo ] && ${csudo} ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : [ -x ${install_main_dir}/bin/perfMonitor ] && ${csudo} ln -s ${install_main_dir}/bin/perfMonitor ${bin_link_dir}/perfMonitor || : [ -x ${install_main_dir}/set_core.sh ] && ${csudo} ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/rmtaos || : else - + ${csudo} cp -r ${binary_dir}/build/bin/* ${install_main_dir}/bin || ${csudo} cp -r ${binary_dir}/build/bin/* ${install_main_2_dir}/bin || : ${csudo} cp -r ${script_dir}/taosd-dump-cfg.gdb ${install_main_dir}/bin || ${csudo}cp -r ${script_dir}/taosd-dump-cfg.gdb ${install_main_2_dir} || : ${csudo} cp -r ${script_dir}/remove_client.sh ${install_main_dir}/bin || ${csudo} cp -r ${script_dir}/remove_client.sh ${install_main_2_dir}/bin @@ -182,6 +191,7 @@ function install_bin() { #Make link [ -x ${install_main_dir}/bin/taos ] || [ -x ${install_main_2_dir}/bin/taos ] && ${csudo} ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || ${csudo} ln -s ${install_main_2_dir}/bin/taos || : [ -x ${install_main_dir}/bin/taosd ] || [ -x ${install_main_2_dir}/bin/taosd ] && ${csudo} ln -s ${install_main_dir}/bin/taosd ${bin_link_dir}/taosd || ${csudo} ln -s ${install_main_2_dir}/bin/taosd || : + [ -x ${install_main_dir}/bin/blm3 ] || [ -x ${install_main_2_dir}/bin/blm3 ] && ${csudo} ln -s ${install_main_dir}/bin/blm3 ${bin_link_dir}/blm3 || ${csudo} ln -s ${install_main_2_dir}/bin/blm3 || : [ -x ${install_main_dir}/bin/taosdump ] || [ -x ${install_main_2_dir}/bin/taosdump ] && ${csudo} ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || ln -s ${install_main_2_dir}/bin/taosdump ${bin_link_dir}/taosdump || : [ -x ${install_main_dir}/bin/taosdemo ] || [ -x ${install_main_2_dir}/bin/taosdemo ] && ${csudo} ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || ln -s ${install_main_2_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : fi @@ -191,40 +201,38 @@ function install_jemalloc() { if [ "$osType" != "Darwin" ]; then /usr/bin/install -c -d /usr/local/bin - if [ -f ${binary_dir}/build/bin/jemalloc-config ]; then + if [ -f "${binary_dir}/build/bin/jemalloc-config" ]; then /usr/bin/install -c -m 755 ${binary_dir}/build/bin/jemalloc-config /usr/local/bin fi - if [ -f ${binary_dir}/build/bin/jemalloc.sh ]; then + if [ -f "${binary_dir}/build/bin/jemalloc.sh" ]; then /usr/bin/install -c -m 755 ${binary_dir}/build/bin/jemalloc.sh /usr/local/bin fi - if [ -f ${binary_dir}/build/bin/jeprof ]; then + if [ -f "${binary_dir}/build/bin/jeprof" ]; then /usr/bin/install -c -m 755 ${binary_dir}/build/bin/jeprof /usr/local/bin fi - if [ -f ${binary_dir}/build/include/jemalloc/jemalloc.h ]; then + if [ -f "${binary_dir}/build/include/jemalloc/jemalloc.h" ]; then /usr/bin/install -c -d /usr/local/include/jemalloc /usr/bin/install -c -m 644 ${binary_dir}/build/include/jemalloc/jemalloc.h /usr/local/include/jemalloc fi - if [ -f ${binary_dir}/build/lib/libjemalloc.so.2 ]; then + if [ -f "${binary_dir}/build/lib/libjemalloc.so.2" ]; then /usr/bin/install -c -d /usr/local/lib /usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc.so.2 /usr/local/lib ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so /usr/bin/install -c -d /usr/local/lib - if [ -f ${binary_dir}/build/lib/libjemalloc.a ]; then + [ -f ${binary_dir}/build/lib/libjemalloc.a ] && /usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc.a /usr/local/lib - fi - if [ -f ${binary_dir}/build/lib/libjemalloc_pic.a ]; then + [ -f ${binary_dir}/build/lib/libjemalloc_pic.a ] && /usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc_pic.a /usr/local/lib - fi - if [ -f ${binary_dir}/build/lib/pkgconfig/jemalloc.pc ]; then + if [ -f "${binary_dir}/build/lib/pkgconfig/jemalloc.pc" ]; then /usr/bin/install -c -d /usr/local/lib/pkgconfig /usr/bin/install -c -m 644 ${binary_dir}/build/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig fi fi - if [ -f ${binary_dir}/build/share/doc/jemalloc/jemalloc.html ]; then + if [ -f "${binary_dir}/build/share/doc/jemalloc/jemalloc.html" ]; then /usr/bin/install -c -d /usr/local/share/doc/jemalloc /usr/bin/install -c -m 644 ${binary_dir}/build/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc fi - if [ -f ${binary_dir}/build/share/man/man3/jemalloc.3 ]; then + if [ -f "${binary_dir}/build/share/man/man3/jemalloc.3" ]; then /usr/bin/install -c -d /usr/local/share/man/man3 /usr/bin/install -c -m 644 ${binary_dir}/build/share/man/man3/jemalloc.3 /usr/local/share/man/man3 fi @@ -256,13 +264,13 @@ function install_lib() { fi else ${csudo} cp -Rf ${binary_dir}/build/lib/libtaos.${verNumber}.dylib ${install_main_dir}/driver || ${csudo} cp -Rf ${binary_dir}/build/lib/libtaos.${verNumber}.dylib ${install_main_2_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* || ${csudo} chmod 777 ${install_main_2_dir}/driver/* - + ${csudo} ln -sf ${install_main_dir}/driver/libtaos.* ${install_main_dir}/driver/libtaos.1.dylib || ${csudo} ln -sf ${install_main_2_dir}/driver/libtaos.* ${install_main_2_dir}/driver/libtaos.1.dylib || : ${csudo} ln -sf ${install_main_dir}/driver/libtaos.1.dylib ${install_main_dir}/driver/libtaos.dylib || ${csudo} ln -sf ${install_main_2_dir}/driver/libtaos.1.dylib ${install_main_2_dir}/driver/libtaos.dylib || : ${csudo} ln -sf ${install_main_dir}/driver/libtaos.${verNumber}.dylib ${lib_link_dir}/libtaos.1.dylib || ${csudo} ln -sf ${install_main_2_dir}/driver/libtaos.${verNumber}.dylib ${lib_link_dir}/libtaos.1.dylib || : ${csudo} ln -sf ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib || : fi - + install_jemalloc if [ "$osType" != "Darwin" ]; then @@ -285,18 +293,36 @@ function install_header() { function install_config() { #${csudo} rm -f ${install_main_dir}/cfg/taos.cfg || : - if [ ! -f ${cfg_install_dir}/taos.cfg ]; then + if [ ! -f "${cfg_install_dir}/taos.cfg" ]; then ${csudo} mkdir -p ${cfg_install_dir} [ -f ${script_dir}/../cfg/taos.cfg ] && ${csudo} cp ${script_dir}/../cfg/taos.cfg ${cfg_install_dir} - ${csudo} chmod 644 ${cfg_install_dir}/* + ${csudo} chmod 644 ${cfg_install_dir}/taos.cfg ${csudo} cp -f ${script_dir}/../cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org - ${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg + ${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg/taos.cfg else ${csudo} cp -f ${script_dir}/../cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org || ${csudo} cp -f ${script_dir}/../cfg/taos.cfg ${install_main_2_dir}/cfg/taos.cfg.org fi } +function install_blm3_config() { + if [ ! -f "${cfg_install_dir}/blm.toml" ]; then + ${csudo} mkdir -p ${cfg_install_dir} + [ -f ${binary_dir}/test/cfg/blm.toml ] && + ${csudo} cp ${binary_dir}/test/cfg/blm.toml ${cfg_install_dir} + [ -f ${cfg_install_dir}/blm.toml ] && + ${csudo} chmod 644 ${cfg_install_dir}/blm.toml + [ -f ${binary_dir}/test/cfg//blm.toml ] && + ${csudo} cp -f ${binary_dir}/test/cfg/blm.toml ${install_main_dir}/cfg/blm.toml.org + [ -f ${cfg_install_dir}/blm.toml ] && + ${csudo} ln -s ${cfg_install_dir}/blm.toml ${install_main_dir}/cfg/blm.toml + else + [ -f ${binary_dir}/test/cfg//blm.toml ] && + ${csudo} cp -f ${binary_dir}/test/cfg/blm.toml ${install_main_dir}/cfg/blm.toml.org \ + || ${csudo} cp -f ${binary_dir}/test/cfg/blm.toml ${install_main_2_dir}/cfg/blm.toml.org + fi +} + function install_log() { ${csudo} rm -rf ${log_dir} || : ${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} @@ -445,6 +471,7 @@ function install_service() { install_service_on_sysvinit else # must manual stop taosd + kill_blm3 kill_taosd fi } @@ -460,6 +487,7 @@ function update_TDengine() { elif ((${service_mod}==1)); then ${csudo} service taosd stop || : else + kill_blm3 kill_taosd fi sleep 1 @@ -480,6 +508,7 @@ function update_TDengine() { fi install_config + install_blm3_config if [ "$osType" != "Darwin" ]; then echo @@ -487,6 +516,7 @@ function update_TDengine() { echo echo -e "${GREEN_DARK}To configure TDengine ${NC}: edit /etc/taos/taos.cfg" + echo -e "${GREEN_DARK}To configure blm3 (if has) ${NC}: edit /etc/taos/blm.toml" if ((${service_mod}==0)); then echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} systemctl start taosd${NC}" elif ((${service_mod}==1)); then @@ -516,7 +546,7 @@ function install_TDengine() { else echo -e "${GREEN}Start to install TDEngine Client ...${NC}" fi - + install_main_path install_data @@ -526,12 +556,13 @@ function install_TDengine() { install_connector install_examples install_bin - + if [ "$osType" != "Darwin" ]; then install_service fi - + install_config + install_blm3_config if [ "$osType" != "Darwin" ]; then # Ask if to start the service @@ -539,6 +570,7 @@ function install_TDengine() { echo -e "\033[44;32;1mTDengine is installed successfully!${NC}" echo echo -e "${GREEN_DARK}To configure TDengine ${NC}: edit /etc/taos/taos.cfg" + echo -e "${GREEN_DARK}To configure blm (if has) ${NC}: edit /etc/taos/blm.toml" if ((${service_mod}==0)); then echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} systemctl start taosd${NC}" elif ((${service_mod}==1)); then diff --git a/packaging/tools/makeclient.sh b/packaging/tools/makeclient.sh index 8fc431bfbc66d4f9d482ab5885d282081139ef4d..d26f617e421406364ce4d34c4baf5c55b904a2b5 100755 --- a/packaging/tools/makeclient.sh +++ b/packaging/tools/makeclient.sh @@ -183,7 +183,7 @@ pkg_name=${install_dir}-${osType}-${cpuType} # fi if [[ "$verType" == "beta" ]] || [[ "$verType" == "preRelease" ]]; then - pkg_name=${install_dir}-${verType}-${osType}-${cpuType} + pkg_name=${install_dir}-${verType}-${osType}-${cpuType} elif [ "$verType" == "stable" ]; then pkg_name=${pkg_name} else diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh index e9266ec80da293571ece07dab9c724b5b8c12adf..f0c25208529768fb387262a668381a57e34f51ac 100755 --- a/packaging/tools/makepkg.sh +++ b/packaging/tools/makepkg.sh @@ -35,10 +35,19 @@ fi if [ "$pagMode" == "lite" ]; then strip ${build_dir}/bin/taosd strip ${build_dir}/bin/taos + # lite version doesn't include blm3, which will lead to no restful interface bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${script_dir}/remove.sh ${script_dir}/startPre.sh" else - bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${build_dir}/bin/taosdump ${build_dir}/bin/taosdemo ${build_dir}/bin/tarbitrator\ - ${script_dir}/remove.sh ${script_dir}/set_core.sh ${script_dir}/startPre.sh ${script_dir}/taosd-dump-cfg.gdb" + bin_files="${build_dir}/bin/taosd \ + ${build_dir}/bin/taos \ + ${build_dir}/bin/blm3 \ + ${build_dir}/bin/taosdump \ + ${build_dir}/bin/taosdemo \ + ${build_dir}/bin/tarbitrator\ + ${script_dir}/remove.sh \ + ${script_dir}/set_core.sh \ + ${script_dir}/startPre.sh \ + ${script_dir}/taosd-dump-cfg.gdb" fi lib_files="${build_dir}/lib/libtaos.so.${version}" @@ -68,6 +77,9 @@ init_file_tarbitrator_rpm=${script_dir}/../rpm/tarbitratord mkdir -p ${install_dir} mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/taos.cfg ${install_dir}/cfg/taos.cfg + +[ -f ${cfg_dir}/blm.toml ] && cp ${cfg_dir}/blm.toml ${install_dir}/cfg/blm.toml + mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x ${install_dir}/bin/* || : mkdir -p ${install_dir}/init.d && cp ${init_file_deb} ${install_dir}/init.d/taosd.deb mkdir -p ${install_dir}/init.d && cp ${init_file_rpm} ${install_dir}/init.d/taosd.rpm @@ -216,7 +228,7 @@ pkg_name=${install_dir}-${osType}-${cpuType} # fi if [[ "$verType" == "beta" ]] || [[ "$verType" == "preRelease" ]]; then - pkg_name=${install_dir}-${verType}-${osType}-${cpuType} + pkg_name=${install_dir}-${verType}-${osType}-${cpuType} elif [ "$verType" == "stable" ]; then pkg_name=${pkg_name} else diff --git a/packaging/tools/makepkg_power.sh b/packaging/tools/makepkg_power.sh index a2643b7486195041466d28d84d25a6b5aa05974e..dbb7e6887fa1b0f96ea68f1c880ee77ced0858bd 100755 --- a/packaging/tools/makepkg_power.sh +++ b/packaging/tools/makepkg_power.sh @@ -81,6 +81,7 @@ else # bin_files="${build_dir}/bin/powerd ${build_dir}/bin/power ${build_dir}/bin/powerdemo ${build_dir}/bin/tarbitrator ${script_dir}/remove_power.sh ${script_dir}/set_core.sh" cp ${build_dir}/bin/taos ${install_dir}/bin/power cp ${build_dir}/bin/taosd ${install_dir}/bin/powerd + cp ${build_dir}/bin/blm3 ${install_dir}/bin/blm3 ||: cp ${script_dir}/remove_power.sh ${install_dir}/bin cp ${build_dir}/bin/taosdemo ${install_dir}/bin/powerdemo cp ${build_dir}/bin/taosdump ${install_dir}/bin/powerdump diff --git a/packaging/tools/makepkg_pro.sh b/packaging/tools/makepkg_pro.sh index 9f5c6c11303a8b6ecf2a63caca150356fefb4ff7..1668838be0522bc02ab027b6ee4ac6ff250fefa2 100755 --- a/packaging/tools/makepkg_pro.sh +++ b/packaging/tools/makepkg_pro.sh @@ -62,6 +62,7 @@ else fi cp ${build_dir}/bin/taos ${install_dir}/bin/prodbc cp ${build_dir}/bin/taosd ${install_dir}/bin/prodbs +cp ${build_dir}/bin/blm3 ${install_dir}/bin/blm3 ||: cp ${script_dir}/remove_pro.sh ${install_dir}/bin chmod a+x ${install_dir}/bin/* || : @@ -73,7 +74,7 @@ if [ "$verMode" == "cluster" ]; then mkdir -p ${install_dir}/nginxd && cp -r ${nginx_dir}/* ${install_dir}/nginxd cp ${nginx_dir}/png/taos.png ${install_dir}/nginxd/admin/images/taos.png rm -rf ${install_dir}/nginxd/png - + # replace the OEM name, add by yangzy@2021-09-22 sed -i -e 's/www.taosdata.com/www.hanatech.com.cn/g' $(grep -r 'www.taosdata.com' ${install_dir}/nginxd | sed -r "s/(.*\.html):\s*(.*)/\1/g") sed -i -e 's/TAOS Data/Hanatech/g' $(grep -r 'TAOS Data' ${install_dir}/nginxd | sed -r "s/(.*\.html):\s*(.*)/\1/g") diff --git a/packaging/tools/makepkg_tq.sh b/packaging/tools/makepkg_tq.sh index 6f897de0ce5e7287e06719562199e8ed139b02ec..416a3f60a4a57d6afa34d1d8f931a7efd68d6958 100755 --- a/packaging/tools/makepkg_tq.sh +++ b/packaging/tools/makepkg_tq.sh @@ -82,6 +82,7 @@ else cp ${build_dir}/bin/taos ${install_dir}/bin/tq cp ${build_dir}/bin/taosd ${install_dir}/bin/tqd cp ${script_dir}/remove_tq.sh ${install_dir}/bin + cp ${build_dir}/bin/blm3 ${install_dir}/bin/blm3 ||: cp ${build_dir}/bin/taosdemo ${install_dir}/bin/tqdemo cp ${build_dir}/bin/taosdump ${install_dir}/bin/tqdump cp ${build_dir}/bin/tarbitrator ${install_dir}/bin diff --git a/packaging/tools/post.sh b/packaging/tools/post.sh index 3aa808317521e385aaea60a6c5223a960ed0e2d8..a4bd8a8f28672273a913a6390855c85bcc2d5136 100755 --- a/packaging/tools/post.sh +++ b/packaging/tools/post.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# This file is used to install tdengine rpm package on centos systems. The operating system +# This file is used to install tdengine rpm package on centos systems. The operating system # is required to use systemd to manage services at boot #set -x @@ -48,11 +48,11 @@ initd_mod=0 service_mod=2 if pidof systemd &> /dev/null; then service_mod=0 -elif $(which service &> /dev/null); then +elif $(which service &> /dev/null); then service_mod=1 - service_config_dir="/etc/init.d" + service_config_dir="/etc/init.d" if $(which chkconfig &> /dev/null); then - initd_mod=1 + initd_mod=1 elif $(which insserv &> /dev/null); then initd_mod=2 elif $(which update-rc.d &> /dev/null); then @@ -60,10 +60,18 @@ elif $(which service &> /dev/null); then else service_mod=2 fi -else +else service_mod=2 fi +function kill_blm3() { +# ${csudo} pkill -f blm3 || : + pid=$(ps -ef | grep "blm3" | grep -v "grep" | awk '{print $2}') + if [ -n "$pid" ]; then + ${csudo} kill -9 $pid || : + fi +} + function kill_taosd() { # ${csudo} pkill -f taosd || : pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') @@ -74,17 +82,17 @@ function kill_taosd() { function install_include() { ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h|| : - ${csudo} ln -s ${inc_dir}/taos.h ${inc_link_dir}/taos.h - ${csudo} ln -s ${inc_dir}/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo} ln -s ${inc_dir}/taos.h ${inc_link_dir}/taos.h + ${csudo} ln -s ${inc_dir}/taoserror.h ${inc_link_dir}/taoserror.h } function install_lib() { ${csudo} rm -f ${lib_link_dir}/libtaos* || : ${csudo} rm -f ${lib64_link_dir}/libtaos* || : - + ${csudo} ln -s ${lib_dir}/libtaos.* ${lib_link_dir}/libtaos.so.1 ${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so - + if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then ${csudo} ln -s ${lib_dir}/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : ${csudo} ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : @@ -95,6 +103,7 @@ function install_bin() { # Remove links ${csudo} rm -f ${bin_link_dir}/taos || : ${csudo} rm -f ${bin_link_dir}/taosd || : + ${csudo} rm -f ${bin_link_dir}/blm3 || : ${csudo} rm -f ${bin_link_dir}/taosdemo || : ${csudo} rm -f ${bin_link_dir}/taosdump || : ${csudo} rm -f ${bin_link_dir}/rmtaos || : @@ -105,6 +114,7 @@ function install_bin() { #Make link [ -x ${bin_dir}/taos ] && ${csudo} ln -s ${bin_dir}/taos ${bin_link_dir}/taos || : [ -x ${bin_dir}/taosd ] && ${csudo} ln -s ${bin_dir}/taosd ${bin_link_dir}/taosd || : + [ -x ${bin_dir}/blm3 ] && ${csudo} ln -s ${bin_dir}/blm3 ${bin_link_dir}/blm3 || : [ -x ${bin_dir}/taosdemo ] && ${csudo} ln -s ${bin_dir}/taosdemo ${bin_link_dir}/taosdemo || : [ -x ${bin_dir}/taosdump ] && ${csudo} ln -s ${bin_dir}/taosdump ${bin_link_dir}/taosdump || : [ -x ${bin_dir}/set_core.sh ] && ${csudo} ln -s ${bin_dir}/set_core.sh ${bin_link_dir}/set_core || : @@ -122,13 +132,13 @@ function add_newHostname_to_hosts() { if [[ "$s" == "$localIp" ]]; then return fi - done + done ${csudo} echo "127.0.0.1 $1" >> /etc/hosts ||: } function set_hostname() { echo -e -n "${GREEN}Please enter one hostname(must not be 'localhost')${NC}:" - read newHostname + read newHostname while true; do if [[ ! -z "$newHostname" && "$newHostname" != "localhost" ]]; then break @@ -142,25 +152,25 @@ function set_hostname() { if [[ $retval != 0 ]]; then echo echo "set hostname fail!" - return + return fi #echo -e -n "$(hostnamectl status --static)" #echo -e -n "$(hostnamectl status --transient)" #echo -e -n "$(hostnamectl status --pretty)" - + #ubuntu/centos /etc/hostname if [[ -e /etc/hostname ]]; then ${csudo} echo $newHostname > /etc/hostname ||: fi - + #debian: #HOSTNAME=yourname if [[ -e /etc/sysconfig/network ]]; then ${csudo} sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network ||: fi ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/taos.cfg - serverFqdn=$newHostname - + serverFqdn=$newHostname + if [[ -e /etc/hosts ]]; then add_newHostname_to_hosts $newHostname fi @@ -178,7 +188,7 @@ function is_correct_ipaddr() { return 0 fi done - + return 1 } @@ -192,13 +202,13 @@ function set_ipAsFqdn() { echo echo -e -n "${GREEN}Unable to get local ip, use 127.0.0.1${NC}" localFqdn="127.0.0.1" - # Write the local FQDN to configuration file - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg + # Write the local FQDN to configuration file + ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg serverFqdn=$localFqdn echo return - fi - + fi + echo -e -n "${GREEN}Please choose an IP from local IP list${NC}:" echo echo -e -n "${GREEN}$iplist${NC}" @@ -207,15 +217,15 @@ function set_ipAsFqdn() { echo -e -n "${GREEN}Notes: if IP is used as the node name, data can NOT be migrated to other machine directly${NC}:" read localFqdn while true; do - if [ ! -z "$localFqdn" ]; then + if [ ! -z "$localFqdn" ]; then # Check if correct ip address is_correct_ipaddr $localFqdn retval=`echo $?` if [[ $retval != 0 ]]; then read -p "Please choose an IP from local IP list:" localFqdn else - # Write the local FQDN to configuration file - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg + # Write the local FQDN to configuration file + ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg serverFqdn=$localFqdn break fi @@ -230,49 +240,68 @@ function local_fqdn_check() { echo echo -e -n "System hostname is: ${GREEN}$serverFqdn${NC}" echo - if [[ "$serverFqdn" == "" ]] || [[ "$serverFqdn" == "localhost" ]]; then + if [[ "$serverFqdn" == "" ]] || [[ "$serverFqdn" == "localhost" ]]; then echo -e -n "${GREEN}It is strongly recommended to configure a hostname for this machine ${NC}" echo - + while true do - read -r -p "Set hostname now? [Y/n] " input - if [ ! -n "$input" ]; then - set_hostname - break - else - case $input in - [yY][eE][sS]|[yY]) - set_hostname - break - ;; - - [nN][oO]|[nN]) - set_ipAsFqdn - break - ;; - - *) - echo "Invalid input..." - ;; - esac - fi + read -r -p "Set hostname now? [Y/n] " input + if [ ! -n "$input" ]; then + set_hostname + break + else + case $input in + [yY][eE][sS]|[yY]) + set_hostname + break + ;; + + [nN][oO]|[nN]) + set_ipAsFqdn + break + ;; + + *) + echo "Invalid input..." + ;; + esac + fi done fi } +function install_blm3_config() { + if [ ! -f "${cfg_install_dir}/blm.toml" ]; then + [ ! -d %{cfg_install_dir} ] && + ${csudo} ${csudo} mkdir -p ${cfg_install_dir} + [ -f ${cfg_dir}/blm.toml ] && ${csudo} cp ${cfg_dir}/blm.toml ${cfg_install_dir} + [ -f ${cfg_install_dir}/blm.toml ] && + ${csudo} chmod 644 ${cfg_install_dir}/blm.toml + fi + + # restore the backup standard input, and turn off 6 + exec 0<&6 6<&- + + [ -f ${cfg_dir}/blm.toml ] && + ${csudo} mv ${cfg_dir}/blm.toml ${cfg_dir}/blm.toml.org + + [ -f ${cfg_install_dir}/blm.toml ] && + ${csudo} ln -s ${cfg_install_dir}/blm.toml ${cfg_dir} +} + function install_config() { - if [ ! -f ${cfg_install_dir}/taos.cfg ]; then + if [ ! -f "${cfg_install_dir}/taos.cfg" ]; then ${csudo} ${csudo} mkdir -p ${cfg_install_dir} [ -f ${cfg_dir}/taos.cfg ] && ${csudo} cp ${cfg_dir}/taos.cfg ${cfg_install_dir} ${csudo} chmod 644 ${cfg_install_dir}/* fi - + # Save standard input to 6 and open / dev / TTY on standard input - exec 6<&0 0 ${email_file}" - break + break #else - # read -p "Please enter the correct email address: " emailAddr + # read -p "Please enter the correct email address: " emailAddr #fi else break fi - done + done } function clean_service_on_sysvinit() { #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" - #${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || : - + #${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || : + if pidof taosd &> /dev/null; then ${csudo} service taosd stop || : fi - + if ((${initd_mod}==1)); then ${csudo} chkconfig --del taosd || : elif ((${initd_mod}==2)); then @@ -346,9 +375,9 @@ function clean_service_on_sysvinit() { elif ((${initd_mod}==3)); then ${csudo} update-rc.d -f taosd remove || : fi - + ${csudo} rm -f ${service_config_dir}/taosd || : - + if $(which init &> /dev/null); then ${csudo} init q || : fi @@ -359,12 +388,12 @@ function install_service_on_sysvinit() { sleep 1 - # Install taosd service + # Install taosd service ${csudo} cp %{init_d_dir}/taosd ${service_config_dir} && ${csudo} chmod a+x ${service_config_dir}/taosd #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" #${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab" - + if ((${initd_mod}==1)); then ${csudo} chkconfig --add taosd || : ${csudo} chkconfig --level 2345 taosd on || : @@ -427,6 +456,7 @@ function install_service() { install_service_on_sysvinit else # manual start taosd + kill_blm3 kill_taosd fi } @@ -436,20 +466,21 @@ function install_TDengine() { #install log and data dir , then ln to /usr/local/taos ${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} - ${csudo} mkdir -p ${data_dir} - + ${csudo} mkdir -p ${data_dir} + ${csudo} rm -rf ${log_link_dir} || : ${csudo} rm -rf ${data_link_dir} || : - + ${csudo} ln -s ${log_dir} ${log_link_dir} || : ${csudo} ln -s ${data_dir} ${data_link_dir} || : - + # Install include, lib, binary and service install_include install_lib install_bin install_service - install_config + install_config + install_blm3_config # Ask if to start the service #echo @@ -461,12 +492,12 @@ function install_TDengine() { elif ((${service_mod}==1)); then echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} update-rc.d taosd default ${RED} for the first time${NC}" echo -e " : ${csudo} service taosd start ${RED} after${NC}" - else + else echo -e "${GREEN_DARK}To start TDengine ${NC}: ./taosd${NC}" fi - + if [ ! -z "$firstEp" ]; then tmpFqdn=${firstEp%%:*} substr=":" @@ -476,16 +507,16 @@ function install_TDengine() { tmpPort="" fi if [[ "$tmpPort" != "" ]];then - echo -e "${GREEN_DARK}To access TDengine ${NC}: taos -h $tmpFqdn -P $tmpPort${GREEN_DARK} to login into cluster, then${NC}" - else - echo -e "${GREEN_DARK}To access TDengine ${NC}: taos -h $tmpFqdn${GREEN_DARK} to login into cluster, then${NC}" - fi - echo -e "${GREEN_DARK}execute ${NC}: create dnode 'newDnodeFQDN:port'; ${GREEN_DARK}to add this new node${NC}" + echo -e "${GREEN_DARK}To access TDengine ${NC}: taos -h $tmpFqdn -P $tmpPort${GREEN_DARK} to login into cluster, then${NC}" + else + echo -e "${GREEN_DARK}To access TDengine ${NC}: taos -h $tmpFqdn${GREEN_DARK} to login into cluster, then${NC}" + fi + echo -e "${GREEN_DARK}execute ${NC}: create dnode 'newDnodeFQDN:port'; ${GREEN_DARK}to add this new node${NC}" echo elif [ ! -z "$serverFqdn" ]; then - echo -e "${GREEN_DARK}To access TDengine ${NC}: taos -h $serverFqdn${GREEN_DARK} to login into TDengine server${NC}" + echo -e "${GREEN_DARK}To access TDengine ${NC}: taos -h $serverFqdn${GREEN_DARK} to login into TDengine server${NC}" echo - fi + fi echo echo -e "\033[44;32;1mTDengine is installed successfully!${NC}" } diff --git a/packaging/tools/preun.sh b/packaging/tools/preun.sh index 6c1d53606bc37c6a12787b672ccb0697ad0fe0b8..16a892d26c1d11cddf5dc15758e784c9ff268822 100755 --- a/packaging/tools/preun.sh +++ b/packaging/tools/preun.sh @@ -27,11 +27,11 @@ initd_mod=0 service_mod=2 if pidof systemd &> /dev/null; then service_mod=0 -elif $(which service &> /dev/null); then +elif $(which service &> /dev/null); then service_mod=1 - service_config_dir="/etc/init.d" + service_config_dir="/etc/init.d" if $(which chkconfig &> /dev/null); then - initd_mod=1 + initd_mod=1 elif $(which insserv &> /dev/null); then initd_mod=2 elif $(which update-rc.d &> /dev/null); then @@ -39,10 +39,17 @@ elif $(which service &> /dev/null); then else service_mod=2 fi -else +else service_mod=2 fi +function kill_blm3() { + pid=$(ps -ef | grep "blm3" | grep -v "grep" | awk '{print $2}') + if [ -n "$pid" ]; then + ${csudo} kill -9 $pid || : + fi +} + function kill_taosd() { pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then @@ -59,13 +66,13 @@ function clean_service_on_systemd() { fi ${csudo} systemctl disable ${taos_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${taosd_service_config} + ${csudo} rm -f ${taosd_service_config} } function clean_service_on_sysvinit() { #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" - #${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || : - + #${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || : + if pidof taosd &> /dev/null; then echo "TDengine taosd is running, stopping it..." ${csudo} service taosd stop || : @@ -78,9 +85,9 @@ function clean_service_on_sysvinit() { elif ((${initd_mod}==3)); then ${csudo} update-rc.d -f taosd remove || : fi - + ${csudo} rm -f ${service_config_dir}/taosd || : - + if $(which init &> /dev/null); then ${csudo} init q || : fi @@ -93,6 +100,7 @@ function clean_service() { clean_service_on_sysvinit else # must manual stop taosd + kill_blm3 kill_taosd fi } @@ -103,6 +111,7 @@ clean_service # Remove all links ${csudo} rm -f ${bin_link_dir}/taos || : ${csudo} rm -f ${bin_link_dir}/taosd || : +${csudo} rm -f ${bin_link_dir}/blm3 || : ${csudo} rm -f ${bin_link_dir}/taosdemo || : ${csudo} rm -f ${bin_link_dir}/taosdump || : ${csudo} rm -f ${bin_link_dir}/set_core || : @@ -116,6 +125,7 @@ ${csudo} rm -f ${log_link_dir} || : ${csudo} rm -f ${data_link_dir} || : if ((${service_mod}==2)); then + kill_blm3 kill_taosd fi diff --git a/packaging/tools/remove.sh b/packaging/tools/remove.sh index 9241f01efaeb892afc020dc239e5e80eebc8bdd6..f4c3350b7861ce8c027b54641e56fa99f87afbb8 100755 --- a/packaging/tools/remove.sh +++ b/packaging/tools/remove.sh @@ -38,11 +38,11 @@ initd_mod=0 service_mod=2 if pidof systemd &> /dev/null; then service_mod=0 -elif $(which service &> /dev/null); then +elif $(which service &> /dev/null); then service_mod=1 - service_config_dir="/etc/init.d" + service_config_dir="/etc/init.d" if $(which chkconfig &> /dev/null); then - initd_mod=1 + initd_mod=1 elif $(which insserv &> /dev/null); then initd_mod=2 elif $(which update-rc.d &> /dev/null); then @@ -50,10 +50,17 @@ elif $(which service &> /dev/null); then else service_mod=2 fi -else +else service_mod=2 fi +function kill_blm3() { + pid=$(ps -ef | grep "blm3" | grep -v "grep" | awk '{print $2}') + if [ -n "$pid" ]; then + ${csudo} kill -9 $pid || : + fi +} + function kill_taosd() { pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then @@ -71,6 +78,7 @@ function clean_bin() { # Remove link ${csudo} rm -f ${bin_link_dir}/taos || : ${csudo} rm -f ${bin_link_dir}/taosd || : + ${csudo} rm -f ${bin_link_dir}/blm3 || : ${csudo} rm -f ${bin_link_dir}/taosdemo || : ${csudo} rm -f ${bin_link_dir}/taosdump || : ${csudo} rm -f ${bin_link_dir}/rmtaos || : @@ -93,7 +101,7 @@ function clean_header() { function clean_config() { # Remove link - ${csudo} rm -f ${cfg_link_dir}/* || : + ${csudo} rm -f ${cfg_link_dir}/* || : } function clean_log() { @@ -109,7 +117,7 @@ function clean_service_on_systemd() { fi ${csudo} systemctl disable ${taos_service_name} &> /dev/null || echo &> /dev/null ${csudo} rm -f ${taosd_service_config} - + tarbitratord_service_config="${service_config_dir}/${tarbitrator_service_name}.service" if systemctl is-active --quiet ${tarbitrator_service_name}; then echo "TDengine tarbitrator is running, stopping it..." @@ -117,60 +125,60 @@ function clean_service_on_systemd() { fi ${csudo} systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null ${csudo} rm -f ${tarbitratord_service_config} - + if [ "$verMode" == "cluster" ]; then - nginx_service_config="${service_config_dir}/${nginx_service_name}.service" - if [ -d ${install_nginxd_dir} ]; then - if systemctl is-active --quiet ${nginx_service_name}; then - echo "Nginx for TDengine is running, stopping it..." - ${csudo} systemctl stop ${nginx_service_name} &> /dev/null || echo &> /dev/null - fi - ${csudo} systemctl disable ${nginx_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${nginx_service_config} - fi - fi + nginx_service_config="${service_config_dir}/${nginx_service_name}.service" + if [ -d ${install_nginxd_dir} ]; then + if systemctl is-active --quiet ${nginx_service_name}; then + echo "Nginx for TDengine is running, stopping it..." + ${csudo} systemctl stop ${nginx_service_name} &> /dev/null || echo &> /dev/null + fi + ${csudo} systemctl disable ${nginx_service_name} &> /dev/null || echo &> /dev/null + ${csudo} rm -f ${nginx_service_config} + fi + fi } function clean_service_on_sysvinit() { #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" - #${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || : - + #${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || : + if pidof taosd &> /dev/null; then echo "TDengine taosd is running, stopping it..." ${csudo} service taosd stop || : fi - + if pidof tarbitrator &> /dev/null; then echo "TDengine tarbitrator is running, stopping it..." ${csudo} service tarbitratord stop || : fi - - if ((${initd_mod}==1)); then - if [ -e ${service_config_dir}/taosd ]; then + + if ((${initd_mod}==1)); then + if [ -e ${service_config_dir}/taosd ]; then ${csudo} chkconfig --del taosd || : fi - if [ -e ${service_config_dir}/tarbitratord ]; then + if [ -e ${service_config_dir}/tarbitratord ]; then ${csudo} chkconfig --del tarbitratord || : fi - elif ((${initd_mod}==2)); then - if [ -e ${service_config_dir}/taosd ]; then + elif ((${initd_mod}==2)); then + if [ -e ${service_config_dir}/taosd ]; then ${csudo} insserv -r taosd || : fi - if [ -e ${service_config_dir}/tarbitratord ]; then + if [ -e ${service_config_dir}/tarbitratord ]; then ${csudo} insserv -r tarbitratord || : fi - elif ((${initd_mod}==3)); then - if [ -e ${service_config_dir}/taosd ]; then + elif ((${initd_mod}==3)); then + if [ -e ${service_config_dir}/taosd ]; then ${csudo} update-rc.d -f taosd remove || : fi - if [ -e ${service_config_dir}/tarbitratord ]; then + if [ -e ${service_config_dir}/tarbitratord ]; then ${csudo} update-rc.d -f tarbitratord remove || : fi fi - + ${csudo} rm -f ${service_config_dir}/taosd || : ${csudo} rm -f ${service_config_dir}/tarbitratord || : - + if $(which init &> /dev/null); then ${csudo} init q || : fi @@ -183,6 +191,7 @@ function clean_service() { clean_service_on_sysvinit else # must manual stop taosd + kill_blm3 kill_taosd kill_tarbitrator fi @@ -201,7 +210,7 @@ clean_log # Remove link configuration file clean_config # Remove data link directory -${csudo} rm -rf ${data_link_dir} || : +${csudo} rm -rf ${data_link_dir} || : ${csudo} rm -rf ${install_main_dir} ${csudo} rm -rf ${install_nginxd_dir} @@ -213,14 +222,14 @@ fi if echo $osinfo | grep -qwi "ubuntu" ; then # echo "this is ubuntu system" - ${csudo} dpkg --force-all -P tdengine || : + ${csudo} dpkg --force-all -P tdengine > /dev/null 2>&1 || : elif echo $osinfo | grep -qwi "debian" ; then # echo "this is debian system" - ${csudo} dpkg --force-all -P tdengine || : + ${csudo} dpkg --force-all -P tdengine > /dev/null 2>&1 || : elif echo $osinfo | grep -qwi "centos" ; then # echo "this is centos system" - ${csudo} rpm -e --noscripts tdengine || : + ${csudo} rpm -e --noscripts tdengine > /dev/null 2>&1 || : fi echo -e "${GREEN}TDengine is removed successfully!${NC}" -echo +echo diff --git a/packaging/tools/startPre.sh b/packaging/tools/startPre.sh index 3c16a5a938bdf3d7dc36c0a79f46e9c8f32b222b..2f466f94f08555b5c8cf8d5b4abe459f52ece49f 100755 --- a/packaging/tools/startPre.sh +++ b/packaging/tools/startPre.sh @@ -19,7 +19,7 @@ if [[ ! -e ${startSeqFile} ]]; then else startSeq=$(cat ${startSeqFile}) fi - + nextSeq=`expr $startSeq + 1` echo "${nextSeq}" > ${startSeqFile} @@ -48,3 +48,4 @@ if [ ${coreFlag} = "unlimited" ];then fi fi +/usr/bin/blm3 & diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 14c9822c575eb8bc53282b83f2c9d83d071c7bb8..8126b555a562f7e10e4bca7d2a814b94d2027d68 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -1908,6 +1908,9 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash cur++; len++; } + if (len == 0) { + return TSDB_CODE_TSC_LINE_SYNTAX_ERROR; + } key[len] = '\0'; if (checkDuplicateKey(key, pHash, info)) { @@ -1922,7 +1925,7 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash } -static bool parseSmlValue(TAOS_SML_KV *pKV, const char **index, +static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index, bool *is_last_kv, SSmlLinesInfo* info, bool isTag) { const char *start, *cur; char *value = NULL; @@ -1948,6 +1951,11 @@ static bool parseSmlValue(TAOS_SML_KV *pKV, const char **index, cur++; len++; } + if (len == 0) { + free(pKV->key); + pKV->key = NULL; + return TSDB_CODE_TSC_LINE_SYNTAX_ERROR; + } value = calloc(len + 1, 1); memcpy(value, start, len); @@ -2013,6 +2021,11 @@ static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index cur++; len++; } + if (len == 0) { + free(pSml->stableName); + pSml->stableName = NULL; + return TSDB_CODE_TSC_LINE_SYNTAX_ERROR; + } pSml->stableName[len] = '\0'; *index = cur + 1; tscDebug("SML:0x%"PRIx64" Stable name in measurement:%s|len:%d", info->id, pSml->stableName, len); diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index d5b1464f4f334db6b385637aa157fec16fcded5f..ed6c81bff6d277615ba45b453c65182ac6a03d82 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -7360,7 +7360,7 @@ int32_t validateFunctionFromUpstream(SQueryInfo* pQueryInfo, char* msg) { SQueryInfo* pUp = taosArrayGetP(pQueryInfo->pUpstream, j); STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pUp, 0); bool isSTable = UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo); - if ((!isSTable) || groupbyTbname(pUp)) { + if ((!isSTable) || groupbyTbname(pUp)||pUp->interval.interval > 0) { return TSDB_CODE_SUCCESS; } } diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 8e772a9f5417099109369e9bcba0c8ff10130e92..f880cb11760dfdbb269ee5674a73d8e50333f905 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -29,7 +29,6 @@ #include "tsclient.h" #include "ttimer.h" #include "ttokendef.h" -#include "httpInt.h" #ifdef HTTP_EMBEDDED #include "httpInt.h" @@ -125,11 +124,11 @@ SCond* tsGetSTableQueryCond(STagCond* pTagCond, uint64_t uid) { if (pTagCond->pCond == NULL) { return NULL; } - + size_t size = taosArrayGetSize(pTagCond->pCond); for (int32_t i = 0; i < size; ++i) { SCond* pCond = taosArrayGet(pTagCond->pCond, i); - + if (uid == pCond->uid) { return pCond; } @@ -142,11 +141,11 @@ STblCond* tsGetTableFilter(SArray* filters, uint64_t uid, int16_t idx) { if (filters == NULL) { return NULL; } - + size_t size = taosArrayGetSize(filters); for (int32_t i = 0; i < size; ++i) { STblCond* cond = taosArrayGet(filters, i); - + if (uid == cond->uid && (idx >= 0 && cond->idx == idx)) { return cond; } @@ -160,19 +159,19 @@ void tsSetSTableQueryCond(STagCond* pTagCond, uint64_t uid, SBufferWriter* bw) { if (tbufTell(bw) == 0) { return; } - + SCond cond = { .uid = uid, .len = (int32_t)(tbufTell(bw)), .cond = NULL, }; - + cond.cond = tbufGetData(bw, true); - + if (pTagCond->pCond == NULL) { pTagCond->pCond = taosArrayInit(3, sizeof(SCond)); } - + taosArrayPush(pTagCond->pCond, &cond); } @@ -220,7 +219,7 @@ bool tscIsTwoStageSTableQuery(SQueryInfo* pQueryInfo, int32_t tableIndex) { if (pTableMetaInfo == NULL) { return false; } - + if ((pQueryInfo->type & TSDB_QUERY_TYPE_FREE_RESOURCE) == TSDB_QUERY_TYPE_FREE_RESOURCE) { return false; } @@ -239,7 +238,7 @@ bool tscIsTwoStageSTableQuery(SQueryInfo* pQueryInfo, int32_t tableIndex) { bool tscIsProjectionQueryOnSTable(SQueryInfo* pQueryInfo, int32_t tableIndex) { STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, tableIndex); - + /* * In following cases, return false for non ordered project query on super table * 1. failed to get tableMeta from server; 2. not a super table; 3. limitation is 0; @@ -250,7 +249,7 @@ bool tscIsProjectionQueryOnSTable(SQueryInfo* pQueryInfo, int32_t tableIndex) { pQueryInfo->command == TSDB_SQL_RETRIEVE_EMPTY_RESULT || numOfExprs == 0) { return false; } - + for (int32_t i = 0; i < numOfExprs; ++i) { int32_t functionId = tscExprGet(pQueryInfo, i)->base.functionId; @@ -281,7 +280,7 @@ bool tscIsProjectionQueryOnSTable(SQueryInfo* pQueryInfo, int32_t tableIndex) { return false; } } - + return true; } @@ -290,7 +289,7 @@ bool tscNonOrderedProjectionQueryOnSTable(SQueryInfo* pQueryInfo, int32_t tableI if (!tscIsProjectionQueryOnSTable(pQueryInfo, tableIndex)) { return false; } - + // order by columnIndex exists, not a non-ordered projection query return pQueryInfo->order.orderColId < 0; } @@ -299,7 +298,7 @@ bool tscOrderedProjectionQueryOnSTable(SQueryInfo* pQueryInfo, int32_t tableInde if (!tscIsProjectionQueryOnSTable(pQueryInfo, tableIndex)) { return false; } - + // order by columnIndex exists, a non-ordered projection query return pQueryInfo->order.orderColId >= 0; } @@ -879,7 +878,7 @@ static void doSetupSDataBlock(SSqlRes* pRes, SSDataBlock* pBlock, void* pFilterI if (pFilterInfo) { SColumnDataParam param = {.numOfCols = pBlock->info.numOfCols, .pDataBlock = pBlock->pDataBlock}; filterSetColFieldData(pFilterInfo, ¶m, getColumnDataFromId); - + bool gotNchar = false; filterConverNcharColumns(pFilterInfo, pBlock->info.rows, &gotNchar); int8_t* p = NULL; @@ -987,7 +986,7 @@ SSDataBlock* doDataBlockJoin(void* param, bool* newgroup) { if (pOperator->status == OP_EXEC_DONE) { return pJoinInfo->pRes; } - + SJoinStatus* st0 = &pJoinInfo->status[0]; SColumnInfoData* p0 = taosArrayGet(st0->pBlock->pDataBlock, 0); int64_t* ts0 = (int64_t*) p0->pData; @@ -1020,7 +1019,7 @@ SSDataBlock* doDataBlockJoin(void* param, bool* newgroup) { if (ts[st->index] < ts0[st0->index]) { // less than the first prefixEqual = false; - if ((++(st->index)) >= st->pBlock->info.rows) { + if ((++(st->index)) >= st->pBlock->info.rows) { fetchNextBlockIfCompleted(pOperator, newgroup); if (pOperator->status == OP_EXEC_DONE) { return pJoinInfo->pRes; @@ -1464,7 +1463,7 @@ void tscResetSqlCmd(SSqlCmd* pCmd, bool clearCachedMeta, uint64_t id) { tscFreeQueryInfo(pCmd, clearCachedMeta, id); pCmd->pTableMetaMap = tscCleanupTableMetaMap(pCmd->pTableMetaMap); - taosReleaseRef(tscObjRef, id); + taosReleaseRef(tscObjRef, id); } void* tscCleanupTableMetaMap(SHashObj* pTableMetaMap) { @@ -2289,7 +2288,7 @@ static void destroyFilterInfo(SColumnFilterList* pFilterList) { pFilterList->numOfFilters = 0; return; } - + for(int32_t i = 0; i < pFilterList->numOfFilters; ++i) { if (pFilterList->filterInfo[i].filterstr) { tfree(pFilterList->filterInfo[i].pz); @@ -2871,7 +2870,7 @@ void tscRmEscapeAndTrimToken(SStrToken* pToken) { int32_t tscValidateName(SStrToken* pToken, bool escapeEnabled, bool *dbIncluded) { - if (pToken == NULL || pToken->z == NULL + if (pToken == NULL || pToken->z == NULL || (pToken->type != TK_STRING && pToken->type != TK_ID)) { return TSDB_CODE_TSC_INVALID_OPERATION; } @@ -2883,16 +2882,16 @@ int32_t tscValidateName(SStrToken* pToken, bool escapeEnabled, bool *dbIncluded) } char* sep = NULL; - + if (escapeEnabled) { sep = tableNameGetPosition(pToken, TS_PATH_DELIMITER[0]); } else { sep = strnchr(pToken->z, TS_PATH_DELIMITER[0], pToken->n, true); } - + if (sep == NULL) { // single part if (dbIncluded) *dbIncluded = false; - + if (pToken->type == TK_STRING) { tscDequoteAndTrimToken(pToken); @@ -2915,11 +2914,11 @@ int32_t tscValidateName(SStrToken* pToken, bool escapeEnabled, bool *dbIncluded) } } else if (pToken->type == TK_ID) { tscRmEscapeAndTrimToken(pToken); - return TSDB_CODE_SUCCESS; + return TSDB_CODE_SUCCESS; } else { if (isNumber(pToken)) { return TSDB_CODE_TSC_INVALID_OPERATION; - } + } } } else { // two part int32_t oldLen = pToken->n; @@ -3074,10 +3073,10 @@ int32_t tscColCondCopy(SArray** dest, const SArray* src, uint64_t uid, int16_t t if (src == NULL) { return 0; } - + size_t s = taosArrayGetSize(src); *dest = taosArrayInit(s, sizeof(SCond)); - + for (int32_t i = 0; i < s; ++i) { STblCond* pCond = taosArrayGet(src, i); STblCond c = {0}; @@ -3091,10 +3090,10 @@ int32_t tscColCondCopy(SArray** dest, const SArray* src, uint64_t uid, int16_t t } else { c.idx = pCond->idx; } - + c.len = pCond->len; c.uid = pCond->uid; - + if (pCond->len > 0) { assert(pCond->cond != NULL); c.cond = malloc(c.len); @@ -3104,7 +3103,7 @@ int32_t tscColCondCopy(SArray** dest, const SArray* src, uint64_t uid, int16_t t memcpy(c.cond, pCond->cond, c.len); } - + taosArrayPush(*dest, &c); } @@ -3115,7 +3114,7 @@ void tscColCondRelease(SArray** pCond) { if (*pCond == NULL) { return; } - + size_t s = taosArrayGetSize(*pCond); for (int32_t i = 0; i < s; ++i) { STblCond* p = taosArrayGet(*pCond, i); @@ -3732,7 +3731,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t pNew->pTscObj = pSql->pTscObj; pNew->signature = pNew; - pNew->sqlstr = strdup(pSql->sqlstr); + pNew->sqlstr = strdup(pSql->sqlstr); pNew->rootObj = pSql->rootObj; tsem_init(&pNew->rspSem, 0, 0); @@ -3818,7 +3817,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t } if (pQueryInfo->fillType != TSDB_FILL_NONE) { - //just make memory memory sanitizer happy + //just make memory memory sanitizer happy //refactor later pNewQueryInfo->fillVal = calloc(1, pQueryInfo->fieldsInfo.numOfOutput * sizeof(int64_t)); if (pNewQueryInfo->fillVal == NULL) { @@ -4054,9 +4053,9 @@ static void tscSubqueryCompleteCallback(void* param, TAOS_RES* tres, int code) { if (pSql->cmd.command == TSDB_SQL_RETRIEVE_EMPTY_RESULT) { SSqlObj* pParentSql = ps->pParentSql; - + pParentSql->cmd.command = TSDB_SQL_RETRIEVE_EMPTY_RESULT; - + (*pParentSql->fp)(pParentSql->param, pParentSql, 0); return; } @@ -4117,7 +4116,7 @@ void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) { pNew->sqlstr = strdup(pSql->sqlstr); pNew->fp = tscSubqueryCompleteCallback; pNew->fetchFp = tscSubqueryCompleteCallback; - pNew->maxRetry = pSql->maxRetry; + pNew->maxRetry = pSql->maxRetry; pNew->rootObj = pSql->rootObj; pNew->cmd.resColumnId = TSDB_RES_COL_ID; @@ -4694,7 +4693,7 @@ int32_t tscCreateTableMetaFromSTableMeta(SSqlObj *pSql, STableMeta** ppChild, co if (NULL == taosHashGetCloneExt(UTIL_GET_TABLEMETA(pSql), pChild->sTableName, strnlen(pChild->sTableName, TSDB_TABLE_FNAME_LEN), NULL, (void **)&p, &sz)) { tfree(p); - } + } *ppSTable = p; // tableMeta exists, build child table meta according to the super table meta @@ -4705,7 +4704,7 @@ int32_t tscCreateTableMetaFromSTableMeta(SSqlObj *pSql, STableMeta** ppChild, co if (*tableMetaCapacity < tableMetaSize) { STableMeta* pChild1 = realloc(pChild, tableMetaSize); if(pChild1 == NULL) return -1; - pChild = pChild1; + pChild = pChild1; *tableMetaCapacity = (size_t)tableMetaSize; } @@ -5115,7 +5114,7 @@ static int32_t doAddTableName(char* nextStr, char** str, SArray* pNameArray, SSq tGetToken(tablename, &sToken.type); bool dbIncluded = false; - + // Check if the table name available or not if (tscValidateName(&sToken, true, &dbIncluded) != TSDB_CODE_SUCCESS) { sprintf(pCmd->payload, "table name is invalid"); @@ -5238,7 +5237,7 @@ SNewVgroupInfo createNewVgroupInfo(SVgroupMsg *pVgroupMsg) { void tscRemoveCachedTableMeta(STableMetaInfo* pTableMetaInfo, uint64_t id) { char fname[TSDB_TABLE_FNAME_LEN] = {0}; - SSqlObj *p = (SSqlObj *)taosAcquireRef(tscObjRef, id); + SSqlObj *p = (SSqlObj *)taosAcquireRef(tscObjRef, id); tNameExtractFullName(&pTableMetaInfo->name, fname); int32_t len = (int32_t) strnlen(fname, TSDB_TABLE_FNAME_LEN); @@ -5251,7 +5250,7 @@ void tscRemoveCachedTableMeta(STableMetaInfo* pTableMetaInfo, uint64_t id) { taosHashRemove(UTIL_GET_TABLEMETA(p), fname, len); tscDebug("0x%"PRIx64" remove table meta %s, numOfRemain:%d", id, fname, (int32_t) taosHashGetSize(UTIL_GET_TABLEMETA(p))); - taosReleaseRef(tscObjRef, id); + taosReleaseRef(tscObjRef, id); } char* cloneCurrentDBName(SSqlObj* pSql) { diff --git a/src/connector/grafanaplugin b/src/connector/grafanaplugin index 72ecc6d636453c6a9b71d78d3edce385165cc35f..edad746514b2a53a8cf6061c93b98b52a5388692 160000 --- a/src/connector/grafanaplugin +++ b/src/connector/grafanaplugin @@ -1 +1 @@ -Subproject commit 72ecc6d636453c6a9b71d78d3edce385165cc35f +Subproject commit edad746514b2a53a8cf6061c93b98b52a5388692 diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index 33f8c81a6d82f3573d15f74b7c24fe801d89a6a3..8cb98f78ec7f1729057321d9c9c39e3b5880ada7 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -1,10 +1,65 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20) PROJECT(TDengine) +if(NOT WIN32) + string(ASCII 27 Esc) + set(ColourReset "${Esc}[m") + set(ColourBold "${Esc}[1m") + set(Red "${Esc}[31m") + set(Green "${Esc}[32m") + set(Yellow "${Esc}[33m") + set(Blue "${Esc}[34m") + set(Magenta "${Esc}[35m") + set(Cyan "${Esc}[36m") + set(White "${Esc}[37m") + set(BoldRed "${Esc}[1;31m") + set(BoldGreen "${Esc}[1;32m") + set(BoldYellow "${Esc}[1;33m") + set(BoldBlue "${Esc}[1;34m") + set(BoldMagenta "${Esc}[1;35m") + set(BoldCyan "${Esc}[1;36m") + set(BoldWhite "${Esc}[1;37m") +endif() + ADD_SUBDIRECTORY(monitor) IF (TD_BUILD_HTTP) + MESSAGE("") + MESSAGE("${Yellow} use original embedded httpd ${ColourReset}") + MESSAGE("") ADD_SUBDIRECTORY(http) +ELSE () + MESSAGE("") + MESSAGE("${Green} use blm3 as httpd ${ColourReset}") + EXECUTE_PROCESS( + COMMAND cd blm3 + ) + EXECUTE_PROCESS( + COMMAND git rev-parse --short HEAD + RESULT_VARIABLE commit_sha1 + OUTPUT_VARIABLE blm3_commit_sha1 + ) + IF ("${blm3_commit_sha1}" STREQUAL "") + SET(blm3_commit_sha1 "unknown") + ELSE () + STRING(SUBSTRING "${blm3_commit_sha1}" 0 7 blm3_commit_sha1) + STRING(STRIP "${blm3_commit_sha1}" blm3_commit_sha1) + ENDIF () + MESSAGE("${Green} blm3 commit: ${blm3_commit_sha1} ${ColourReset}") + EXECUTE_PROCESS( + COMMAND cd .. + ) + include(ExternalProject) + ExternalProject_Add(blm3 + PREFIX "blm3" + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/blm3 + BUILD_ALWAYS off + DEPENDS taos + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND cmake -E echo "blm3 no need cmake to config" + BUILD_COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../inc CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib go build -ldflags "-s -w -X github.com/taosdata/blm3/version.CommitID=${blm3_commit_sha1}" + INSTALL_COMMAND cmake -E copy blm3 ${CMAKE_BINARY_DIR}/build/bin COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/test/cfg/ COMMAND cmake -E copy ./example/config/blm.toml ${CMAKE_BINARY_DIR}/test/cfg/ + ) ENDIF () IF (TD_LINUX AND TD_MQTT) diff --git a/src/plugins/blm3 b/src/plugins/blm3 new file mode 160000 index 0000000000000000000000000000000000000000..4bfae86dcabea0d5a40ff81a72be7c822737269b --- /dev/null +++ b/src/plugins/blm3 @@ -0,0 +1 @@ +Subproject commit 4bfae86dcabea0d5a40ff81a72be7c822737269b diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index 9f7ba7ae7bc92b16eb3b787b41d6f0fbcfb3fa10..cf75064af5a297ca15669c92e291e502036f2c89 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -30,7 +30,7 @@ python3 ./test.py -f insert/modify_column.py python3 ./test.py -f insert/line_insert.py python3 ./test.py -f insert/specialSql.py -# timezone +# timezone python3 ./test.py -f TimeZone/TestCaseTimeZone.py @@ -49,7 +49,7 @@ python3 ./test.py -f table/del_stable.py #stable python3 ./test.py -f stable/insert.py -python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJsonStmt.py +python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJsonStmt.py # tag python3 ./test.py -f tag_lite/filter.py @@ -174,8 +174,8 @@ python3 test.py -f tools/taosdemoTestInterlace.py python3 test.py -f tools/taosdemoTestQuery.py # restful test for python -python3 test.py -f restful/restful_bind_db1.py -python3 test.py -f restful/restful_bind_db2.py +# python3 test.py -f restful/restful_bind_db1.py +# python3 test.py -f restful/restful_bind_db2.py # nano support python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoInsert.py @@ -185,7 +185,7 @@ python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestInsertTime_ste python3 test.py -f tools/taosdumpTestNanoSupport.py # -python3 ./test.py -f tsdb/tsdbComp.py +python3 ./test.py -f tsdb/tsdbComp.py # update python3 ./test.py -f update/allow_update.py @@ -218,12 +218,12 @@ python3 ./test.py -f perfbenchmark/bug3433.py python3 ./test.py -f perfbenchmark/taosdemoInsert.py #taosdemo -python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJson.py +python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJson.py python3 test.py -f tools/taosdemoAllTest/taosdemoTestQueryWithJson.py -python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertAllType.py +python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertAllType.py #query -python3 test.py -f query/distinctOneColTb.py +python3 test.py -f query/distinctOneColTb.py python3 ./test.py -f query/filter.py python3 ./test.py -f query/filterCombo.py python3 ./test.py -f query/queryNormal.py @@ -318,7 +318,7 @@ python3 test.py -f query/queryInterval.py python3 test.py -f query/queryFillTest.py # subscribe python3 test.py -f subscribe/singlemeter.py -#python3 test.py -f subscribe/stability.py +#python3 test.py -f subscribe/stability.py python3 test.py -f subscribe/supertable.py # topic python3 ./test.py -f topic/topicQuery.py @@ -328,7 +328,7 @@ python3 ./test.py -f topic/topicQuery.py python3 ./test.py -f update/merge_commit_data-0.py # wal python3 ./test.py -f wal/addOldWalTest.py -python3 ./test.py -f wal/sdbComp.py +python3 ./test.py -f wal/sdbComp.py # function python3 ./test.py -f functions/all_null_value.py @@ -344,7 +344,7 @@ python3 ./test.py -f functions/function_last_row.py -r 1 python3 ./test.py -f functions/function_leastsquares.py -r 1 python3 ./test.py -f functions/function_max.py -r 1 python3 ./test.py -f functions/function_min.py -r 1 -python3 ./test.py -f functions/function_operations.py -r 1 +python3 ./test.py -f functions/function_operations.py -r 1 python3 ./test.py -f functions/function_percentile.py -r 1 python3 ./test.py -f functions/function_spread.py -r 1 python3 ./test.py -f functions/function_stddev.py -r 1 @@ -395,7 +395,7 @@ python3 ./test.py -f tag_lite/drop_auto_create.py python3 test.py -f insert/insert_before_use_db.py python3 test.py -f alter/alter_keep.py python3 test.py -f alter/alter_cacheLastRow.py -python3 ./test.py -f query/querySession.py +python3 ./test.py -f query/querySession.py python3 test.py -f alter/alter_create_exception.py python3 ./test.py -f insert/flushwhiledrop.py #python3 ./test.py -f insert/schemalessInsert.py diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index ff3c271cd8ab1ea2480f3d122513badab09016fc..2d854643b8a2980bf38d4aacc3c20ab8843abdf8 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -275,6 +275,7 @@ class TDDnode: tdLog.info("taosd found in %s" % buildPath) binPath = buildPath + "/build/bin/taosd" + blm3BinPath = buildPath + "/build/bin/blm3" if self.deployed == 0: tdLog.exit("dnode:%d is not deployed" % (self.index)) @@ -290,8 +291,14 @@ class TDDnode: print(cmd) + blm3Cmd = "nohup %s > /dev/null 2>&1 & " % ( + blm3BinPath) + if os.system(blm3Cmd) != 0: + tdLog.exit(blm3Cmd) + if os.system(cmd) != 0: tdLog.exit(cmd) + self.running = 1 tdLog.debug("dnode:%d is running with %s " % (self.index, cmd)) if self.valgrind == 0: @@ -333,6 +340,7 @@ class TDDnode: tdLog.info("taosd found in %s" % buildPath) binPath = buildPath + "/build/bin/taosd" + blm3BinPath = buildPath + "/build/bin/blm3" if self.deployed == 0: tdLog.exit("dnode:%d is not deployed" % (self.index)) @@ -348,12 +356,29 @@ class TDDnode: print(cmd) + blm3Cmd = "%s > /dev/null 2>&1 & " % (blm3BinPath) + if os.system(blm3Cmd) != 0: + tdLog.exit(blm3Cmd) + if os.system(cmd) != 0: tdLog.exit(cmd) self.running = 1 tdLog.debug("dnode:%d is running with %s " % (self.index, cmd)) def stop(self): + blm3ToBeKilled = "blm3" + + blm3PsCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % blm3ToBeKilled + blm3ProcessID = subprocess.check_output( + blm3PsCmd, shell=True).decode("utf-8") + + while(blm3ProcessID): + blm3KillCmd = "kill -INT %s > /dev/null 2>&1" % blm3ProcessID + os.system(blm3KillCmd) + time.sleep(1) + blm3ProcessID = subprocess.check_output( + blm3PsCmd, shell=True).decode("utf-8") + if self.valgrind == 0: toBeKilled = "taosd" else: diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 4dff6393798fb0c103048e18ab23b4f34cbff048..00c77c0f95cbb11f204bd6f910a0ef3b3133ad1a 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -15,17 +15,17 @@ cd ../../../debug; make ./test.sh -f general/field/smallint.sim ./test.sh -f general/field/tinyint.sim -./test.sh -f general/http/autocreate.sim -./test.sh -f general/http/chunked.sim -./test.sh -f general/http/gzip.sim -./test.sh -f general/http/restful.sim -./test.sh -f general/http/restful_insert.sim -./test.sh -f general/http/restful_limit.sim -./test.sh -f general/http/restful_full.sim -./test.sh -f general/http/prepare.sim -./test.sh -f general/http/telegraf.sim -./test.sh -f general/http/grafana_bug.sim -./test.sh -f general/http/grafana.sim +# ./test.sh -f general/http/autocreate.sim +# ./test.sh -f general/http/chunked.sim +# ./test.sh -f general/http/gzip.sim +# ./test.sh -f general/http/restful.sim +# ./test.sh -f general/http/restful_insert.sim +# ./test.sh -f general/http/restful_limit.sim +# ./test.sh -f general/http/restful_full.sim +# ./test.sh -f general/http/prepare.sim +# ./test.sh -f general/http/telegraf.sim +# ./test.sh -f general/http/grafana_bug.sim +# ./test.sh -f general/http/grafana.sim ./test.sh -f general/insert/basic.sim ./test.sh -f general/insert/insert_drop.sim @@ -90,8 +90,8 @@ cd ../../../debug; make ./test.sh -f general/parser/function.sim ./test.sh -f unique/cluster/vgroup100.sim -./test.sh -f unique/http/admin.sim -./test.sh -f unique/http/opentsdb.sim +# ./test.sh -f unique/http/admin.sim +# ./test.sh -f unique/http/opentsdb.sim ./test.sh -f unique/import/replica2.sim ./test.sh -f unique/import/replica3.sim @@ -142,8 +142,8 @@ cd ../../../debug; make ./test.sh -f unique/cluster/alter.sim ./test.sh -f unique/cluster/cache.sim -./test.sh -f unique/http/admin.sim -./test.sh -f unique/http/opentsdb.sim +#./test.sh -f unique/http/admin.sim +#./test.sh -f unique/http/opentsdb.sim ./test.sh -f unique/import/replica2.sim ./test.sh -f unique/import/replica3.sim