Page 1 of 2

postgres db error

Posted: Thu Apr 24, 2014 5:39 am
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

Re: postgres db error

Posted: Thu Apr 24, 2014 10:30 am
by abrist
Is your db offloaded?

Re: postgres db error

Posted: Fri Apr 25, 2014 1:48 am
by kgopiramesh
No the db is running on the same server where the nagios application is hosted.

Re: postgres db error

Posted: Fri Apr 25, 2014 11:13 am
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?

Re: postgres db error

Posted: Mon Apr 28, 2014 3:08 am
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.

Re: postgres db error

Posted: Mon Apr 28, 2014 1:22 pm
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...

Re: postgres db error

Posted: Tue Apr 29, 2014 5:18 am
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

Re: postgres db error

Posted: Tue Apr 29, 2014 4:39 pm
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?

Re: postgres db error

Posted: Mon May 05, 2014 2:03 am
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"

Re: postgres db error

Posted: Mon May 05, 2014 10:57 am
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?