Error when setup database

Hi there!

I’ve been following this great tutorial but unfortunately, it fails in the end when trying to setup the librenms database. Don’t quite know what to do at this stage :frowning:

root@nas:/volume1/docker/librenms# docker exec librenms setup_database

In Connection.php line 664:

SQLSTATE[HY000] [2002] Connection timed out (SQL: select * from information
_schema.tables where table_schema = librenms and table_name = migrations an
d table_type = ‘BASE TABLE’)

In PDOConnection.php line 31:

SQLSTATE[HY000] [2002] Connection timed out

In PDOConnection.php line 27:

SQLSTATE[HY000] [2002] Connection timed out

Hi Fred and welcome to the forums

Thank you for taking your time to post this

Never seen this error before

Could you post me your MariaDB and LibreNMS docker run code? (You can mask out the passwords etc)

I am assuming that the MariaDB database setup and admin privileges has been setup without problems? (The part where we login into the SQL CLI in the MariaDB container)

Still assuming things here, might be an error on linking the containers together. Eg: LibreNMS container unable to communicate with your MariaDB container, thus giving the timeout error

Thanks Jason! Here are the container definition:

Mariadb

docker run -v /volume1/docker/mariadb:/var/lib/mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -e TZ=America/Los_Angeles --name mariadb -d mariadb:latest --sql-mode=’’

I had to use MYSQL_ALLOW_EMPTY_PASSWORD=yes since if I use MYSQL_ROOT_PASSWORD=random_password when trying to connect to the DB with docker exec -it mariadb mysql -u root I get a Access denied for user ‘root’@‘localhost’ (using password: NO)

librenms

docker run
-p 8668:80
-e DB_HOST=db
-e DB_NAME=librenms
-e DB_USER=librenms
-e DB_PASS=random_password
-e APP_KEY=base64:+kJkeYIsgMfab5qSYMg9csNP0OJQIc+mG+j0x48SDlo=
-e BASE_URL=http://192.168.1.100:8668
-e TZ=America/Los_Angeles
–link mariadb:db
-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
–name librenms
-d
–restart always
jarischaefer/docker-librenms:latest

After running the setup_database and the timeout, when I look in the DB, I see that some tables had been created.

Thank you for the docker run commands

Hm…! Ok, so the host name works

Yes this. You are my kinda second user confirming this, including me. Prior versions when I deployed the MariaDB, I had this problem too where I can’t login to the CLI even with the correct root password. So I tried to login the CLI without the “-p” option, which is to ask for your password, meanwhile checking whether root password has been set and it worked for some reason (only in Synology)

I tried to deploy a new MariaDB container on my end, here are the results, which is totally opposite of yours, where without setting -p logs me in

Note in screenshot:
mysql -u root
works rather than
mysql -u root -p

Could you fast deploy from scratch to check on your end whether this is the same behaviour?

## stopping librenms and removing its files
docker stop librenms && docker rm librenms
rm -rvf /volume1/docker/librenms/* 
## same for mariadb, have to delete the local files
docker stop mariadb && docker rm mariadb
rm -rvf /volume1/docker/mariadb/*
## trying that mariadb run command again
docker run \
-v /volume1/docker/mariadb:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD="rooting" \
-e TZ=Asia/Singapore \
--name mariadb \
-d \
--restart always \
mariadb:latest \
--sql-mode=''
## after deploying
docker exec -it mariadb mysql -u root
# fingers crossed this works, if not, try the -p option
# enter "rooting" when asked for password
docker exec -it mariadb mysql -u root -p
# and if this works, you are the total opposite from me

Let me know again, if this behaviour is different on your end, I will need to update the tutorial with two methods of logging in the MySQL CLI :sweat_smile:

omg… it works now!

I left it running , now I could login with the -p option… :scream:

Since I kinda got it to work with your scenario… meanwhile, continuing the rest of my tutorial steps…

will update again whether I run into the timeout issue

Update: it works on my end

so far the only differences is that i am using a root password for MariaDB instead of no_password, and I put in double quotes for the base64 key just in case for any special escape characters

docker run \
-p 8669:80 \
-e DB_HOST=db \
-e DB_NAME=librenms \
-e DB_USER=librenms \
-e DB_PASS=libre_password \
-e APP_KEY="base64:waWCoAjO4q8LnKH7mjVyyOqYTHxgzIFRyjdTOIGZoEw=" \
-e BASE_URL=http://MY.IP:8669 \
-e TZ=Asia/Singapore \
--link mariadb-test:db \
-v /volume1/docker/librenms-test/logs:/opt/librenms/logs \
-v /volume1/docker/librenms-test/rrd:/opt/librenms/rrd \
-v /volume1/docker/librenms-test/custom.config.php:/opt/librenms/conf.d/custom.config.php:ro \
--name librenms-test \
-d \
--restart always \
jarischaefer/docker-librenms:latest
docker exec librenms-test setup_database
docker exec librenms-test create_admin

Mock adding of the Syno host device works as well

As for timeout issues… it seems like you are able to create some initial tables, but it stops in the end, the only factor that I could think of is load performance/issues.

Try stopping some of your existing containers when executing the creation of database in LibreNMS, if you are running other containers

My load in Syno Docker UI:

Let’s start from scratch

  • clear all the current mariadb and librenms persistent local files and folders
  • create new folders etc
  • run the mariaDB container
    + this time round, we restart the mariaDB container after you have created it
  • docker restart mariadb
  • after a restart of mariadb, confirm that mysql -u root -p works with the root password you defined
  • setup the mariadb privileges as written in tutorial
  • you don’t have to generate a new key, just use the same key generated previously
  • try your initial librenms docker run container command again
  • populate database with setup_database (fingers crossed)
  • create admin

Went through all the steps with a clean config, no containers. Same issue. I’m running DSM 6.2.2-24922 Update 4 on a DS218+ if that matters. Interestingly enough, docker exec -it mariadb mysql -u root worked and I was able to create the librenms DB via the CLI. Then I ran into the time out issue during the setup_database script. But then I tried again docker exec -it mariadb mysql -u root and got ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: NO) ??!! This is weird. I can’t even access the CLI with docker exec -it mariadb mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)

I don’t know where that leave me. I don’t have any load on the NAS.

I even tried to delete the docker package, reinstalled it and went through all the steps. Same problem. Very weird. :frowning:

Thank you for the updates

Ok, can confirm this mysql -u root with/without -p problem with you then since it happened to you too… but I don’t understand how come you can’t login at a later stage -_- this is just weird

If you have the time, maybe you could try deploying an older version of librenms? Just to see whether it’s only applicable to this version or all versions of LibreNMS

I would try v1.62 or even v1.6

You would substitute the latest tag with eg:
docker pull jarischaefer/docker-librenms:1.62

Just replace latest with the version number

If this fails, try an older MariaDB container instead of the latest
docker pull mariadb:10.5

I would love to help you but I can’t reproduce your timeout on my end … so I can’t tell which container’s the problem :anguished:

Tried with a bunch of older version. Similar problem … Really weird! Thank you for all your help! I will try to troubleshoot on my end. Probably something specific to my environment. It’s docker so don’t know where it could come from … Thank you again!

Thanks for the update Fred and you are welcome!

I hope things works out on your end

If you are still keen on getting LibreNMS to work, there’s the official Docker LibreNMS container to deploy too, though lots of side containers to load like the rrdcache, memcached etc

And since it’s official, you can reach out to the LibreNMS community for support

The steps are similar, for so many containers, using docker-compose might be a good idea.

Same tip applies: set a fixed image instead of latest for MariaDB

If you do a docker-compose pull (update all images), your database will run the latest version which might introduce problems during upgrades

Good luck!

Hey Jason! I FINALLY found what was the problem with my problem. Seems like the synology firewall was preventing something in the setup_database scripts. I added a new entry to firewall rules: All, All, 172.18.0.0/255.255.0.0 and the script is able to run.

Phew. :smiley:

Fred

1 Like

Omg! Firewall! :crazy_face::joy:

Thank you for the update! :tada:

This should help other users if they encounter similar problems

1 Like