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 !
  目录
分类导航
随笔3 AI29 计算机基础13 算法1 博客搭建7 ChatGPT2 集群63 计算机通信1 数据库59 数据库深入93 数据库93 Docker11 DPDK26 编辑工具4 Elasticsearch4 FAQ1 Go Web1 hometown2 编程语言16 人生11 网络9 Linux38 OPC1 openGauss4 页面12 PostgreSQL54 程序员自我修养1 协议11 stock1 存储5 成长之路1 工具20 视频作品1 VPP18 Vue13 Web1 代码示例11 BenchmarkSQL1 PostgreSQL 源码修炼之路14
最热文章
1
PostgreSQL 逻辑复制全链路:以一个真实事务为例,从 `INSERT` 到 `apply` 的源码级旅程
数据库🔥 2162
2
PostgreSQL 逻辑复制 Stream 执行逻辑源码级拆解:从 reorderbuffer 触发到订阅端落盘回放
数据库🔥 1765
3
PostgreSQL 行锁机制源码级深度拆解:4 种锁模式 + xmax + MultiXact 的完整链路
数据库🔥 1656
4
PostgreSQL reorderbuffer.c 函数级源码全集:5615 行 / 95 个函数的逐函数解析
数据库深入🔥 1650
5
PostgreSQL 目录快照源码级深度拆解:系统表读取的 MVCC 真相与失效机制
数据库🔥 1604
6
13 逻辑复制深入
数据库深入🔥 1570
7
0 Postgresql存储、索引及系统优化、主备切换
PostgreSQL🔥 1495
8
PostgreSQL 读一行数据源码级深度拆解:MVCC 在每个环节的落点
数据库🔥 1464
9
PostgreSQL WAL 记录类型完全指南:21 个 RMGR × 80+ 种记录的源码级拆解
数据库🔥 1431
10
一文读懂openguass dcf网络模块
集群🔥 1420
11
PostgreSQL 元数据存储机制:从磁盘文件到内存缓存,`pg_class` 撑起的整个系统表体系
数据库🔥 1411
12
openGauss 并行解码设计原理深度拆解:reader + 多 worker + CSN 三层架构的源码级剖析
数据库深入🔥 1344
13
逻辑复制源码分析
数据库深入🔥 1327
14
PostgreSQL 逻辑复制:catalog 改动、可见性判定与 xmin/xmax 推进全景
数据库深入🔥 1317
15
自托管服务全家桶:从原文方案到可复制实操手册
人生🔥 1278
16
PostgreSQL CREATE_REPLICATION_SLOT 端到端源码分析:从 SQL 到 snapbuild 状态机的完整链路(每个函数每个参数)
数据库深入🔥 1277
17
PostgreSQL syscache 模块源码深度拆解:CatCache 数据结构、LRU 哈希表、cache invalidation 全链路
数据库深入🔥 1216
18
PostgreSQL 18 内核数据结构全景:RangeVar 与 20+ 个核心数据结构源码级拆解
数据库🔥 1158
19
PostgreSQL 逻辑复制里 `RUNNING_XACTS` 写入机制与快照 `xmin / xmax / xip` 的演化:源码级深度拆解
数据库🔥 1119
20
PostgreSQL 分区表:从一行 `PARTITION BY` 到路由热路径的全链路拆解
数据库🔥 1094