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

docker installation failing to create database #128

Closed
uktricky opened this issue Jan 17, 2021 · 9 comments
Closed

docker installation failing to create database #128

uktricky opened this issue Jan 17, 2021 · 9 comments

Comments

@uktricky
Copy link

Using
docker run \

-d
--net RT-Network
--ip
-h
-e APP_KEY=base64:/
-e BASE_URL=http://
-e DB_HOST=
-e DB_PORT=3306
-e DB_NAME=librenms
-e DB_USER=librenms
-e DB_PASS=
-e TZ=Europe/London
-p 80:80
-v /volume1/docker/librenms/logs:/opt/librenms/logs
-v /volume1/docker/librenms/rrd:/opt/librenms/rrd
-v /volume1/docker/librenms/custom.config.php:/opt/librenms/conf.d/custom.config.php:ro
-v /volume1/docker/librenms/weathermap/configs:/opt/librenms/html/plugins/Weathermap/configs
-v /volume1/docker/librenms/weathermap/output:/opt/librenms/html/plugins/Weathermap/output
--name librenms
--restart unless-stopped
jarischaefer/docker-librenms:latest

when I run the "docker exec librenms setup_database"
I get:
In Process.php line 1201:

The process "mysql --host="${:LARAVEL_LOAD_HOST}" --port="${:LARAVEL_LOAD_P
ORT}" --user="${:LARAVEL_LOAD_USER}" --password="${:LARAVEL_LOAD_PASSWORD}"
--database="${:LARAVEL_LOAD_DATABASE}" < "${:LARAVEL_LOAD_PATH}"" exceeded
the timeout of 60 seconds.

running mariadb in a different docker session on same network
zabbix also in same docker without issues against the database

I previously had librenms running for months but messed up a distributed poller setup
so dropped the database (librenms) and the associated user etc.
removed the docker and even the image
recreated the database/user and permissions
then ran the above installation

But getting the database error?!

@uktricky
Copy link
Author

MariaDB
Server version: 10.4.12-MariaDB-1:10.4.12+maria~bionic mariadb.org binary distribution

@uktricky
Copy link
Author

For reference everything installed fine on release :1.69

@jarischaefer
Copy link
Owner

Try connecting from the LibreNMS container to the database container using the command line.

  1. Start both containers (LibreNMS & DB)
  2. Run docker exec -it librenms bash
  3. You should be inside the container at this point
  4. Run echo $DB_HOST, echo $DB_USER and echo $DB_PASS. Make sure the values are correct
  5. Proceed with mysql --host=$DB_HOST -u $DB_USER -p and enter the password

This should help determine whether there is a communication problem between the containers or a misconfiguration.

@uktricky
Copy link
Author

So created a new Standalone DB and Standalone LibreNMS as per below...
Still Database create error
No connection errors / issues ... v1.69 works perfectly

** Volumes for persistent data
mkdir /volume1/docker/xxmariadb
mkdir /volume1/docker/xxlibrenms
mkdir /volume1/docker/xxlibrenms/logs
mkdir /volume1/docker/xxlibrenms/rrd
mkdir /volume1/docker/xxlibrenms/weathermap
mkdir /volume1/docker/xxlibrenms/weathermap/configs
mkdir /volume1/docker/xxlibrenms/weathermap/output
touch /volume1/docker/xxlibrenms/custom.config.php

** Docker MariaDB Installation
docker run
-d
--net RT-Network
--ip 10.1.3.16
-h WLC-MARIADB2
-e TZ=Europe/London
-e MYSQL_ROOT_PASSWORD=password2020
-p 3306:3306
-v /volume1/docker/xxmariadb:/var/lib/mysql
--name xxmariadb
--restart unless-stopped
mariadb:latest --sql-mode=''

docker exec -it xxmariadb mysql -u root -p

** Database for LibreNMS
CREATE DATABASE xxlibrenms CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER 'xxlibrenms'@'%' IDENTIFIED BY 'xxxxNet20';
CREATE USER 'xxlibrenms'@'localhost' IDENTIFIED BY 'xxxxNet20';
GRANT ALL PRIVILEGES ON xxlibrenms.* TO 'xxlibrenms'@'%';
FLUSH PRIVILEGES;

root@WLC-SN02:~# docker exec -it xxmariadb mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.4.12-MariaDB-1:10.4.12+maria~bionic mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE DATABASE xxlibrenms CHARACTER SET utf8 COLLATE utf8_unicode_ci;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> CREATE USER 'xxlibrenms'@'%' IDENTIFIED BY 'xxxxNet20';
Query OK, 0 rows affected (0.121 sec)

MariaDB [(none)]> CREATE USER 'xxlibrenms'@'localhost' IDENTIFIED BY 'xxxxNet20';
Query OK, 0 rows affected (0.219 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON xxlibrenms.* TO 'xxlibrenms'@'%';
Query OK, 0 rows affected (0.160 sec)

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> exit
Bye
root@WLC-SN02:~# docker restart xxmariadb
xxmariadb

docker restart xxmariadb

** LibreNMS
docker run --rm jarischaefer/docker-librenms generate_key

root@WLC-SN02:~# docker run --rm jarischaefer/docker-librenms generate_key
Unable to find image 'jarischaefer/docker-librenms:latest' locally
latest: Pulling from jarischaefer/docker-librenms
f22ccc0b8772: Pull complete
3cf8fb62ba5f: Pull complete
e80c964ece6a: Pull complete
16a01d5930d3: Pull complete
495554597b3e: Pull complete
c47d363a0054: Pull complete
c0fad1538dc4: Pull complete
f109c4c8ba62: Pull complete
ce980bbd2814: Pull complete
f75c43f2761f: Pull complete
Digest: sha256:c2f4ceb35b6f3b51591e5fc2f7a66a67f1df415af17d4b91b73a0ffc07d031cf
Status: Downloaded newer image for jarischaefer/docker-librenms:latest
base64:zl/bEXXJ/ZRSClWGeNOYw/SFIGcsNgyM7zAdZLXghcM=

KEY : base64:zl/bEXXJ/ZRSClWGeNOYw/SFIGcsNgyM7zAdZLXghcM=

docker run
-d
--net RT-Network
--ip 10.1.3.14
-h WLC-LibreNMS2
-e APP_KEY=base64:zl/bEXXJ/ZRSClWGeNOYw/SFIGcsNgyM7zAdZLXghcM=
-e BASE_URL=http://10.1.3.14
-e DB_HOST=10.1.3.16
-e DB_PORT=3306
-e DB_NAME=xxlibrenms
-e DB_USER=xxlibrenms
-e DB_PASS=xxxxNet20
-e TZ=Europe/London
-p 80:80
-v /volume1/docker/xxlibrenms/logs:/opt/librenms/logs
-v /volume1/docker/xxlibrenms/rrd:/opt/librenms/rrd
-v /volume1/docker/xxlibrenms/custom.config.php:/opt/librenms/conf.d/custom.config.php:ro
-v /volume1/docker/xxlibrenms/weathermap/configs:/opt/librenms/html/plugins/Weathermap/configs
-v /volume1/docker/xxlibrenms/weathermap/output:/opt/librenms/html/plugins/Weathermap/output
--name xxlibrenms
--restart unless-stopped
jarischaefer/docker-librenms:latest

root@WLC-SN02:~# docker exec -it xxlibrenms bash

root@WLC-LibreNMS2:/# echo $DB_HOST, echo $DB_USER and echo $DB_PASS
10.1.3.16, echo xxlibrenms and echo xxxxNet20
root@WLC-LibreNMS2:/#

root@WLC-LibreNMS2:/# mysql --host=$DB_HOST -u $DB_USER -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.5.5-10.4.12-MariaDB-1:10.4.12+maria~bionic mariadb.org binary distribution

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| test               |
| xxlibrenms         |
+--------------------+
3 rows in set (0.00 sec)

mysql>

docker exec xxlibrenms setup_database

root@WLC-SN02:~# docker exec xxlibrenms setup_database

In Process.php line 1201:

  The process "mysql --host="${:LARAVEL_LOAD_HOST}" --port="${:LARAVEL_LOAD_P
  ORT}" --user="${:LARAVEL_LOAD_USER}" --password="${:LARAVEL_LOAD_PASSWORD}"
   --database="${:LARAVEL_LOAD_DATABASE}" < "${:LARAVEL_LOAD_PATH}"" exceeded
   the timeout of 60 seconds.


root@WLC-SN02:~#

root@WLC-SN02:~# docker exec -it xxlibrenms bash
root@WLC-LibreNMS2:/# mysql --host=$DB_HOST -u $DB_USER -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 38
Server version: 5.5.5-10.4.12-MariaDB-1:10.4.12+maria~bionic mariadb.org binary distribution

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use xxlibrenms;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+------------------------+
| Tables_in_xxlibrenms   |
+------------------------+
| access_points          |
| alert_device_map       |
| alert_group_map        |
| alert_location_map     |
| alert_log              |
| alert_rules            |
| alert_schedulables     |
| alert_schedule         |
| alert_template_map     |
| alert_templates        |
| alert_transport_groups |
| alert_transport_map    |
| alert_transports       |
| alerts                 |
| api_tokens             |
| application_metrics    |
| applications           |
| authlog                |
| availability           |
| bgpPeers               |
| bgpPeers_cbgp          |
| bill_data              |
| bill_history           |
| bill_perms             |
| bill_port_counters     |
| bill_ports             |
| bills                  |
| cache                  |
| cache_locks            |
| callback               |
| cef_switching          |
| ciscoASA               |
| component              |
| component_prefs        |
| component_statuslog    |
| config                 |
| customers              |
| customoids             |
| dashboards             |
| dbSchema               |
| device_graphs          |
| device_group_device    |
| device_groups          |
| device_outages         |
| device_perf            |
| device_relationships   |
| devices                |
| devices_attribs        |
| devices_group_perms    |
| devices_perms          |
| entPhysical            |
| entPhysical_state      |
| entityState            |
| eventlog               |
+------------------------+
54 rows in set (0.00 sec)

mysql>

@samuellazea
Copy link

Hi, I have the same issue using mysql database.

`root@29b06f567386:/opt/librenms# mysql --host=$DB_HOST -u $DB_USER -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 34
Server version: 8.0.23 MySQL Community Server - GPL

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> ^DBye
root@29b06f567386:/opt/librenms#
`
This shows that there is no issue to connect to the database. One thing I noticed when creating and deleting the librenms database is that it is working just fine manually but the time it takes to do it is far more then 60 secs.

My question now, can you please make the timeout as a variable that we can give with the enviroment variables? This parameter is available in official librenms it seems.

Many thanks for all your work

@samuellazea
Copy link

I did some more testing and I did a manual delete of the librenms database directly on the mysql container and even the delete took 1 minute and 24 secs. This is over the 60 seconds timeout coming from librenms.
Here is some more info

`root@mysql:/# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 224
Server version: 8.0.23 MySQL Community Server - GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| librenms |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.50 sec)

mysql> drop database librenms;
Query OK, 135 rows affected (1 min 24.73 sec)
`

@jarischaefer
Copy link
Owner

I just grepped through some source files and have not conducted an in-depth analysis yet. Unfortunately, I do not see an easy way to fix this without sacrificing Laravel's database migrations. As far as I can tell, Laravel's classes (e.g. Illuminate\Database\Schema\MySqlSchemaState) do not pass a timeout argument and the default in Symfony's Process.php is 60 seconds.

Perhaps I can help fix this upstream (in Laravel), but it will probably take time to 1) fix in Laravel 2) wait until LibreNMS uses that Laravel version 3) create a new image.

@uktricky
Copy link
Author

OK thanks will stick at 1.69 for now

@jarischaefer
Copy link
Owner

@uktricky This should be fixed, see laravel/framework#36126

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

3 participants