本文介紹時序數據庫Influxdb3 core(開源版本)的安裝和簡單使用以及調優參數的介紹。
預期:
安裝時序數據庫Influxdb3 core
創建數據庫mydb
寫入數據;
使用influxdb3-cli 和 grafana2種方式查詢寫入的數據
前期準備:
linux服務器(本文服務器配置為debain12.6 64G內存、32 cpu、 1T存儲)
influxdb3-core_3.1.0-1_amd64.deb(截稿時的最新版本) 下載地址:InfluxData - Package Repository
開始安裝:
- 上傳influxdb3-core_3.1.0-1_amd64.deb至服務器;
- 執行安裝命令(必須root用戶安裝)
sudo dpkg -i influxdb3-core_3.1.0-1_amd64.deb
- 驗證安裝完成
influxdb3 --version
簡單使用:
1. 啟動服務:
influxdb3 serve \--node-id host01 \--object-store file \--query-file-limit 10000 \ --exec-mem-pool-bytes 42949672960 \--parquet-mem-cache-size 16000 \--last-cache-eviction-interval 5s \--datafusion-max-parquet-fanout 10000 \--wal-max-write-buffer-size 200000 \--log-filter info \--data-dir /root/influxdb3 \> /root/influxdb3/influxdb3.log 2>&1 &
serve參數介紹:
--exec-mem-pool-bytes 17179869184 單位是Bytes
--parquet-mem-cache-size 2000 單位是MB
--query-file-limit 4320 設置查詢允許掃描的文件個數
--datafusion-max-parquet-fanout 5000 sort是可同時處理file的數量
--last-cache-eviction-interval 5s 從Last-N-Value緩存中清除過期條目的時間間隔
--gen1-duration default10m,可選值:1m
, 5m
, and 10m
(query-file-limit基于這個參數計算得出)
2. 創建token
influxdb3 create token --admin
記住該命令返回的Token,后續使用都要用。
3. 創建數據庫:
influxdb3 create database mydb --token <第2步生成的token>
4. 寫入數據:
influxdb3 write \--database mydb \--token <第2步生成的token> \'home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1641024000
home,room=Kitchen temp=21.0,hum=35.9,co=0i 1641024000
home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1641027600
home,room=Kitchen temp=23.0,hum=36.2,co=0i 1641027600
home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1641031200
home,room=Kitchen temp=22.7,hum=36.1,co=0i 1641031200
home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1641034800
home,room=Kitchen temp=22.4,hum=36.0,co=0i 1641034800
home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1641038400
home,room=Kitchen temp=22.5,hum=36.0,co=0i 1641038400
home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1641042000
home,room=Kitchen temp=22.8,hum=36.5,co=1i 1641042000'
5. 查詢數據:
a. 使用influxdb3-cli
influxdb3 query \--database mydb \--token <第2步生成的token> \"SELECT * FROM home"
b. 使用grafana
-
-
- Add new Connetcion
-
-
-
- 按頁面提示輸入信息:
-
-
-
- 點擊grafana左側面板上的explore,選擇數據源,開始使用
-
本文完。
附錄:
- 官方文檔地址:InfluxDB 3 Core Documentation