Page 1 of 1

Nagios Unable to connect to Database

Posted: Thu Mar 26, 2020 9:41 am
by karan-k1110
Hey,
I have installed Nagios Network Analyzer on my Centos6.8 machine with Nagios Core running on it. Where as after typing <server_ip>/nagiosna. I get the Error saying -

A Database Error Occurred

Unable to connect to your database server using the provided settings.

Filename: core/Loader.php

Line Number: 346

Also, when I run service nagiosna stop or start - I get the error message -
Error connecting to the database. (2002, "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)")


Can you help me?

Re: Nagios Unable to connect to Database

Posted: Thu Mar 26, 2020 11:24 am
by scottwilkerson
Can you show the output of the following from the CLI

Code: Select all

service mysqld status

Re: Nagios Unable to connect to Database

Posted: Fri Mar 27, 2020 1:45 am
by karan-k1110
Output -

Re: Nagios Unable to connect to Database

Posted: Fri Mar 27, 2020 12:27 pm
by lmiltchev
You could try:

Code: Select all

service mysqld stop
rm -f /var/lib/mysql/mysql.sock
service mysqld start
I just want to mention that you shouldn't be running two of our products on the same server. From our official documentation:
Important: Nagios Enterprises highly recommends and will only support installing Nagios Network Analyzer on a newly installed, "clean" system (a bare minimal install with nothing else installed or configured).
https://assets.nagios.com/downloads/nag ... ctions.pdf

Re: Nagios Unable to connect to Database

Posted: Wed Apr 01, 2020 6:26 am
by karan-k1110
Hey, I have installed Nagios NA on a new server with no other nagios software but still i'am getting the same error as stated above

Re: Nagios Unable to connect to Database

Posted: Wed Apr 01, 2020 9:31 am
by lmiltchev
Did you see a "success" message at the end of your installation?
Nagios Network Analyzer Installation Success!

You can finish the final setup steps for Nagios Network Analyzer by visiting:
http://<server_ip_address>/nagiosna/
Can you run the following commands from the command line, and show the output?

Code: Select all

cat /etc/*release
uname -a
mysql -V 
ps -ef | grep mysql
php -v

Re: Nagios Unable to connect to Database

Posted: Wed Apr 01, 2020 10:20 am
by karan-k1110
Yes I did recieve the 'Success Installation' prompt without any error.

Here are the outputs to your commands, Please find them attached.

Re: Nagios Unable to connect to Database

Posted: Wed Apr 01, 2020 1:11 pm
by lmiltchev
It seems that you are using a custom (newer than the "default") version of mysql... On my CentOS 6 (fully upgraded) system, I see:

Code: Select all

# mysql -V
mysql  Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1

Let's check a few more things:

1. Restart the mysqld service:

Code: Select all

service mysqld restart
and check to see if it's running:

Code: Select all

service mysqld status
2. Upload you /var/log/messages and /var/log/mysqld.log files on the forum.

3. Run the commands below, and show the output:

Code: Select all

iptables -L
echo 'SELECT @@SQL_MODE, @@GLOBAL.SQL_MODE\G;' | mysql
cat /etc/my.cnf
4. Run the following command:

Code: Select all

yum list installed > /tmp/list.txt
then post the list.txt file that was generated in the /tmp directory.

P.S.
I saw that you used "https" in the URL, when trying to access NNA. Did you configure NNA to work with SSL? If you did, is this the document that you followed - https://assets.nagios.com/downloads/nag ... alyzer.pdf?

Re: Nagios Unable to connect to Database

Posted: Thu Apr 02, 2020 12:46 am
by karan-k1110
Please go the google drive link for all the files, thankyou since they are not getting uploaded here

https://drive.google.com/drive/folders/ ... sp=sharing
lmiltchev wrote:It seems that you are using a custom (newer than the "default") version of mysql... On my CentOS 6 (fully upgraded) system, I see:

Code: Select all

# mysql -V
mysql  Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1

Let's check a few more things:

1. Restart the mysqld service:

Code: Select all

service mysqld restart
and check to see if it's running:

Code: Select all

service mysqld status
Yes it's running
2. Upload you /var/log/messages and /var/log/mysqld.log files on the forum.

3. Run the commands below, and show the output:

Code: Select all

iptables -L
echo 'SELECT @@SQL_MODE, @@GLOBAL.SQL_MODE\G;' | mysql
cat /etc/my.cnf
4. Run the following command:

Code: Select all

yum list installed > /tmp/list.txt
then post the list.txt file that was generated in the /tmp directory.
Please find the attachment
P.S.
I saw that you used "https" in the URL, when trying to access NNA. Did you configure NNA to work with SSL? If you did, is this the document that you followed - https://assets.nagios.com/downloads/nag ... alyzer.pdf?
We have configured with our own organisation SSL certificate

Re: Nagios Unable to connect to Database

Posted: Thu Apr 02, 2020 9:51 am
by lmiltchev
The mysqld.log indicates an issue with the mysql connection. The my.cfg file that you are using is heavily customized. We don't support this kind of customization to the mysql db. Here's one (example) from a "vanilla" install:

Code: Select all

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
If you wished to get Nagios Network Analyzer installed, up and running, run the installer on a CLEAN system, with nothing else installed on it, e.g. CentOS 7 MINIMAL install.

Note: You can customize your system if you wish, however this is not something that we would support. I would recommend that you try your customization in a test environment first before applying it in production.