Page 1 of 1
Database error when setting up nagios server
Posted: Tue Oct 23, 2018 3:27 pm
by vy3734
Hi,
I'm trying to setup a new nagios server. I was able to set it up and bring up the GUI. This is a new physical server with redhat 7.5 running on it, i already had a nagiosxi backup created on a virtual machine running on redhat 6.9 with backup_xi.sh script. I uploaded the backup tar file onto the new server and did a restore_xi.sh. I started seeing the following error:
Message: A database connection error has been detected, we are attempting to repair the server, if the repair does not resolve the issue, please contact Nagios support.
Run the following from the CLI as root to attempt to repair the DB
/usr/local/nagiosxi/scripts/repair_databases.sh
I then tried to execute the ./A-subcomponents as specified in the backup and restore nagios pdf. The script ran fine. I also tried running the repair_databases.sh as suggested by the error message. I Still see the database issue, the GUI won't come up.
Please help!
Thanks!
Re: Database error when setting up nagios server
Posted: Tue Oct 23, 2018 3:35 pm
by vy3734
This is the output of the restore script execution:
[root@NagiosServer scripts]# ./restore_xi.sh /www/backups/nagiosxi/MCOM_RTP_OCT23.tar.gz
tar: MCOM_RTP_OCT23/nagiosxi.tar.gz: Not found in archive
tar: Exiting with failure status due to previous errors
gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now
tar: MCOM_RTP_OCT23/nagiosxi.tar.gz: Not found in archive
tar: Exiting with failure status due to previous errors
gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now
TS=1540326224
Extracting backup to /store/backups/nagiosxi/1540326224-restore...
In /store/backups/nagiosxi/1540326224-restore/1540316337...
Backup files look okay. Preparing to restore...
Shutting down services...
Stopping nagios (via systemctl): [ OK ]
Stopping ndo2db (via systemctl): [ OK ]
rm: cannot remove '/usr/local/nagiosxi/var/subsys/npcd.pid': No such file or directory
NPCD was not running.
Restoring directories to /...
Restoring Nagios Core...
Restoring Nagios XI...
Restoring NagiosQL...
Restoring NagiosQL backups...
Restoring NRDP backups...
Restoring MRTG...
Restoring Nagvis backups...
Restoring MySQL databases...
Redirecting to /bin/systemctl start postgresql.service
Restoring Nagios XI PostgresQL database...
psql: FATAL: role "nagiosxi" does not exist
Error restoring PostgresQL database 'nagiosxi' !
Re: Database error when setting up nagios server
Posted: Tue Oct 23, 2018 3:38 pm
by lmiltchev
Try running the following commands on the new server to see if this is going to solve your issue:
Code: Select all
cd /tmp/
wget https://assets.nagios.com/downloads/nagiosxi/scripts/restore_repair.sh
chmod +x restore_repair.sh
./restore_repair.sh
Re: Database error when setting up nagios server
Posted: Tue Oct 23, 2018 3:41 pm
by ssax
In addition to what lmiltchev posted:
Did your RHEL 6.9 server have an offloaded/external DB? (you should be able to look in your /usr/local/nagiosxi/html/config.inc.php at the dbserver entries).
Did you see any errors when running the restore script or was it only afterwards?
You can PM me your profile from the RHEL 6.9 server (Admin > System Profile > Download Profile) so that I can get an idea of your current setup and why it would give that error after the restore.
Code: Select all
tar: MCOM_RTP_OCT23/nagiosxi.tar.gz: Not found in archive
I'm wondering if the backup was successful, can you try running these commands from the 6.9 server and see if any errors are generated?
Code: Select all
cd /usr/local/nagiosxi/scripts
./backup_xi.sh
Re: Database error when setting up nagios server
Posted: Tue Oct 23, 2018 4:12 pm
by vy3734
After seeing the postgres error during the restore, i looked up the forums and i found the following instructions:
[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
after executing these commands, i did a restore again. It went fine and i was able to login to the GUI and see the same services and hosts as in the old nagios. I am assuming we are good for now. Will reach out if i see any more issues. Thank you so much for taking time to respond to my questions. really appreciate the effort.
Thanks!
Re: Database error when setting up nagios server
Posted: Tue Oct 23, 2018 4:19 pm
by ssax
Nice catch! Let us know if you run into anything else.
Re: Database error when setting up nagios server
Posted: Wed Oct 24, 2018 9:23 am
by vy3734
Hi,
I am not sure if it is the way my nagios servers are built or if it is something else... i get a new error everytime i try to setup a new server.
I was just trying to setup a new nagios server for a different environment, i ran into the following issue
[root@ nagiosxi]# ./E-importnagiosql
Applying patches to Apache configs for Apache 2.4.x syntax...
Sleeping...
NOTE: If prompted, enter the MySQL root password
NagiosQL database appears OK - continuing...
NDOUtils database appears OK - continuing...
ERROR: No files to import - exiting. Were Nagios Core and NagiosQL installed?
I started out with executing ./fullinstall -n -p nagiosxi, everything went fine until E-importnagiosql.
The first error i saw was
2018-10-24 10:12:13 (1023 KB/s) - ‘nagiosql.import.monitoring’ saved [23514]
Sorry, user root is not allowed to execute '/tmp/nagiosxi/nagiosxi/basedir/scripts/reset_config_perms.sh' as root on ma100blpmon502.
RESETTING CONFIG PERMS FAILED!\n
RESULT=1
===================
INSTALLATION ERROR!
===================
Installation step failed - exiting.
Check for error messages in the install log (install.log).
If you require assistance in resolving the issue, please include install.log
in your communications with Nagios XI technical support.
The script that failed was: './E-importnagiosql'
then i manually executed the E script , output is as follows
[root@ nagiosxi]# /tmp/nagiosxi/nagiosxi/basedir/scripts/reset_config_perms.sh
RESETTING PERMS
/bin/chown: cannot access ‘/usr/local/nagiosxi/nom/checkpoints/nagiosxi’: No such file or directory
i then manually created the directory required and the script exited without any errors.
i'm now stuck at ./E-importnagiosql with the error
ERROR: No files to import - exiting. Were Nagios Core and NagiosQL installed?
Any thoughts on where i went wrong?? Please help!
Re: Database error when setting up nagios server
Posted: Wed Oct 24, 2018 10:20 am
by vy3734
I found the following instructions in the forums:
cd /tmp/nagiosxi
cp -r ./subcomponents/nagioscore/mods/cfg/import/* /usr/local/nagios/etc/import
chown apache:nagios /usr/local/nagios/etc/import/*.cfg
./fullinstall -n -p nagiosxi
after executing the above commands, the script execution is stuck at
2018-10-24 11:16:55 (989 KB/s) - ‘nagiosql.import.monitoring’ saved [23514]
Another reconfigure process is still running, sleeping...
Another reconfigure process is still running, sleeping...
Another reconfigure process is still running, sleeping...
Another reconfigure process is still running, sleeping...
Another reconfigure process is still running, sleeping...
Another reconfigure process is still running, sleeping...
Re: Database error when setting up nagios server
Posted: Wed Oct 24, 2018 4:06 pm
by npolovenko
@vy3734, This is very unusual. Please run the following commands:
service nagios stop
rm -f /usr/local/nagiosxi/scripts/reconfigure_nagios.lock
service nagios start
And then run this command to verify configs:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
I also suggest recreating the sudoers file as described here:
https://support.nagios.com/kb/article.php?id=34
Finally, please upload the following file:
/usr/local/nagiosxi/html/config.inc.php