Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when setting up database #146

Closed
jslegers73 opened this issue Oct 25, 2023 · 9 comments
Closed

Error when setting up database #146

jslegers73 opened this issue Oct 25, 2023 · 9 comments

Comments

@jslegers73
Copy link

jslegers73 commented Oct 25, 2023

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:
- TZ=${TZ}
- MYSQL_ROOT_PASSWORD=${MDBRP}
volumes:
- ./mariadb:/var/lib/mysql
- ./mariadb.cnf:/etc/mysql/conf.d/custom.cnf

librenms:
image: jarischaefer/docker-librenms:latest-arm64v8
container_name: LibreNMS
restart: always
hostname: librenms
ports:
- 8668:80
volumes:
- ./librenms/logs:/opt/librenms/logs
- ./librenms/rrd:/opt/librenms/rrd
- ./librenms/custom.config.php:/opt/librenms/conf.d/custom.config.php:ro
environment:
- APP_KEY=base64:J1VABAqbGIZAMZA40ogtOJwTWfI91xr4KB53Vlxbsl4=
- DB_HOST=mariadb
- DB_NAME=librenms
- DB_USER=librenms
- DB_PASS='V#aCitVKB!YzSC3G1x'
- BASE_URL=http://librenms.thuisjsl.local:8668
- DISABLE_IPV6=true
depends_on:
- mariadb
links:
- mariadb:librenms

@jarischaefer
Copy link
Owner

@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
Copy link
Author

@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
Copy link
Author

jslegers73 commented Nov 6, 2023

@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
Copy link
Owner

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
Copy link
Owner

@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
Copy link
Author

jslegers73 commented Dec 8, 2023

@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
Copy link
Author

jslegers73 commented Dec 12, 2023

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
Copy link
Owner

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

@jslegers73
Copy link
Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants