Nagios Unable to connect to Database

This support forum board is for support questions relating to Nagios Network Analyzer, our network traffic and bandwidth analysis solution.
Locked
karan-k1110
Posts: 5
Joined: Thu Mar 26, 2020 7:48 am

Nagios Unable to connect to Database

Post 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?
You do not have the required permissions to view the files attached to this post.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Nagios Unable to connect to Database

Post by scottwilkerson »

Can you show the output of the following from the CLI

Code: Select all

service mysqld status
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
karan-k1110
Posts: 5
Joined: Thu Mar 26, 2020 7:48 am

Re: Nagios Unable to connect to Database

Post by karan-k1110 »

Output -
You do not have the required permissions to view the files attached to this post.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Nagios Unable to connect to Database

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
karan-k1110
Posts: 5
Joined: Thu Mar 26, 2020 7:48 am

Re: Nagios Unable to connect to Database

Post 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
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Nagios Unable to connect to Database

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
karan-k1110
Posts: 5
Joined: Thu Mar 26, 2020 7:48 am

Re: Nagios Unable to connect to Database

Post 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.
You do not have the required permissions to view the files attached to this post.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Nagios Unable to connect to Database

Post 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?
Be sure to check out our Knowledgebase for helpful articles and solutions!
karan-k1110
Posts: 5
Joined: Thu Mar 26, 2020 7:48 am

Re: Nagios Unable to connect to Database

Post 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
You do not have the required permissions to view the files attached to this post.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Nagios Unable to connect to Database

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked