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
[root@libre 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
[root@libre 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’);