InfluxDB

Aus Hackerspace Ffm
Wechseln zu: Navigation, Suche

Hoch effiziente in Go geschriebene Opensource-Datenbank für Zeitreihen wie IoT-Sensordaten und Echtzeitanalysen

Installation

 curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
 echo "deb https://repos.influxdata.com/debian stretch stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
 sudo apt update
 sudo apt install influxdb telegraf
 sudo systemctl enable influxdb
 sudo systemctl start influxdb

Konfigurieren

 influx
 
 > CREATE DATABASE openhab_db
 > CREATE USER admin WITH PASSWORD '<passwort>' WITH ALL PRIVILEGES
 > CREATE USER openhab WITH PASSWORD '<passwort>'
 > CREATE USER grafana WITH PASSWORD '<passwort>'
 > GRANT ALL ON openhab_db TO openhab
 > GRANT READ ON openhab_db TO grafana
 > exit

Authentifizierung für http in Konfigurationsdatei /etc/influxdb/influxdb.conf eintragen

 [http]  
 enabled = true  
 bind-address = ":8086"
 auth-enabled = true

Service neu starten

 sudo systemctl restart influxdb.service

Testen ob es geht

 influx -username grafana -password <passwort> -host localhost
 use openhab_db

Command Line

 influx -username grafana -password <passwort>
 show databases
 use openhab_db
 show measurements // tables
 select * from cpu_temp
 select * from cpu_temp limit 3
 
 name: cpu_temp
 time                value
 ----                -----
 1531852226992000000 50.5
 1531852230885000000 49.9
 1531852234905000000 49.4

Um die Zeit lesbar zu machen

 precicionrfc3339
 select * from cpu_temp limit 3
 name: cpu_temp
 time                     value
 ----                     -----
 2018-07-17T18:30:26.992Z 50.5
 2018-07-17T18:30:30.885Z 49.9
 2018-07-17T18:30:34.905Z 49.4