Fresh install on CentOS 7, validate.php failures

Hi Everyone, I’m new to LibreNMS and i’m very excited to try it but i’m having trouble getting my MySql DB up and running. I tried to give as much detail as possible. I’m sorry if my post is very long winded.

I went through the manual install guide to setup a Linux, Apache, MySQL PHP server.
https://docs.librenms.org/Installation/Installation-CentOS-7-Apache/

i started mariadb and connected with the mysql command.

Database setup and creation

CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER ‘librenms’@‘localhost’ IDENTIFIED BY ‘password’;
GRANT ALL PRIVILEGES ON librenms.* TO ‘librenms’@‘localhost’;
FLUSH PRIVILEGES;
exit

In /etc/my.cnf i also added:

innodb_file_per_table=1
lower_case_table_names=0

Validate.php output

However when I try to do a validate.php on my install my database connection does not exist:

Component Version
LibreNMS
DB Schema ?
PHP 7.2.13
MySQL ?
RRDTool
SNMP NET-SNMP 5.7.2

====================================

[OK] Installed from package; no Composer required
[FAIL] Error connecting to your database.
[WARN] Could not check poller/discovery, db is not connected.
[FAIL] fping location is incorrect or bin not installed.
[FIX]:
Install fping or manually set the path to fping by placing the following in config.php: $config[‘fping’] = ‘/path/to/fping’;
[FAIL] fping6 location is incorrect or bin not installed.
[FIX]:
Install fping6 or manually set the path to fping6 by placing the following in config.php: $config[‘fping6’] = ‘/path/to/fping6’;
[FAIL] rrdtool location is incorrect or bin not installed.
[FIX]:
Install rrdtool or manually set the path to rrdtool by placing the following in config.php: $config[‘rrdtool’] = ‘/path/to/rrdtool’;
[WARN] Non-git install, updates are manual or from package

I see that there are issues with Fping and rddtool. But before I get to those next issues i figure i should investigate why the database connection is failing.

When I check to see if mysql/mariadb are running it shows that there is a process for mysqld and some log files for mariadb:

ps -ax output

[[email protected] librenms]# ps ax | grep mysql
6297 ? Ss 0:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
6483 ? Sl 0:01 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock
8012 pts/2 S+ 0:00 grep --color=auto mysql

[[email protected] librenms]# ps ax | grep mariadb
6483 ? Sl 0:01 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock
8014 pts/2 R+ 0:00 grep --color=auto mariadb

I also thought it might be a database password issue? So i edited my config.php file and made sure these database values were correct:

/opt/librenms/config.php

$config[‘db_host’] = ‘localhost’;
$config[‘db_user’] = ‘USERNAME’;
$config[‘db_pass’] = ‘MY_PASSWORD_GOES_HERE’;
$config[‘db_name’] = ‘librenms’;
$config[‘user’] = ‘librenms’;

Is there some logs i can check to see whats wrong?
i checked /var/log/messages after restarting with “systemctl restart mariadb”
and it looks like its normal events in messages log?

Dec 13 15:30:47 libre systemd: Starting MariaDB database server…
Dec 13 15:30:47 libre mariadb-prepare-db-dir: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done.
Dec 13 15:30:47 libre mariadb-prepare-db-dir: If this is not the case, make sure the /var/lib/mysql is empty before running mariadb-prepare-db-dir.
Dec 13 15:30:47 libre mysqld_safe: 181213 15:30:47 mysqld_safe Logging to ‘/var/log/mariadb/mariadb.log’.
Dec 13 15:30:47 libre mysqld_safe: 181213 15:30:47 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

/var/log/mariadb/mariadb.log after service restart

181213 16:50:19 [Note] /usr/libexec/mysqld: Normal shutdown
181213 16:50:19 [Note] Event Scheduler: Purging the queue. 0 events
181213 16:50:19 InnoDB: Starting shutdown…
181213 16:50:23 InnoDB: Shutdown completed; log sequence number 1597945
181213 16:50:23 [Note] /usr/libexec/mysqld: Shutdown complete
181213 16:50:23 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
181213 16:50:23 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
181213 16:50:23 [Note] /usr/libexec/mysqld (mysqld 5.5.56-MariaDB) starting as process 8684 …
181213 16:50:23 InnoDB: The InnoDB memory heap is disabled
181213 16:50:23 InnoDB: Mutexes and rw_locks use GCC atomic builtins
181213 16:50:23 InnoDB: Compressed tables use zlib 1.2.7
181213 16:50:23 InnoDB: Using Linux native AIO
181213 16:50:23 InnoDB: Initializing buffer pool, size = 128.0M
181213 16:50:23 InnoDB: Completed initialization of buffer pool
181213 16:50:23 InnoDB: highest supported file format is Barracuda.
181213 16:50:23 InnoDB: Waiting for the background threads to start
181213 16:50:24 Percona XtraDB (http://www.percona.com) 5.5.52-MariaDB-38.3 started; log sequence number 1597945
181213 16:50:24 [Note] Plugin ‘FEEDBACK’ is disabled.
181213 16:50:24 [Note] Server socket created on IP: ‘0.0.0.0’.
181213 16:50:24 [Note] Event Scheduler: Loaded 0 events
181213 16:50:24 [Note] /usr/libexec/mysqld: ready for connections.
Version: ‘5.5.56-MariaDB’ socket: ‘/var/lib/mysql/mysql.sock’ port: 3306 MariaDB Server

Where else can I check to see why my LibreNMS is unable to connect to local mySQL?
When i look at the validate.php file i can see where it chcked if isConnected() is true or false

\LibreNMS\DB\Eloquent::boot();
if (\LibreNMS\DB\Eloquent::isConnected()) {
$validator->ok(‘Database connection successful’, null, ‘database’);
} else {
$validator->fail(‘Error connecting to your database.’, null, ‘database’);

It might be possible that you haven’t set a port in the config.php file for your mysql server.

Try adding
$config['db_port'] = '3306';

As for your rrdtool run:
rpm -qa
to see what version you are running and then
which rrdtool
to see were it’s saved

You might need to moved it from /usr/sbin to /usr/bin/

Hopes this helps I’m fairly new too but just got mine up and running. Keep asking if you still need help.

OH thank you so much for the tip :slight_smile:
I have been working on this all afternoon and i left my work for the day. I’m driving home. BUT i will try your suggestion as soon as i get home and will update this thread if it worked.

Hello!

Have you updated the /opt/librenms/.env file with DB connection details?

I would 100% say you haven’t gone through the install docs line by line. Repeat the process - maybe even remove /opt/librenms and start again

I have already updated this file yes:

APP_KEY=base64:P8isLYMDn+ZOuFkEnl5JBSnxbKN0vIhoK5qyUO8aPls=

DB_HOST=localhost
DB_DATABASE=librenms
DB_USERNAME=librenms
DB_PASSWORD=My_password_Goes_Here

#APP_URL=
NODE_ID=5c12944f36950
LIBRENMS_USER=librenms

Hi laf

I’ve taken your suggestion to heart and deleted the /opt/librenms folder and started again.

This time i went through all the steps with a fine tooth comb. I found that there were some packages that yum did not install correctly. There were some dependency failures. I tried my best to resolve them one by one. A lot of the errors that were in the validate php are now gone. So i am hopeful I am closer to getting this to work.

However I am still unable to get validate.php to talk mysql:

./validate.php

====================================

Component Version
LibreNMS 1.46-54-g95d3726
**DB Schema ?**
PHP 7.2.13
**MySQL ?**
RRDTool 1.4.8
SNMP NET-SNMP 5.7.2

====================================

[OK] Composer Version: 1.8.0
[OK] Dependencies up-to-date.
[FAIL] Error connecting to your database.
[WARN] Could not check poller/discovery, db is not connected.
[WARN] Your install is over 24 hours out of date, last update: Wed, 12 Dec 2018 14:43:00 +0000
[FIX]:
Make sure your daily.sh cron is running and run ./daily.sh by hand to see if there are any errors.
[WARN] Your local git contains modified files, this could prevent automatic updates.
[FIX]:
You can fix this with ./scripts/github-remove
Modified Files:
bootstrap/cache/.gitignore
logs/.gitignore
rrd/.gitignore
storage/app/.gitignore
storage/app/public/.gitignore
storage/debugbar/.gitignore
storage/framework/cache/.gitignore
storage/framework/sessions/.gitignore
storage/framework/testing/.gitignore
storage/framework/views/.gitignore
storage/logs/.gitignore

TROUBLESHOOTING:
I tried to check that the user exists in mysql:

[[email protected] opt]# mysql -u root
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 58
Server version: 5.5.60-MariaDB MariaDB Server
Copyright © 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

MariaDB [(none)]> SELECT User, Host, Password FROM mysql.user;
±---------±----------------------±------------------------------------------+
| User | Host | Password |
±---------±----------------------±------------------------------------------+
| root | localhost | |
| root | localhost.localdomain | |
| root | 127.0.0.1 | |
| root | ::1 | |
| | localhost | |
| | localhost.localdomain | |
librenms | localhost | BDB988D9D6DC6E86A60C88F9A14005BD61AD5166 |
±---------±----------------------±------------------------------------------+
7 rows in set (0.00 sec)

And just in case, I tried to run through creating the DB and the user again just to make sure:

MariaDB [(none)]> CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ERROR 1007 (HY000): Can’t create database ‘librenms’; database exists
MariaDB [(none)]> CREATE USER ‘librenms’@‘localhost’ IDENTIFIED BY ‘password’;
ERROR 1396 (HY000): Operation CREATE USER failed for ‘librenms’@'localhost’
MariaDB [(none)]> GRANT ALL PRIVILEGES ON librenms.* TO ‘librenms’@‘localhost’;
Query OK, 0 rows affected (0.00 sec)

/var/log/mariadb/mariadb.log
181214 10:21:12 [Note] Plugin ‘FEEDBACK’ is disabled.
181214 10:21:12 [Note] Server socket created on IP: ‘0.0.0.0’.
181214 10:21:12 [Note] Event Scheduler: Loaded 0 events
181214 10:21:12 [Note] /usr/libexec/mysqld: ready for connections.
Version: ‘5.5.60-MariaDB’ socket: ‘/var/lib/mysql/mysql.sock’ port: 3306 MariaDB Server

[[email protected] librenms]# mysql -u librenms -p -h localhost
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 134
Server version: 5.5.60-MariaDB MariaDB Server

When i try to connect but with the FQDN it says that the its not allowed
[[email protected] librenms]# mysql -u librenms -p -h libre.mycompany.local
Enter password:
ERROR 1130 (HY000): Host ‘libre.mycompany.local’ is not allowed to connect to this MariaDB server

/opt/librenms/.env
APP_KEY=base64:ssvqf3/OzV7ti0s7rPM85jXIGObiL9HzNxCSx07UNfg=

#DB_HOST=localhost
#DB_DATABASE=librenms
#DB_USERNAME=librenms
#DB_PASSWORD=PASSWORD_HERE
#APP_URL=
NODE_ID=5c13c89aa3bd9

/opt/librenms/config.php

Database config
$config[‘db_host’] = ‘localhost’;
$config[‘db_user’] = ‘librenms’;
$config[‘db_pass’] = ‘PASSWORD_HERE’;
$config[‘db_name’] = ‘librenms’;
$config[‘db_port’] = ‘3306’;

You will see a ‘?’ in the Version column for MySQL until you have gone through http://librenms.example.com/install

After you go through the install and configure your database user, etc, and the site is working, then the correct value will be shown in the Version column:

  [email protected]:~$ ./validate.php
  ====================================
  Component | Version
  --------- | -------
  LibreNMS  | 21.5.1-22-g4ee1abb1d
  DB Schema | 2021_04_08_151101_add_foreign_keys_to_port_group_port_table (208)
  PHP       | 7.3.27-1~deb10u1
  Python    | 3.7.3
  MySQL     | 10.3.27-MariaDB-0+deb10u1
  RRDTool   | 1.7.1
  SNMP      | NET-SNMP 5.7.3
  ====================================
  
  [OK]    Composer Version: 2.1.2
  [OK]    Dependencies up-to-date.
  [OK]    Database connection successful
  [OK]    Database schema correct