Page 1 of 2

Error restoring PostgresQL database 'nagiosxi... Please help

Posted: Sun Sep 24, 2017 3:50 am
by dbsaust
Hi All,
We are trying to restore Nagios XI 5.2.2 version:
- Source system is 32 bit, Cent OS 5
- Destination system is 64 bit Cent OX 7
- Installed Nagios XI 5.2.2 on destination VM and then run the restoration script. Haven't installed anything except WGET on the new VM destination. But restore script is complaining about PostgresQL.

- Screen shot logs as below. What to do? Kindly assist.

Log:

Code: Select all

[root@newnagiosxi nagiosxi]# /usr/local/nagiosxi/scripts/restore_xi.sh  /store/backups/nagiosxi/1505986286.tar.gz
WARNING: you are trying to restore a i386 backup on a x86_64 system
         Compiled plugins and other binaries will NOT be restored.

Are you sure you want to continue? [y/N] y
WARNING: you are trying to restore a OS 5 backup on a OS 7 system
         Compiled plugins and other binaries as well as httpd configurations
         will NOT be restored.

Are you sure you want to continue? [y/N] y
TS=1506241895
Extracting backup to /store/backups/nagiosxi/1506241895-restore...
In /store/backups/nagiosxi/1506241895-restore/1505986286...
Backup files look okay.  Preparing to restore...
Shutting down services...
Restoring directories to /...
Restoring Nagios Core...
Restoring Nagios XI...
Restoring NagiosQL...
Restoring NagiosQL backups...
Restoring NRDP backups...
Restoring MRTG...
Restoring Nagvis backups...
chown: cannot access â/usr/local/nagvisâ: No such file or directory
Restoring MySQL databases...
Redirecting to /bin/systemctl start  postgresql.service
Job for postgresql.service failed because the control process exited with error code. See "systemctl status postgresql.service" and "journalctl -xe" for details.
Restoring Nagios XI PostgresQL database...
psql: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Error restoring PostgresQL database 'nagiosxi' !
You have new mail in /var/spool/mail/root

Re: Error restoring PostgresQL database 'nagiosxi... Please

Posted: Mon Sep 25, 2017 10:58 am
by scottwilkerson
you will need to also have postgres installed to restore a version that was running postgres

Code: Select all

yum install postgresql postgresql-devel postgresql-libs postgresql-server php-pgsql -y
Then perform the restore

Once the restore is complete, being you are changing arch, you will want to see this document as well
https://support.nagios.com/kb/article/n ... -data.html

Re: Error restoring PostgresQL database 'nagiosxi... Please

Posted: Tue Sep 26, 2017 12:13 am
by dbsaust
Thanks scottwilkerson!
I will try tonight and update you here.

Re: Error restoring PostgresQL database 'nagiosxi... Please

Posted: Tue Sep 26, 2017 5:33 am
by dbsaust
Hi scottwilkerson,
PostgreSQL is now running okay. However, this time complaining the below:

psql: FATAL: Peer authentication failed for user "nagiosxi"

Code: Select all

Extracting backup to /store/backups/nagiosxi/1506421212-restore...
In /store/backups/nagiosxi/1506421212-restore/1505986286...
Backup files look okay.  Preparing to restore...
Shutting down services...
Restoring directories to /...
Restoring Nagios Core...
Restoring Nagios XI...
Restoring NagiosQL...
Restoring NagiosQL backups...
Restoring NRDP backups...
Restoring MRTG...
Restoring Nagvis backups...
chown: cannot access â/usr/local/nagvisâ: No such file or directory
Restoring MySQL databases...
Redirecting to /bin/systemctl start  postgresql.service
Restoring Nagios XI PostgresQL database...
psql: FATAL:  Peer authentication failed for user "nagiosxi"
Error restoring PostgresQL database 'nagiosxi' !

Re: Error restoring PostgresQL database 'nagiosxi... Please

Posted: Tue Sep 26, 2017 9:43 am
by scottwilkerson
Sorry, you will also need to so the following:

Code: Select all

psql -c "create user nagiosxi with password 'n@gweb';"
psql -c "create database nagiosxi owner nagiosxi;"

Re: Error restoring PostgresQL database 'nagiosxi... Please

Posted: Tue Sep 26, 2017 8:44 pm
by dbsaust
Thanks again, scottwilkerson!

I tried the following which were successful. Will give it a go tonight and will update here.

Code: Select all

[root@newnagiosxi ~]# su - postgres
Last login: Tue Sep 26 21:09:45 AEST 2017 on pts/0
-bash-4.2$ psql -c "create user nagiosxi with password 'n@gweb';"
CREATE ROLE
-bash-4.2$ psql -c "create database nagiosxi owner nagiosxi;"
CREATE DATABASE
-bash-4.2$ exit
logout

Re: Error restoring PostgresQL database 'nagiosxi... Please

Posted: Wed Sep 27, 2017 5:10 am
by dbsaust
Hi scottwilkerson,
Still following error. Kindly assist.

Restoring Nagios XI PostgresQL database...
psql: FATAL: Peer authentication failed for user "nagiosxi"

Re: Error restoring PostgresQL database 'nagiosxi... Please

Posted: Wed Sep 27, 2017 10:17 am
by tgriep
There is a Postgres configuration file that needs to be configures to allow access to the database and the default settings maybe blocking the restore.
Edit the following file on the new server.

Code: Select all

/var/lib/pgsql/data/pg_hba.conf
Comment out all of the settings at the bottom of the file and add the following if they do not exist.

Code: Select all

local   all         all                               trust
host    all         all         127.0.0.1/32          trust
host    all         all         ::1/128               trust
Save the file and restart postgres by running

Code: Select all

service postgresql restart
Then try the restore again and see if this resolves the issue.

Re: Error restoring PostgresQL database 'nagiosxi... Please

Posted: Wed Sep 27, 2017 7:59 pm
by dbsaust
Hi tgriep,
Modified following lines and restart the service as per your direction. Will try again tonight and inform you the outcome. Thanks.

Code: Select all

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

Re: Error restoring PostgresQL database 'nagiosxi... Please

Posted: Thu Sep 28, 2017 5:45 am
by dbsaust
Hi tgriep,
Yes, restoration completed and I can login Nagios XI pages using an existing user. Thank you very much!
By the way, after restoration, as documented, I applied the follwoing commands:

Code: Select all

cd /tmp/nagiosxi
rm -f installed.subcomponents
./A-subcomponents

The above gave error on MySQL though, but pages still working. Do I need to re-run above commands?

Additionally, we are migrating from a 32bit to 64bit machine and I understand that we need to convert the performance data. Is it mandatory now?

Thanks mate.