记录一下使用Ubuntu系统的安装TDengine Database管理软件工具
先查看一下系统的版本,可以看到这里使用的是Ubuntu20.04版本,版本代号focal
myw@myw-S451LN:~$ uname -a
Linux myw-S451LN 6.2.0-39-generic #40~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 16 10:53:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
myw@myw-S451LN:~$ uname -r
6.2.0-39-generic
myw@myw-S451LN:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy
myw@myw-S451LN:~$
官网介绍:TDengine 是一款专为物联网、工业互联网等场景设计并优化的大数据平台,它能安全高效地将大量设备、数据采集器每天产生的高达 TB 甚至 PB 级的数据进行汇聚、存储、分析和分发,对业务运行状态进行实时监测、预警,提供实时的商业洞察。其核心模块是高性能、集群开源、云原生、极简的时序数据库 TDengine OSS
官网
https://docs.taosdata.com
官网安装教程
https://docs.taosdata.com/get-started/package/
linux环境
使用deb安装
首先去下载deb安装包 有2个(其中taosTools是工具,TDengine-server是时序数据库),下载需要输入邮箱 ,然后从邮箱获取下载链接,记录一下我安装的版本和工具版本
https://www.taosdata.com/assets-download/3.0/TDengine-server-3.2.2.0-Linux-x64.deb
https://www.taosdata.com/assets-download/3.0/taosTools-2.5.2-Linux-x64-comp3.deb
win系统客户端
https://www.taosdata.com/assets-download/3.0/TDengine-client-3.2.2.0-Windows-x64.exe
将下载的安装包放置在ubuntu的home指定的用户下面(安装需要进入deb包的目录) 我这里是/home/myw
/home/myw
安装指令(在deb文件包的目录下面)
sudo dpkg -i TDengine-server-3.2.2.0-Linux-x64.deb
myw@myw-S451LN:~$ sudo dpkg -i TDengine-server-3.2.2.0-Linux-x64.deb
[sudo] myw 的密码:
正在选中未选择的软件包 tdengine。
(正在读取数据库 ... 系统当前共安装有 207485 个文件和目录。)
准备解压 TDengine-server-3.2.2.0-Linux-x64.deb ...
正在解压 tdengine (3.2.2.0) ...
正在设置 tdengine (3.2.2.0) ...
./post.sh: 行 107: /var/log/taos/tdengine_install.log: 没有那个文件或目录
Start to install TDengine...
./post.sh: 行 107: /var/log/taos/tdengine_install.log: 没有那个文件或目录
System hostname is: myw-S451LN
Enter FQDN:port (like h1.taosdata.com:6030) of an existing TDengine cluster node to join
OR leave it blank to build one:
Enter your email address for priority support or enter empty to skip:
Created symlink /etc/systemd/system/multi-user.target.wants/taosd.service → /etc/systemd/system/taosd.service.
To configure TDengine : edit /etc/taos/taos.cfg
To start TDengine : sudo systemctl start taosd
To access TDengine : taos -h myw-S451LN to login into TDengine server
TDengine is installed successfully!
myw@myw-S451LN:~$
安装过程中有2个停顿 直接enter
启动停止重启,查看是否启动成功 默认端口是6030
systemctl start taosd
systemctl status taosd
systemctl stop taosd
systemctl restart taosd
myw@myw-S451LN:~$ sudo netstat -lnp|grep taos
tcp 0 0 0.0.0.0:6030 0.0.0.0:* LISTEN 1019/taosd
unix 2 [ ACC ] 流 LISTENING 27052 1100/udfd /var/lib/taos//.udfd.sock.1
myw@myw-S451LN:~$ sudo systemctl stop taosd
myw@myw-S451LN:~$ sudo netstat -lnp|grep taos
myw@myw-S451LN:~$ sudo systemctl start taosd
myw@myw-S451LN:~$ sudo netstat -lnp|grep taos
tcp 0 0 0.0.0.0:6030 0.0.0.0:* LISTEN 5885/taosd
unix 2 [ ACC ] 流 LISTENING 46956 5899/udfd /var/lib/taos//.udfd.sock.1
myw@myw-S451LN:~$ sudo systemctl restart taosd
myw@myw-S451LN:~$ sudo netstat -lnp|grep taos
tcp 0 0 0.0.0.0:6030 0.0.0.0:* LISTEN 6065/taosd
unix 2 [ ACC ] 流 LISTENING 47581 6076/udfd /var/lib/taos//.udfd.sock.1
myw@myw-S451LN:~$ sudo systemctl status taosd
● taosd.service - TDengine server service
Loaded: loaded (/etc/systemd/system/taosd.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2024-01-07 12:04:24 CST; 13s ago
Process: 6059 ExecStartPre=/usr/local/taos/bin/startPre.sh (code=exited, status=0/SUCCESS)
Main PID: 6065 (taosd)
Tasks: 33 (limit: 9286)
Memory: 9.9M
CPU: 218ms
CGroup: /system.slice/taosd.service
├─6065 /usr/bin/taosd
└─6076 /usr/bin/udfd -c /etc/taos/
1月 07 12:04:24 myw-S451LN systemd[1]: Starting TDengine server service...
1月 07 12:04:24 myw-S451LN systemd[1]: Started TDengine server service.
myw@myw-S451LN:~$
启动之后进入tdengine数据库
taos
myw@myw-S451LN:~$ taos
Welcome to the TDengine Command Line Interface, Client Version:3.2.2.0
Copyright (c) 2023 by TDengine, all rights reserved.
******************************** Tab Completion ************************************
* The TDengine CLI supports tab completion for a variety of items, *
* including database names, table names, function names and keywords. *
* The full list of shortcut keys is as follows: *
* [ TAB ] ...... complete the current word *
* ...... if used on a blank line, display all supported commands *
* [ Ctrl + A ] ...... move cursor to the st[A]rt of the line *
* [ Ctrl + E ] ...... move cursor to the [E]nd of the line *
* [ Ctrl + W ] ...... move cursor to the middle of the line *
* [ Ctrl + L ] ...... clear the entire screen *
* [ Ctrl + K ] ...... clear the screen after the cursor *
* [ Ctrl + U ] ...... clear the screen before the cursor *
**************************************************************************************
Server is Community Edition.
taos> show databases;
name |
=================================
information_schema |
performance_schema |
Query OK, 2 row(s) in set (0.001619s)
taos> exit;
myw@myw-S451LN:~$
根据官方的教程体验一下命令行创建数据库和表
taos> CREATE DATABASE demo;
Create OK, 0 row(s) affected (5.116540s)
taos> USE demo;
Database changed.
taos> CREATE TABLE t (ts TIMESTAMP, speed INT);
Create OK, 0 row(s) affected (0.001511s)
taos> INSERT INTO t VALUES ('2019-07-15 00:00:00', 10);
Insert OK, 1 row(s) affected (0.001685s)
taos> INSERT INTO t VALUES ('2019-07-15 01:00:00', 20);
Insert OK, 1 row(s) affected (0.001532s)
taos> SELECT * FROM t;
ts | speed |
========================================
2019-07-15 00:00:00.000 | 10 |
2019-07-15 01:00:00.000 | 20 |
Query OK, 2 row(s) in set (0.001555s)
taos>
根据官方的体验一下写入速度和查询
taosBenchmark
myw@myw-S451LN:~$ sudo taosBenchmark
[sudo] myw 的密码:
[01/07 12:12:02.674949] INFO: client version: 3.2.2.0
Press enter key to continue or Ctrl-C to stop
[01/07 12:12:19.064618] INFO: command to create database: <CREATE DATABASE IF NOT EXISTS test VGROUPS 4 PRECISION 'ms';>
[01/07 12:12:19.069152] SUCC: created database (test)
[01/07 12:12:19.071316] WARN: failed to run command DESCRIBE `test`.`meters`, code: 0x80002603, reason: Table does not exist
[01/07 12:12:19.071360] INFO: stable meters does not exist, will create one
[01/07 12:12:19.072193] INFO: create stable: <CREATE TABLE test.meters (ts TIMESTAMP,current float,voltage int,phase float) TAGS (groupid int,location binary(24))>
[01/07 12:12:19.155807] INFO: generate stable<meters> columns data with lenOfCols<80> * prepared_rand<360>
[01/07 12:12:22.662169] INFO: generate stable<meters> tags data with lenOfTags<62> * childTblCount<10000>
[01/07 12:12:22.666451] INFO: start creating 10000 table(s) with 8 thread(s)
[01/07 12:12:22.667534] INFO: thread[0] start creating table from 0 to 1249
[01/07 12:12:22.668186] INFO: thread[1] start creating table from 1250 to 2499
[01/07 12:12:22.668906] INFO: thread[2] start creating table from 2500 to 3749
[01/07 12:12:22.670124] INFO: thread[3] start creating table from 3750 to 4999
[01/07 12:12:22.671742] INFO: thread[4] start creating table from 5000 to 6249
[01/07 12:12:22.673665] INFO: thread[5] start creating table from 6250 to 7499
[01/07 12:12:22.674909] INFO: thread[6] start creating table from 7500 to 8749
[01/07 12:12:22.676058] INFO: thread[7] start creating table from 8750 to 9999
[01/07 12:12:24.316949] SUCC: Spent 1.6500 seconds to create 10000 table(s) with 8 thread(s), already exist 0 table(s), actual 10000 table(s) pre created, 0 table(s) will be auto created
Press enter key to continue or Ctrl-C to stop
[01/07 12:12:29.271717] INFO: record per request (30000) is larger than insert rows (10000) in progressive mode, which will be set to 10000
[01/07 12:12:29.327505] INFO: Total 2482 tables on bb test's vgroup 0 (id: 4)
[01/07 12:12:29.327522] INFO: Total 2522 tables on bb test's vgroup 1 (id: 5)
[01/07 12:12:29.327549] INFO: Total 2520 tables on bb test's vgroup 2 (id: 6)
[01/07 12:12:29.327568] INFO: Total 2476 tables on bb test's vgroup 3 (id: 7)
[01/07 12:12:29.391136] INFO: Estimate memory usage: 283.60MB
Press enter key to continue or Ctrl-C to stop
[01/07 12:12:37.566155] INFO: pthread_join 0 ...
[01/07 12:13:07.581119] INFO: thread[2] has currently inserted rows: 4900000, peroid insert rate: 163251.707 rows/s
[01/07 12:13:07.584158] INFO: thread[1] has currently inserted rows: 4910000, peroid insert rate: 163568.526 rows/s
[01/07 12:13:07.584970] INFO: thread[3] has currently inserted rows: 4900000, peroid insert rate: 163235.392 rows/s
[01/07 12:13:07.959306] INFO: thread[0] has currently inserted rows: 4940000, peroid insert rate: 162537.426 rows/s
[01/07 12:13:37.585407] INFO: thread[1] has currently inserted rows: 9790000, peroid insert rate: 162661.245 rows/s
[01/07 12:13:37.585692] INFO: thread[2] has currently inserted rows: 9970000, peroid insert rate: 168977.470 rows/s
[01/07 12:13:37.636150] INFO: thread[3] has currently inserted rows: 9990000, peroid insert rate: 169373.087 rows/s
[01/07 12:13:37.973312] INFO: thread[0] has currently inserted rows: 10130000, peroid insert rate: 172919.304 rows/s
[01/07 12:14:07.596251] INFO: thread[1] has currently inserted rows: 14850000, peroid insert rate: 168604.845 rows/s
[01/07 12:14:07.602622] INFO: thread[2] has currently inserted rows: 15030000, peroid insert rate: 168571.143 rows/s
[01/07 12:14:08.247951] INFO: thread[0] has currently inserted rows: 15090000, peroid insert rate: 163836.956 rows/s
[01/07 12:14:08.303297] INFO: thread[3] has currently inserted rows: 15090000, peroid insert rate: 166302.540 rows/s
[01/07 12:14:37.625015] INFO: thread[1] has currently inserted rows: 19790000, peroid insert rate: 164507.643 rows/s
[01/07 12:14:37.629453] INFO: thread[2] has currently inserted rows: 19830000, peroid insert rate: 159856.129 rows/s
[01/07 12:14:38.336561] INFO: thread[0] has currently inserted rows: 19880000, peroid insert rate: 159194.390 rows/s
[01/07 12:14:38.388810] INFO: thread[3] has currently inserted rows: 19870000, peroid insert rate: 158883.164 rows/s
[01/07 12:15:05.195084] SUCC: thread[3] progressive mode, completed total inserted rows: 24760000, 179445.39 records/second
[01/07 12:15:07.649704] INFO: thread[2] has currently inserted rows: 24590000, peroid insert rate: 158560.959 rows/s
[01/07 12:15:07.675532] INFO: thread[1] has currently inserted rows: 24680000, peroid insert rate: 162728.785 rows/s
[01/07 12:15:08.343712] INFO: thread[0] has currently inserted rows: 24650000, peroid insert rate: 158962.909 rows/s
[01/07 12:15:08.756175] SUCC: thread[0] progressive mode, completed total inserted rows: 24820000, 175445.37 records/second
[01/07 12:15:08.756393] INFO: pthread_join 1 ...
[01/07 12:15:09.262905] SUCC: thread[2] progressive mode, completed total inserted rows: 25200000, 177605.51 records/second
[01/07 12:15:11.574702] SUCC: thread[1] progressive mode, completed total inserted rows: 25220000, 174897.55 records/second
[01/07 12:15:11.574861] INFO: pthread_join 2 ...
[01/07 12:15:11.574877] INFO: pthread_join 3 ...
[01/07 12:15:11.576252] SUCC: Spent 154.008730 (real 141.383857) seconds to insert rows: 100000000 with 4 thread(s) into test 649313.84 (real 707294.33) records/second
[01/07 12:15:11.576289] SUCC: insert delay, min: 16.9580ms, avg: 56.5535ms, p90: 84.4130ms, p95: 95.8320ms, p99: 534.7680ms, max: 1878.0990ms
myw@myw-S451LN:~$
插入1亿条数据花的时间长了些 那是因为电脑是S451LN 很老很老的电脑了 如果是io高或者固态硬盘很快
查询超级表的总条数
SELECT COUNT(*) FROM test.meters;
taos> SELECT COUNT(*) FROM test.meters;
count(*) |
========================
100000000 |
Query OK, 1 row(s) in set (0.284454s)
taos>
查询 1 亿条记录的平均值、最大值、最小值
SELECT AVG(current), MAX(voltage), MIN(phase) FROM test.meters;
taos> SELECT AVG(current), MAX(voltage), MIN(phase) FROM test.meters;
avg(current) | max(voltage) | min(phase) |
==================================================================
0.057360763841361 | 18 | -1.0000000 |
Query OK, 1 row(s) in set (0.576719s)
taos>
查询 location = “California.SanFrancisco” 的记录总条数
SELECT COUNT(*) FROM test.meters WHERE location = "California.SanFrancisco";
taos> SELECT COUNT(*) FROM test.meters WHERE location = "California.SanFrancisco";
count(*) |
========================
10200000 |
Query OK, 1 row(s) in set (0.052531s)
taos>
查询 groupId = 10 的所有记录的平均值、最大值、最小值文章来源:https://www.toymoban.com/news/detail-811529.html
SELECT AVG(current), MAX(voltage), MIN(phase) FROM test.meters WHERE groupId = 10;
taos> SELECT AVG(current), MAX(voltage), MIN(phase) FROM test.meters WHERE groupId = 10;
avg(current) | max(voltage) | min(phase) |
==================================================================
0.057453115410926 | 18 | -1.0000000 |
Query OK, 1 row(s) in set (0.096468s)
taos>
对表 d10 按每 10 秒进行平均值、最大值和最小值聚合统计文章来源地址https://www.toymoban.com/news/detail-811529.html
SELECT FIRST(ts), AVG(current), MAX(voltage), MIN(phase) FROM test.d10 INTERVAL(10s);
taos> SELECT FIRST(ts), AVG(current), MAX(voltage), MIN(phase) FROM test.d10 INTERVAL(10s);
first(ts) | avg(current) | max(voltage) | min(phase) |
============================================================================================
2017-07-14 10:40:00.000 | 0.054056339328364 | 18 | -0.9998480 |
Query OK, 1 row(s) in set (0.030202s)
taos>
到了这里,关于Ubuntu系统下安装TDengine Database的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!