yum install -y gcc gcc-c++ make autoconf wget ncurses-devel libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel openldap-devel libtool-ltdl-devel libevent-devel gd-devel bzip2-devel pcre-devel bison libaio-devel cmake readline-devel libtirpc-devel sqlite-devel oniguruma automake libtool libzip libzip-devel unzip
1、查看是否安装
java -version
2、卸载
查看系统是否自带 jdk
rpm -qa |grep java
rpm -qa |grep jdk
rpm -qa |grep gcj
如果有输出信息,批量卸载系统自带
rpm -qa | grep java | xargs rpm -e --nodeps
如果使用 yum 安装的 jdk,请使用下面命令卸载
yum -y remove java-1.8.0-openjdk-headless.x86_64
3、安装
3.1 检查 yum 中有没有 java1.8 包
yum list java-1.8*
3.2 开始安装
yum install java-1.8.0-openjdk* -y
https://github.com/taosdata/TDengine/archive/refs/tags/ver-2.4.0.5.tar.gz
4、
tar zxvf TDengine-ver-2.4.0.5.tar.gz
cd TDengine-ver-2.4.0.5
安装
在代码目录下新建build目录,并在代码根目录下编译;
命令如下:
cmake .
cmake --build .
make install
To configure TDengine : edit /etc/taos/taos.cfg
To start TDengine : sudo systemctl start taosd
To access TDengine : use taos in shell
/etc/taos
/var/lib/taos
/var/log/taos
/usr/bin/taos
/usr/local/taos
/usr/local/taos/bin/taos
/usr/local/taos/connector/python/taos
nano /etc/taos/taos.cfg
logDir /myweb/TDengine/log
dataDir /myweb/TDengine/data
tempDir /myweb/temp/
启动 taosd &
firewall-cmd --zone=public --permanent --add-port=6030/tcp
firewall-cmd --zone=public --permanent --add-port=6035/tcp
firewall-cmd --zone=public --permanent --add-port=6030-6042/tcp
firewall-cmd --zone=public --permanent --add-port=6030-6042/udp
firewall-cmd --zone=public --add-port=6041/tcp --permanent
firewall-cmd --reload
systemctl start taosd 启动服务
taosd & 单独启动服务
systemctl enable taosd 设置自启动状态
systemctl status taosd 查看状态
systemctl list-unit-files 查看情况
taos 连接服务器,默认root用户,密码taosdata
taos -h 192.168.1.16 -u root -p 密码
create database k3mdm;
use k3mdm;
create table apipushlog(fdatetime timestamp,times int);
insert into apipushlog (fdatetime,times) values(‘2021-07-01 00:20:21’,1);
create table msg(fdatetime timestamp,msg nchar(200));
insert into apipushlog (fdatetime,msg) values(‘2021-07-01 00:20:21’,‘1’);
insert into k3mdm.msg(fdatetime,msg) values(Now,‘safasf’)
alter table msg add column temp double;
alter table lz_status modify column temp double;
alter table lz_status add column voltage double;
Now ,Now -1m ,h Now
http://192.168.1.16:6041/rest/sql
在请求头header上增加一个信息:
Authorization: Basic TOKEN
Authorization: Basic cm9vdDp0YW9zZGF0YQ==
TOKEN为{username}:{password}经过base64编码之后的字符串,例如root:taosdata编码后为cm9vdDp0YW9zZGF0YQ==
然后在body中,将请求的sql填入,如:
select * from k3mdm.apipushlog
即可获取实际的数据。
第二种:curl_setopt($ch, CURLOPT_USERPWD,root:taosdata);
第三种:$encodedAuth = base64_encode(root:taodata);
curl_setopt( c h , C U R L O P T H T T P H E A D E R , a r r a y ( ′ A u t h o r i z a t i o n : B a s i c ′ . ch, CURLOPT_HTTPHEADER, array('Authorization : Basic '. ch,CURLOPTHTTPHEADER,array(′Authorization:Basic′.encodedAuth));
http://192.168.1.16:6041/rest/login/root/taosdata 获取授权码
结果集采用Unix时间戳
http://192.168.1.16:6041/rest/sqlt
结果集采用UTC时间字符串
http://192.168.1.16:6041/rest/sqlutc
连铸数据入库:
涛思数据创建表 create table lz_sensor(fdatetime timestamp,ctrlName nchar(50),name nchar(50),health int,value double);
规则引擎:
FOREACH
payload.measures
DO
clientid,item.ctrlName as ctrlName,item.name as name,item.health as health,item.timestamp as fdatetime,item.value as value
INCASE
item.value >= 0
FROM ‘LZ_status/temp’
webserver插入数据:
insert into k3mdm.lz_sensor(fdatetime,ctrlName,name,health,value) values(Now,’ c t r l N a m e ′ , ′ {ctrlName}',' ctrlName′,′{name}’,’ h e a l t h ′ , ′ {health}',' health′,′{value}’)