Influxdb fails after openhabian reboot

Over the past weeks I had several issues with influxdb and openHAB wasn’t able to access influx anymore. Finally I at least found out how to fix it which

sudo chown -R 1000:1000 /var/lib/influxdb
sudo chown -R influxdb:influxdb /var/lib/influxdb
sudo systemctl daemon-reload
sudo systemctl restart influxdb.service

Now, I found out what causes the problem: it is a server restart of my raspbi4 which runs openHAB 3.4.1

Does anyone have an idea why the server restart creates the problem which I can fix by the above statements? (for the record, an openHAB restart does not result into the problem)

If you execute these two lines after an other

the first one is obsolete/unnecessary.

Is ZRAM turned on ? I had a similar problem when I was installing mosquitto some time ago.
For whatever reason ( at least in my case ) the underlying entries on filesystem did not get the changes done in ZRAM file layer.
I would suggest to have a look into folders, files in /opt/zram/*.bind/ and check the ownerships and permissions in those directories if they match with what they need to be.

true :man_facepalming:

Yes, it is.

this is what it looks like

/opt/zram/influxdb.bind $ ls -l
drwxr-xr-x 3 influxdb influxdb 4096 Jan  7 12:00 data
drwxr-xr-x 2 influxdb influxdb 4096 Jan 30 00:34 meta
drwx------ 3 influxdb influxdb 4096 Jan  7 12:00 wal

That does look good at least now.

If say /var/lib/influxdb is on ZRAM on your box, when ZRAM starts after a reboot, it’ll take the ‘real’ files+dirs+permission from /var/lib/influxdb which is on SD at that time and ‘replaces’ the directory with itself. The original SD directory will from then on be available as /opt/zram/something.bind. I suggest you change the permissions in there, too.
The problem usually is when you install something with ZRAM on then boot without letting ZRAM sync back to SD. It does on stopping the zram service which is part of any proper shutdown but will not work when there’s a power outage.
And if your problem relates to right the “root” dir of a ZRAM mount this is certainly a special edge case and changes aren’t synced even on proper shutdown. I would not know how to handle this.

Thx Markus, for the explanation.

These are the permissions of /var/lib/influxdb:

drwxr-xr-x 1 influxdb influxdb 4096 Jan  7 12:00 data
-rw-r--r-- 1 influxdb influxdb    5 Feb  5 10:36 influxd.pid
drwxr-xr-x 1 influxdb influxdb 4096 Jan 30 00:34 meta
drwx------ 1 influxdb influxdb 4096 Jan  7 12:00 wal

to me they look identical.

I don’t understand what you mean here, though.

Any further idea that I could investigate?

I will do a reboot tomorrow and see what the permissions are after the reboot and then post that here (I don’t dare to do that now).

The dir itself /var/lib/influxdb if that is the zram mountpoint on your box.

I have been having the same problem with the owner and group of /var/lib/influxdb being reset to root on reboot.

I believe on installation, the ownership of the directory is set correctly to influxdb:influxdb. Running option 14 - Fix Permissions in openhabian-config actually changes the ownership to root:root. Looking at the code in /opt/openhabian/functions/system.bash confirms that it makes this change to /opt/zram/influxdb.bind. So it looks to me that this is a problem with openhabian-config.

1 Like

Same problem here:

openhabian@openhabian:/opt/zram $ ls -dl in*
drwxrwxr-x 5 root root 4096 Mar 16 15:56 influxdb.bind

I had to change the owner and group to influxdb to get influxdb up and running again after a reboot:

openhabian@openhabian:/var/lib $ ls -dl in*
drwxrwxr-x 1 influxdb influxdb 4096 Jun  7 10:44 influxdb

IIUC, changing owner/group of /opt/zram/influxdb.bind to influxdb should cause the fix to survive a reboot.

###############################################################################
###############  openhabian  ##################################################
###############################################################################
##        Ip = 192.168.1.181
##   Release = Raspbian GNU/Linux 11 (bullseye)
##    Kernel = Linux 6.1.21-v8+
##  Platform = none
##    Uptime = 9 day(s). 22:10:46
## CPU Usage = 5.24% avg over 4 cpu(s) (4 core(s) x 1 socket(s))
##  CPU Load = 1m: 0.21, 5m: 0.20, 15m: 0.19
##    Memory = Free: 0.61GB (16%), Used: 3.13GB (84%), Total: 3.75GB
##      Swap = Free: 2.99GB (100%), Used: 0.00GB (0%), Total: 2.99GB
##      Root = Free: 16.73GB (61%), Used: 10.30GB (39%), Total: 28.22GB
##   Updates = 47 apt updates available.
##  Sessions = 1 session(s)
## Processes = 152 running processes of 32768 maximum processes
###############################################################################

                          _   _     _     ____   _
  ___   ___   ___   ___  | | | |   / \   | __ ) (_)  ____   ___
 / _ \ / _ \ / _ \ / _ \ | |_| |  / _ \  |  _ \ | | / _  \ / _ \
| (_) | (_) |  __/| | | ||  _  | / ___ \ | |_) )| || (_) || | | |
 \___/|  __/ \___/|_| |_||_| |_|/_/   \_\|____/ |_| \__|_||_| | |
      |_|                  openHAB 3.4.3 - Release Build

I have opened an issue for it on Github: https://github.com/openhab/openhabian/issues/1781#issue-1751343306