jarischaefer / docker-librenms

Docker image for LibreNMS
MIT License
115 stars 38 forks source link

Error when setting up database #146

Closed jslegers73 closed 8 months ago

jslegers73 commented 12 months ago

Hi,

When I want to setup the database with command docker exec LibreNMS setup_database. I get the following error.

docker exec LibreNMS setup_database Could not open input file: /opt/librenms/includes/sql-schema/update.php

When I check in the container the directory isn't there also :

root@librenms:/usr/local/bin# ./setup_database Could not open input file: /opt/librenms/includes/sql-schema/update.php

root@librenms:/usr/local/bin# cd /opt/librenms/includes/

root@librenms:/opt/librenms/includes# ls caches discovery init.php services.inc.php systemd-shared.inc.php common.php functions.php polling snmp.inc.php datastore.inc.php helpers.php port-descr-parser.inc.php snmptrap.inc.php dbFacile.php html rewrites.php static-config.php definitions include-dir.inc.php services syslog.php

root@librenms:/opt/librenms/includes#

Is this a know issue or am I doing something wrong?

This is my docker-compose file :

mariadb: image: mariadb container_name: MariaDB restart: always hostname: mariadb environment:

jarischaefer commented 11 months ago

@jslegers73 Thank you for the report. A new version (23.10) containing a fix will be released shortly. In the meantime, you may call the proper command directly: docker exec LibreNMS /sbin/setuser librenms /opt/librenms/lnms migrate --no-interaction --force --isolated --seed

jslegers73 commented 11 months ago

@jslegers73 Thank you for the report. A new version (23.10) containing a fix will be released shortly. In the meantime, you may call the proper command directly: docker exec LibreNMS /sbin/setuser librenms /opt/librenms/lnms migrate --no-interaction --force --isolated --seed

@jarischaefer I will try the new version tonight.

jslegers73 commented 11 months ago

@jarischaefer I get another error now. I have deleted the data directory form MariaDB.

pi@rpi-test:~/docker-data $ docker exec LibreNMS setup_database

In Connection.php line 795:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'librenms.cache_l ocks' doesn't exist (Connection: mysql, SQL: update cache_locks set owne r = DBPXPM6OufjArW5m, expiration = 1699289604 where key = laravel_cach e_framework/command-migrate and (owner = DBPXPM6OufjArW5m or expiration <= 1699286004))

In Connection.php line 601:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'librenms.cache_l ocks' doesn't exist

pi@rpi-test:~/docker-data $

Tried it also on a fresh installation same issue unfortunately.

jarischaefer commented 11 months ago

Tried it also on a fresh installation same issue unfortunately.

I believe that some state is still present, otherwise database migrations would have created fresh tables prior to using the cache. Did you really fully remove both the container and its directories (docker rm)?

I will create a new helper script for setting up a fresh database in such scenarios. In the meantime, use the following command: /sbin/setuser librenms /opt/librenms/artisan migrate:fresh

jarischaefer commented 10 months ago

@jslegers73 Try docker pull jarischaefer/docker-librenms. The latest build should contain the new setup_fresh_database script. This new script drops and re-creates all tables.

jslegers73 commented 10 months ago

@jarischaefer Hi sorry for my late reply. Sorry to say but I have tried it again but again same error on fresh installed 64 Bit RPI 4

pi@rpi-test:~/docker-data $ docker exec LibreNMS setup_database

In Connection.php line 795:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'librenms.cache_l ocks' doesn't exist (Connection: mysql, SQL: update cache_locks set owne r = O5UJPdrChD42eTFp, expiration = 1702035163 where key = laravel_cach e_framework/command-migrate and (owner = O5UJPdrChD42eTFp or expiration <= 1702031563))

In Connection.php line 601:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'librenms.cache_l ocks' doesn't exist

pi@rpi-test:~/docker-data $

I use the mariadb docker container. docker pull mariadb

This is how I have setup the database: CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci; CREATE USER 'librenms'@'%' IDENTIFIED BY 'Password'; CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'Password'; GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'%'; FLUSH PRIVILEGES; exit

This should work with the original MariaDB right?

When I try your work around looks like it is working:

image

And when I want to create an Admin I get the following error: pi@rpi-test:~/docker-data $ docker exec LibreNMS create_admin The selected role.0 is invalid.

Sorry for this. I hope you can fix it.

jslegers73 commented 10 months ago

I did some testing. Found out that image version 23.8.2 works ok. I have to create the database with option : /sbin/setuser librenms /opt/librenms/artisan migrate:fresh. If I use the docker exec LibreNMS setup_database command I get the following error.

pi@rpi-test:~/docker-data $ docker exec LibreNMS setup_database
Could not open input file: /opt/librenms/includes/sql-schema/update.php
pi@rpi-test:~/docker-data $

But I can create the admin account and login. So that works.

23.9 and 23.10 I can't get to work. Also not on an AMD64 machine. Hopefully this will help you.

jarischaefer commented 9 months ago

@jslegers73 Sorry for the delay, please try version 24.1.0, or use -e DAILY_ON_STARTUP=true for the initial setup.

jslegers73 commented 9 months ago

@jslegers73 Sorry for the delay, please try version 24.1.0, or use -e DAILY_ON_STARTUP=true for the initial setup.

Hi was on holiday. I have tested it and it works thank you.