taosd基本使用


难度 中等

taos是一个开源的时序数据库,目前发展势头较好,走的开源路线。

二进制包下载安装

server

需要到taos官网下载,但是无法直接获取下载链接,要输入邮箱(能获取到联系你的方式,便于统计下载量),会将下载链接发送到的你的邮箱。

wget https://www.taosdata.com/assets-download/3.0/TDengine-server-3.3.2.0-Linux-x64.rpm
rpm -i TDengine-server-3.3.2.0-Linux-x64.rpm
systemctl start taosd

需要使用root用户安装。

taosd的默认数据库目录在/var/lib/taos下面,他的配置文件在/etc/taos/taos.cfg。

taos的数据库目录结构大致如下:

/var/lib/taos
├── dnode
│   ├── dnode.info
│   └── dnode.json
├── mnode
│   ├── data
│   ├── mnode.json
│   ├── sync
│   └── wal
└── vnode

taos默认以root用户运行:(已常规数据库有所区别,一般数据库都是以普通用户运行的,比如postgres、mysql)。

(base) ➜  ~ ps -ef | grep taosd
root     3744260       1  0 11:07 ?        00:00:00 /usr/bin/taosd

如果没有明确指定,taos默认监听127.0.0.1的6300端口,只能本机访问。同时还会监听一个unix domain socket。

(base) ➜  ~ sudo netstat -anp | grep taos
tcp        0      0 0.0.0.0:6030            0.0.0.0:*               LISTEN      3744260/taosd       
tcp        0      0 127.0.0.1:6030          127.0.0.1:54630         ESTABLISHED 3744260/taosd       
tcp        0      0 127.0.0.1:54630         127.0.0.1:6030          ESTABLISHED 3744260/taosd       
unix  2      [ ACC ]     STREAM     LISTENING     293894282 3744286/udfd         /var/lib/taos//.udfd.sock.1

taos默认的运行日志放在/var/log/taos/目录下面,其目录结构如下:

/var/log/taos
├── taosdlog.0
├── taosSlowLog
├── tdengine_install.log
└── udfdlog.0

我们要使taosd能对外服务,就不能使用127.0.0.1这个ip,而是要使用对外的ip,这里需要修改配置文件。

vim /etc/taos/taos.cfg
(base) ➜  ~ cat /etc/taos/taos.cfg | grep fqdn
fqdn                      taosdb

将fqdn那行后面的域名换成自己的ip或者域名,如果使用的是域名的话,可以在/etc/hosts里添加域名和ip的映射关系。

修改完成后需要重启taosd,需要特别注意的是因为taosd会默认写一些数据到/var/lib/taos的数据目录下,目前直接修改配置文件重启会失败。(当前采用的措施是删除数据库目录重新启动)

07/22 11:19:24.065295 03779249 C DND start to init dnode env
07/22 11:19:24.065674 03779249 C DND succceed to read dnode file /var/lib/taos//dnode/dnode.json
07/22 11:19:24.065694 03779249 C DND ERROR dnode:1, localEp taosdb:6030 different from node1:6030
07/22 11:19:24.065698 03779249 C DND ERROR localEp taosdb:6030 different with /var/lib/taos//dnode/dnode.json and need to be reconfigured
07/22 11:19:24.065781 03779249 C DND ERROR failed to read file since Invalid config option
07/22 11:19:24.065791 03779249 C DND ERROR failed to create dnode since Invalid config option
07/22 11:19:24.065794 03779249 C DND ERROR failed to init dnode since Invalid config option
sudo rm -rf /var/lib/taos/*
sudo systemctl restart taosd 

重启之后配置正确的话就会监听对外的ip和端口了。

client

cli

安装server时默认就安装了cli,直接使用taos命令就可以连接数据库。(没有设置密码也没有指定端口、数据库,所以我也不知道密码用户数据库是什么,缺省用户和密码似乎是root和taosdata)

(base) ➜  ~ taos
Welcome to the TDengine Command Line Interface, Client Version:3.3.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 TDengine Community Edition, ver:3.3.2.0 and will never expire.

taos> 

尝试了一下基本命令,看起来有点像是类mysql的,没有postgres的\d、\d+,倒是有show databases。

taos> \d+
    > ;

DB error: unrecognized token: "\d+ ;" (0.000059s)
taos> \d;

DB error: unrecognized token: "\d;" (0.000033s)
taos> help
    > ;

DB error: syntax error near "help ;" (0.000036s)
taos> show database;

DB error: syntax error near "database;" (0.000041s)
taos> show databases;
              name              |
=================================
 information_schema             |
 performance_schema             |
Query OK, 2 row(s) in set (0.000737s)

taos> 

windows cli

taos官网提供了客户端程序,同样需要输入邮箱地址才能下载,下载链接会发到邮箱地址。

wget https://www.taosdata.com/assets-download/3.0/TDengine-client-3.3.2.0-Windows-x64.exe

下载完成后可以安装到windows,可以生成桌面快捷方式,但实际上是启动了一个cmd窗口,可以使用taos命令连接服务端,还是没有界面。

 C:\TDengine 的目录

2024/07/22  14:06    <DIR>          .
2024/07/22  14:06    <DIR>          cfg
2024/07/22  14:06    <DIR>          connector
2024/07/22  14:06    <DIR>          driver
2024/07/22  14:06    <DIR>          examples
2024/07/22  14:06    <DIR>          include
2024/07/22  11:44    <DIR>          log
2024/03/26  23:17           982,296 msvcp140d.dll
2024/06/28  12:14         4,833,280 taos.exe
2024/06/28  12:14           475,136 taosBenchmark.exe
2024/06/28  12:14           654,848 taosdump.exe
2024/07/22  14:06    <DIR>          taos_odbc
2024/07/22  14:06            48,905 unins000.dat
2024/07/22  14:06         3,141,379 unins000.exe
C:\TDengine>taos -h taosdb
Welcome to the TDengine Command Line Interface, Client Version:3.3.2.0
Copyright (c) 2023 by TDengine, all rights reserved.

Server is TDengine Community Edition, ver:3.3.2.0 and will never expire.

taos> show databases;
              name              |
=================================
 information_schema             |
 performance_schema             |
Query OK, 2 row(s) in set (0.038056s)

taos>

webui

taos还提供了一个web操作管理界面taos-explorer,不过属于付费功能,github下面也没有该仓库的开源。

源码编译安装


文章作者: growdu
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 growdu !
  目录
分类导航
随笔2 AI27 算法1 计算机基础13 博客搭建7 ChatGPT2 集群63 计算机通信1 数据库34 数据库深入80 DPDK26 Docker11 Elasticsearch4 编辑工具4 FAQ1 Go Web1 hometown2 编程语言16 网络9 OPC1 Linux38 openGauss4 页面12 PostgreSQL54 程序员自我修养1 协议11 成长之路1 stock1 存储5 工具20 VPP18 视频作品1 Vue13 Web1 代码示例11 数据库15 BenchmarkSQL1 PostgreSQL 源码修炼之路14
最热文章
1
13 逻辑复制深入
数据库深入🔥 1570
2
0 Postgresql存储、索引及系统优化、主备切换
PostgreSQL🔥 1495
3
一文读懂openguass dcf网络模块
集群🔥 1420
4
逻辑复制源码分析
数据库深入🔥 1327
5
PostgreSQL 分区表:从一行 `PARTITION BY` 到路由热路径的全链路拆解
数据库🔥 1094
6
applyparallelworker.c 之 LA 端源码深度解析:Leader Apply Worker 的指挥中枢
数据库深入🔥 1082
7
PostgreSQL Background Worker 全解:从 `RegisterBackgroundWorker` 到逻辑复制 4 类 worker 的全生命周期
数据库🔥 1078
8
PostgreSQL的后台进程walsender分析 - 关系型数据库 - 亿速云
PostgreSQL🔥 1033
9
PostgreSQL 逻辑复制的监控:六张视图 + 一组可执行 SQL,把 publisher/subscriber 的速率与健康度彻底看透
数据库🔥 1032
10
PostgreSQL 逻辑复制支持 DDL 之后:DDL 与 DML 的时序难题(重点:分区表)
数据库🔥 999
11
reorderbuffer.c 源码深度解析:PostgreSQL 逻辑复制的"事务重组引擎
数据库深入🔥 953
12
PostgreSQL 内核开发:读取一张表的 9 步标准流程与缓存全景
数据库🔥 938
13
从 `postgres` 二进制到生产级守护 —— PostgreSQL 最外层模块与启动全流程拆解
数据库🔥 936
14
支持逻辑复制同步 DDL 适配 SQL Server 方案
数据库深入🔥 934
15
PostgreSQL 逻辑复制的 ReorderBuffer 与事务机制:从一行 WAL 到一致性变更流的全链路绑定
数据库🔥 913
16
DDL同步架构(美化版)
数据库深入🔥 908
17
PostgreSQL Latch 机制详解:从一行 SetLatch 到 epoll 的内核之旅
数据库🔥 871
18
pgbench 源码全解:一个 C 文件如何撑起 PostgreSQL 官方压测工具
数据库🔥 860
19
PostgreSQL libpq 机制与缓冲区详解
数据库🔥 850
20
PostgreSQL 逻辑复制 spill 文件深度剖析:从 `xid-*.spill` 到 TPC-C 的增长方程
数据库🔥 845