postgres db error

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
kgopiramesh

postgres db error

Post by kgopiramesh »

Hi ,

We have received this error when trying to backup the nagios xi.

pg_dump: [archiver (db)] connection to database "nagiosxi" failed: FATAL: no pg_hba.conf entry for host "168.125.36.9", user "nagiosxi", database "nagiosxi", SSL off
Error backing up PostgresQL database 'nagiosxi' !


I have tried taking the backup of nagiosxi2.9with the script provided in the path /usr/local/nagiosxi/scripts but that gave the above error and when I tried manually connecting to the postgres database it is success using the command psql -U postgres

I thought of doing it with the 2.3 version's default provided script and it has successfully created the backup tar file, when I ran the back up script of 2.3, it gave the below output.

Backing up Core Config Manager (NagiosQL)...
tar: Removing leading `/' from member names
tar: Removing leading `/' from member names
Backing up Nagios Core...
tar: Removing leading `/' from member names
tar: /usr/local/nagios/var/ndo.sock: socket ignored
tar: /usr/local/nagios/share/perfdata/CSW02-1-NewYork: file changed as we read it
Backing up Nagios XI...
tar: Removing leading `/' from member names
Backing up MRTG...
tar: Removing leading `/' from member names
Backing up MySQL databases...
Backing up PostgresQL databases...
Backing up logrotate config files...
Backing up Apache config files...
Compressing backup...

===============
BACKUP COMPLETE
===============

So does the backup successfully created? and I have observed the difference between these two files

version 2.3 script :

echo "Backing up PostgresQL databases..."
mkdir -p $mydir/pgsql
pg_dump -c -U nagiosxi nagiosxi > $mydir/pgsql/nagiosxi.sql
res=$?
if [ $res != 0 ]; then
echo "Error backing up PostgresQL database 'nagiosxi' !"
exit;
fi



version 2.9 script

echo "Backing up PostgresQL databases..."
mkdir -p $mydir/pgsql
if [ -z $cfg__db_info__nagiosxi__dbserver ]; then
cfg__db_info__nagiosxi__dbserver="localhost"
fi
pg_dump -h $cfg__db_info__nagiosxi__dbserver -c -U $cfg__db_info__nagiosxi__user $cfg__db_info__nagiosxi__db > $mydir/pgsql/nagiosxi.sql
res=$?
if [ $res != 0 ]; then
echo "Error backing up PostgresQL database 'nagiosxi' !"
exit $res;
fi
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: postgres db error

Post by abrist »

Is your db offloaded?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
kgopiramesh

Re: postgres db error

Post by kgopiramesh »

No the db is running on the same server where the nagios application is hosted.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: postgres db error

Post by sreinhardt »

Can you run the backup script again and immidiately after it exits from failed postgres run "echo $?" and return us the value please? Also just to confirm, is 168.125.36.9 your nagios and postgres server? Also does "pgsql -U nagiosxi nagiosxi" work?
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
kgopiramesh

Re: postgres db error

Post by kgopiramesh »

Please find the below for the value returned after running the original backup script included in 2.9

echo $?
1

Yes 168.125.36.9 is the server where our nagios application and db is installed.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: postgres db error

Post by scottwilkerson »

Can you run the following

Code: Select all

cat /usr/local/nagiosxi/html/config.inc.php |grep -3 pgsql|grep dbserver
The value should be empty or localhost...
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
kgopiramesh

Re: postgres db error

Post by kgopiramesh »

cat /usr/local/nagiosxi/html/config.inc.php |grep -3 pgsql|grep dbserver
"dbserver" => 'localhost',
I have tried even changing this to localhost and tried backing up the application, still received the below error

pg_dump: [archiver (db)] connection to database "nagiosxi" failed: FATAL: no pg_hba.conf entry for host "168.125.36.9", user "nagiosxi", database "nagiosxi", SSL off
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: postgres db error

Post by slansing »

What is the output of:

Code: Select all

grep -R 'localhost' /var/lib/pgsql/
Did you do any changing of the hosts file, or the address of your local nagios xi server? The address the system would reference?
kgopiramesh

Re: postgres db error

Post by kgopiramesh »

Binary file /var/lib/pgsql/data/pg_xlog/0000000100000001000000DA matches
Binary file /var/lib/pgsql/data/pg_xlog/0000000100000001000000D9 matches
Binary file /var/lib/pgsql/data/pg_xlog/0000000100000001000000D8 matches
Binary file /var/lib/pgsql/data/pg_xlog/0000000100000001000000D7 matches
/var/lib/pgsql/data/postgresql.conf:#listen_addresses = 'localhost' # what IP address(es) to listen on;
/var/lib/pgsql/data/postgresql.conf: # defaults to 'localhost', '*' = all
Binary file /var/lib/pgsql/data/base/16385/2619 matches
Binary file /var/lib/pgsql/data/base/16385/16435 matches
Binary file /var/lib/pgsql/data/base/16385/16400 matches
Binary file /var/lib/pgsql/data/base/16385/16506 matches
Binary file /var/lib/pgsql/data/base/16385/16497 matches
Binary file /var/lib/pgsql/data/base/16385/16424 matches
/var/lib/pgsql/pgstartup.log:WARNING: could not create listen socket for "localhost"
/var/lib/pgsql/pgstartup.log:WARNING: could not create listen socket for "localhost"
/var/lib/pgsql/pgstartup.log:WARNING: could not create listen socket for "localhost"
/var/lib/pgsql/pgstartup.log:WARNING: could not create listen socket for "localhost"
/var/lib/pgsql/pgstartup.log:WARNING: could not create listen socket for "localhost"
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: postgres db error

Post by sreinhardt »

Looks like this might all be stemming from an issue with postgres attempting to bind locally. Could you post your /etc/hosts file please?
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked