Seite 1 von 2

openhab + influxdb + auth Problem

Verfasst: 22. Mär 2020 19:46
von Alex
Hallo zusammen,

ich bin ganz neu hier und erst vor kurzem das erste mal mit einem raspPi 4 und dem openhab 2.5 in Berührung gekommen. Bisher habe ich items, bindings etc. einbinden können und diese sowohl über Basic Ui und Habpanel auslesen und anzeigen lassen.

Ich bitte um eure Unterstützung für mein folgendes Problem:
Ich möchte als nächstes influxdb und grafana nutzen, um mir die Werte visualiseren zu können.
Leider bekomme ich die Nutzung von influx nicht hin, da ich sowohl über die Installationsroutine in openhab (sudo openhabian-config) als auch über Einzelinstallation einen Authentifizierung Fehler bekomme. Ich kann nicht auf influxdb mit den entsprechenden Berechtigungen zugreifen.

Hier die Fehlermeldung bei der Direktinstallation:

$ systemctl restart influxdb.service
OK Configure InfluxDB admin account... {"results":[{"statement_id":0,"error":"user already exists"}]}
OK Configure listen on localhost only...
$ sed -i -e /# Determines whether HTTP endpoint is enabled./ { n ; s/# enabled = true/enabled = true/ } /etc/influxdb/influxdb.conf
$ sed -i s/# bind-address = ":8086"/bind-address = "localhost:8086"/g /etc/influxdb/influxdb.conf
$ sed -i s/# auth-enabled = false/auth-enabled = true/g /etc/influxdb/influxdb.conf
$ sed -i s/# store-enabled = true/store-enabled = false/g /etc/influxdb/influxdb.conf
$ systemctl restart influxdb.service
OK
Setup of inital influxdb database and InfluxDB users... {"error":"authorization failed"}
{"error":"authorization failed"}
{"error":"authorization failed"}
{"error":"authorization failed"}
{"error":"authorization failed"}


Wenn ich influx starte und ausführen möchte, erscheint folgende Fehlermeldung:
$ influx
Connected to http://localhost:8086 version 1.7.10
InfluxDB shell version: 1.7.10
> auth
username: openhab
password:
> CREATE DATABASE mydb
ERR: authorization failed
Warning: It is possible this error is due to not setting a database.
Please set a database with the command "use <database>".

----

Hier ein Auszug aus meiner Konfiguration, wenn noch etwas fehlt, lasst es mich bitte wissen:
Zugriff über PuTTY

Release = Raspbian GNU/Linux 10 (buster)
## Kernel = Linux 4.19.97-v7l+
## Platform = Raspberry Pi 4 Model B Rev 1.2
CPU Usage = 42.47% avg over 4 cpu(s) (4 core(s) x 1 socket(s))
## CPU Load = 1m: 1.16, 5m: 0.27, 15m: 0.09
## Memory = Free: 3.32GB (86%), Used: 0.53GB (14%), Total: 3.86GB
## Swap = Free: 0.09GB (100%), Used: 0.00GB (0%), Total: 0.09GB
## Root = Free: 21.73GB (78%), Used: 6.04GB (22%), Total: 28.99GB
## Updates = 0 apt updates available.
## Sessions = 1 session(s)
## Processes = 126 running processes of 32768 maximum processes

Ich habe jetzt mehrmals probiert, influx zu deinstallieren und wieder zu installieren, habe aber das Gefühl, dass noch irgendwo Einträge in Files hängen, die zu diesem Authorization Problem führen.

Wie kann ich influxdb restlos von meinem System deinstallieren (sudo apt-get remove --auto-remove influxdb und sudo apt-get purge --auto-remove influxdb habe ich bereits mehrfach ausgeführt) und welche Dateien müssen noch gelöscht werden, damit ich "jungfräulich" von vorne mit der Installation beginnen kann?
Wie und wo kann ich die Authorization einsehen oder ändern, um das Authentifizierungsproblem abszustellen?

Ich hoffe sehr auf eure Unterstützung und schnelle Hilfe... Vielen Dank vorab und viele Grüße
Alex

Re: openhab + influxdb + auth Problem

Verfasst: 23. Mär 2020 09:08
von udo1toni
Du hast die Meldung aber schon gelesen, oder?
Dein Problem ist, dass es zum einen keine Datenbank gibt, und Du zum anderen versuchst, Sich mit dem falschen User zu authentifizieren.

Zuerst musst Du mit root in die Management Konsole, dann eine Datenbank und User anlegen und zum Schluss auch noch die Berechtigungen setzen. Hast Du Dir mal das Tutorial im englischen Forum angeschaut?

Gesendet von meinem SM-G973F mit Tapatalk


Re: openhab + influxdb + auth Problem

Verfasst: 23. Mär 2020 19:02
von Alex
Hallo zusammen, hallo udo1toni,

vielen Dank für die schnelle Antwort und die Hinweise.
Ja, ich habe versucht, die englische Anleitung nachzuvollziehen. Ist mir offensichtlich nicht gelungen. Mag zum einen daran liegen, dass ich nur rudimentäre Programmierkenntnisse habe und mein Englisch nur ausreichend ist. Deswegen schreibe ich ja auch im deutschen Forum und hoffe auf eure Unterstützung ;) Aber, man lernt ja immer dazu. Ich fange ja gerade erst mit openhab und IoT ("Intranet" of Things) an und bin nach wie vor total begeistert.
udo1toni hat geschrieben: 23. Mär 2020 09:08 Zuerst musst Du mit root in die Management Konsole,...
Kannst du mir bitte beschreiben, wie das geht? Was muss ich eingeben? (Ich weiß nicht, was root bedeutet und wie die Management Konsole aussieht)

Ich hätte jetzt folgendes probiert:

[18:45:15] openhabian@openhab:~$ influx
Connected to http://localhost:8086 version 1.7.10
InfluxDB shell version: 1.7.10
>

Wenn ich nun versuche, eine Datenbank anzulegen, erscheint folgendes:

> CREATE DATABASE mydb
ERR: authorization failed
Warning: It is possible this error is due to not setting a database.
Please set a database with the command "use <database>".
> use mydb
WARN: authorization failed
Using database mydb
> show databases
ERR: authorization failed

Was mache ich falsch? Wie kann ich sicherstellen, welche Credentials hinterlegt sind und wie kann ich die ändern?

Vielen Dank vor und viele Grüße
Alex

Re: openhab + influxdb + auth Problem

Verfasst: 23. Mär 2020 22:07
von udo1toni
So aus dem Gedächtnis würde ich behaupten, mit sudo influx solltest Du automatisch Superuser auf der Datenbankengine sein.

Re: openhab + influxdb + auth Problem

Verfasst: 23. Mär 2020 22:13
von Alex
:D
[22:09:36] openhabian@openhab:~$ sudo influx
Connected to http://localhost:8086 version 1.7.10
InfluxDB shell version: 1.7.10
>
> CREATE USER admin2 WITH PASSWORD 'admin2' WITH ALL PRIVILEGES
ERR: unable to parse authentication credentials
Warning: It is possible this error is due to not setting a database.
Please set a database with the command "use <database>".
> show databases
ERR: unable to parse authentication credentials
Warning: It is possible this error is due to not setting a database.
Please set a database with the command "use <database>".
>

.... ich komme einfach nicht weiter....

Re: openhab + influxdb + auth Problem

Verfasst: 23. Mär 2020 22:44
von udo1toni
Du musst zuerst eine Datenbank anlegen.

Code: Alles auswählen

$ influx
Connected to http://localhost:8086 version 0.13
InfluxDB shell version: 0.13
> CREATE DATABASE openhab_db
> CREATE USER admin WITH PASSWORD 'SuperSecretPassword123+' WITH ALL PRIVILEGES
> CREATE USER openhab WITH PASSWORD 'AnotherSuperbPassword456-'
> CREATE USER grafana WITH PASSWORD 'PleaseLetMeRead789?'
> GRANT ALL ON openhab_db TO openhab
> GRANT READ ON openhab_db TO grafana
> exit

Re: openhab + influxdb + auth Problem

Verfasst: 24. Mär 2020 06:17
von Alex
Hallo udo1toni,

ich habe influx und grafana deinstalliert:
>sudo apt-get remove --auto-remove influxdb
>sudo apt-get remove --auto-remove grafana
und
>sudo apt-get purge --auto-remove influxdb
>sudo apt-get purge --auto-remove grafana

Muss ich bei Deinstallation moch mehr berücksichtigen?

Danach habe ich neu installiert über die Routine in openhabian-config (influxdb + grafana).

Hier das log:

Installing InfluxDB...

$ apt-get -y install apt-transport-https
Reading package lists... Done
Building dependency tree
Reading state information... Done
apt-transport-https is already the newest version (1.8.2).
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
--2020-03-23 22:31:40-- https://repos.influxdata.com/influxdb.key
Resolving repos.influxdata.com (repos.influxdata.com)... 2600:9000:20e8:3200:7:7790:e740:93a1, 2600:9000:20e8:6600:7:7790:e740:93a1, 2600:9000:20e8:36 00:7:7790:e740:93a1, ...
Connecting to repos.influxdata.com (repos.influxdata.com)|2600:9000:20e8:3200:7:7790:e740:93a1|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3108 (3.0K) [application/pgp-keys]
Saving to: ‘STDOUT’

- 100%[=======================================================================>] 3.04K --.-KB/s in 0s

2020-03-23 22:31:40 (11.9 MB/s) - written to stdout [3108/3108]

OK

$ apt-get update
Hit:1 http://raspbian.raspberrypi.org/raspbian buster InRelease
Hit:2 https://repos.influxdata.com/debian buster InRelease
Hit:3 http://archive.raspberrypi.org/debian buster InRelease
Hit:4 https://packages.grafana.com/oss/deb stable InRelease
Ign:5 https://dl.bintray.com/openhab/apt-repo2 stable InRelease
Get:6 https://dl.bintray.com/openhab/apt-repo2 stable Release [6,051 B]
Fetched 6,051 B in 2s (3,352 B/s)
Reading package lists... Done

$ apt-get -y install influxdb
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
influxdb
0 upgraded, 1 newly installed, 0 to remove and 5 not upgraded.
Need to get 0 B/59.4 MB of archives.
After this operation, 158 MB of additional disk space will be used.
Selecting previously unselected package influxdb.
(Reading database ... 47594 files and directories currently installed.)
Preparing to unpack .../influxdb_1.7.10-1_armhf.deb ...
Unpacking influxdb (1.7.10-1) ...
Setting up influxdb (1.7.10-1) ...
Processing triggers for man-db (2.8.5-2) ...
Updating FireMotD available updates count ...

$ systemctl daemon-reload

$ systemctl enable influxdb.service

$ systemctl restart influxdb.service
OK Configure InfluxDB admin account... {"results":[{"statement_id":0,"error":"user already exists"}]}
OK Configure listen on localhost only...
$ sed -i -e /# Determines whether HTTP endpoint is enabled./ { n ; s/# enabled = true/enabled = true/ } /etc/influxdb/influxdb.conf

$ sed -i s/# bind-address = ":8086"/bind-address = "localhost:8086"/g /etc/influxdb/influxdb.conf

$ sed -i s/# auth-enabled = false/auth-enabled = true/g /etc/influxdb/influxdb.conf

$ sed -i s/# store-enabled = true/store-enabled = false/g /etc/influxdb/influxdb.conf

$ systemctl restart influxdb.service
OK
Setup of inital influxdb database and InfluxDB users... {"error":"authorization failed"}
{"error":"authorization failed"}
{"error":"authorization failed"}
{"error":"authorization failed"}
{"error":"authorization failed"}

[22:34:59] openhabian@openhab:~$ influx
Connected to http://localhost:8086 version 1.7.10
InfluxDB shell version: 1.7.10
> CREATE DATABASE openhab_db
ERR: unable to parse authentication credentials
Warning: It is possible this error is due to not setting a database.
Please set a database with the command "use <database>".
> use openhab_db
ERR: unable to parse authentication credentials
DB does not exist!
> exit
[22:35:50] openhabian@openhab:~$ sudo influx
Connected to http://localhost:8086 version 1.7.10
InfluxDB shell version: 1.7.10
> CREATE USER admin WITH PASSWORD 'admin' WITH ALL PRIVILEGES
ERR: unable to parse authentication credentials
Warning: It is possible this error is due to not setting a database.
Please set a database with the command "use <database>".
>

Es will nicht so wie ich will und es funktioniert auch nicht wie in den Anleitungen beschrieben...
Was mache ich falsch?

Danke für die Hilfe

Re: openhab + influxdb + auth Problem

Verfasst: 24. Mär 2020 10:38
von udo1toni
Bitte versuche influx mit sudo aufzurufen. Es kann gut sein, dass der Ausschnitt aus dem Howto ohnehin unter dem User root läuft.
Und dann aber bitte die Reihenfole einhalten. Zuerst Datenbank anlegen, dann (wenn eine Erfolgsmeldung kam, nicht bei Fehlermeldung...)
User anlegen und abschließend Berechtigung anlegen.

Re: openhab + influxdb + auth Problem

Verfasst: 24. Mär 2020 19:15
von Alex
Hallo udo1toni,

danke vorweg für deinen langen Atem...
Bitte schau, was passiert:

[19:11:16] openhabian@openhab:~$ sudo influx
[sudo] password for openhabian:
Connected to http://localhost:8086 version 1.7.10
InfluxDB shell version: 1.7.10
> CREATE DATABASE openhab_home
ERR: unable to parse authentication credentials
Warning: It is possible this error is due to not setting a database.
Please set a database with the command "use <database>".
> use openhab_home
ERR: unable to parse authentication credentials
DB does not exist!
>

Ich bin ratlos... :(

Re: openhab + influxdb + auth Problem

Verfasst: 24. Mär 2020 19:57
von udo1toni
Was mir etwas Kummer bereitet, sind diese Zeilen:
Alex hat geschrieben: 24. Mär 2020 06:17 OK Configure InfluxDB admin account... {"results":[{"statement_id":0,"error":"user already exists"}]}
OK Configure listen on localhost only...
$ sed -i -e /# Determines whether HTTP endpoint is enabled./ { n ; s/# enabled = true/enabled = true/ } /etc/influxdb/influxdb.conf
$ sed -i s/# bind-address = ":8086"/bind-address = "localhost:8086"/g /etc/influxdb/influxdb.conf
$ sed -i s/# auth-enabled = false/auth-enabled = true/g /etc/influxdb/influxdb.conf
$ sed -i s/# store-enabled = true/store-enabled = false/g /etc/influxdb/influxdb.conf
$ systemctl restart influxdb.service
OK
Setup of inital influxdb database and InfluxDB users... {"error":"authorization failed"}
Er bricht das Script ab, weil der Admin User schon existiert. In der Folge kann er auch keine Datenbank mehr anlegen.

Du könntest mal versuchen, auth-enabled auf false zu setzen (gehe dazu nach /etc/influxdb/influxdb.conf und ändere es dort, anschließend musst Du mittels sudo systemctl restart influxdb.service den Dienst neu starten.) Nun sollte der Zugriff möglich sein, gleich welcher User verwendet wird.

Allerdings ist das auch irgendwie Rumgemurkse.