TDengine 常見問題解答

  • 佔用端口 

  • 默認用戶名及密碼:root taosdata
  • RESTful 接口默認端口:6041
  • 客戶端端口:6030
  • RESTful Connector

爲支持各種不同類型平臺的開發,TDengine 提供符合 REST 設計標準的 API,即 RESTful API。爲最大程度降低學習成本,不同於其他數據庫 RESTful API 的設計方法,TDengine 直接通過 HTTP POST 請求 BODY 中包含的 SQL 語句來操作數據庫,僅需要一個 URL。RESTful 連接器的使用參見視頻教程

注意:與標準連接器的一個區別是,RESTful 接口是無狀態的,因此 USE db_name 指令沒有效果,所有對錶名、超級表名的引用都需要指定數據庫名前綴。(從 2.2.0.0 版本開始,支持在 RESTful url 中指定 db_name,這時如果 SQL 語句中沒有指定數據庫名前綴的話,會使用 url 中指定的這個 db_name。)

安裝

RESTful 接口不依賴於任何 TDengine 的庫,因此客戶端不需要安裝任何 TDengine 的庫,只要客戶端的開發語言支持 HTTP 協議即可。

驗證

在已經安裝 TDengine 服務器端的情況下,可以按照如下方式進行驗證。

下面以 Ubuntu 環境中使用 curl 工具(確認已經安裝)來驗證 RESTful 接口的正常。

下面示例是列出所有的數據庫,請把 h1.taosdata.com 和 6041(缺省值)替換爲實際運行的 TDengine 服務 fqdn 和端口號:

curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' h1.taosdata.com:6041/rest/sql

返回值結果如下表示驗證通過:

{
  "status": "succ",
  "head": ["name","created_time","ntables","vgroups","replica","quorum","days","keep1,keep2,keep(D)","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","precision","status"],
  "data": [
    ["log","2020-09-02 17:23:00.039",4,1,1,1,10,"30,30,30",1,3,100,4096,1,3000,2,"us","ready"],
    ],
  "rows": 1
}

上述摘自:https://www.taosdata.com/cn/documentation/connector#restful

  • Widnows客戶端連接失敗 

C:\TDengine>taos -h www.summergao.com -s "use summergao; show tables;"

Welcome to the TDengine shell from Linux, Client Version:2.2.1.3
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.

taos connect failed, reason: Unable to establish connection.

問題原因:在服務器端只開放了6030的TCP端口。

解決辦法:在服務器端同時開放6030的TCP和UDP端口。

firewall-cmd --zone=public --add-port=6030/tcp --permanent
firewall-cmd --zone=public --add-port=6030/udp --permanent
firewall-cmd --reload

 再次執行成功:

C:\TDengine>taos -h www.summergao.com -s "use summergao; show tables;"

Welcome to the TDengine shell from Linux, Client Version:2.2.1.3
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.

taos> use summergao; show tables;
Query OK, 0 of 0 row(s) in database (0.021000s)

           table_name           |      created_time       | columns |          stable_name           |          uid          |     tid     |    vgId     |
==========================================================================================================================================================
 t                              | 2021-11-04 14:07:46.124 |       2 |                                |       844424946914061 |           1 |           3 |
Query OK, 1 row(s) in set (0.304000s)


C:\TDengine>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章