Page 1 of 1

restoring to different platform - mysql issues

Posted: Fri Oct 27, 2023 5:26 am
by elinagios
Hello

Current environment:
centos 7
nagiosxi 5.11.2

Installed new empty environment:
Ubuntu 22.04
nagiosxi 5.11.2

1) Used the Backing Up And Restoring Your Nagios XI System.pdf to restore current setup to the new one.
2) Used restore_repair.sh for cross platform repair, it ended with:
UPGRADE: POST-UPGRADE: NDO post upgrade started...
Performing install...
> Creating database with user
> Enter MySQL root password:
> Using command line supplied credentials for account/db creation...
> Username: ndoutils
> Password: *****
> Database: nagios
> Press <ENTER> to continue...
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1007 (HY000) at line 1: Can't create database 'nagios'; database exists
Something went wrong creating database 'nagios'
Finished restore repair OK
3) In web ui, it gives error:
Database Error
Access denied for user 'nagiosxi'@'localhost' (using password: YES)
Run the following from the CLI as root to attempt to repair the DB:
/usr/local/nagiosxi/scripts/repair_databases.sh
4) i run repair_databases.sh but it doesnt change anything, error remains.

In nagios.log i see error:
[1698392554] NDO-3: NDO 3.1.0 (c) Copyright 2009-2023 Nagios - Nagios Core Development Team
[1698392554] NDO-3: Unable to connect to mysql. Configuration may be incorrect or database may have temporarily disconnected.

Database Error: Could not connect to database
Access denied for user 'nagiosxi'@'localhost' (using password: YES)

What am i missing here?

Also, during the restore proccess, it gives info - what is it refereing to, which subcomponents:
You will need to re-download the Nagios XI tarball, and re-installthe subcomponents for this system

Re: restoring to different platform - mysql issues

Posted: Fri Oct 27, 2023 9:48 am
by sgardil
Hey @elinagios

Sorry to hear that you are having issues. Bellow is some documentation that may help solve this issue. Unfortunately migrating across different distros can always have its issues. Let us know if the documentation below helps solve the issue.
https://support.nagios.com/kb/article/m ... r-892.html

Re: restoring to different platform - mysql issues

Posted: Fri Oct 27, 2023 10:02 am
by gwesterman
Hi @elinagios,

If you haven't already, trying the last suggestion in the article @sgardil shared would be a good place to start:

Establish a terminal session to your offloaded MySQL server and execute the following commands:

Code: Select all

mysql -u root -p'mypassword'
Once logged in, execute these commands:

Code: Select all

GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.26.5.12' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

FLUSH PRIVILEGES;

QUIT;
You will need to change the address 10.26.5.12 to the IP address of your Nagios XI server. After making those changes the restore script should successfully complete.

Re: restoring to different platform - mysql issues

Posted: Thu Nov 02, 2023 7:51 am
by elinagios
I did the restore by that article.
The mysql password was updated in the restore script and mysql is not offloaded to another server but is in the same with nagiosxi itself.

When i try to re-Grant,
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'somepassword' WITH GRANT OPTION;
i get error:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY 'somepassword' WITH GRANT OPTION' at line 1

Re: restoring to different platform - mysql issues

Posted: Thu Nov 02, 2023 11:35 am
by jsimon
Hi elinagios,

Depending on the MYSQL version there are some differences in how IDENTIFIED BY is handled within a GRANT statement, and depending on whether or not the user already exists or is being created and granted permissions by a single statement. My recommendation is to try it without the IDENTIFIED BY clause.

Code: Select all

Access denied for user 'nagiosxi'@'localhost' (using password: YES)
This makes me believe you are using the wrong password for the restore script. This needs to match the password used in your MYSQL config. I would confirm the password in your config file (likely in /etc/mysql) and make sure it matches the password used in the restore script.

If the issue persists after trying these steps, please let us know what version of MYSQL is on the Ubuntu server you are migrating to.

Re: restoring to different platform - mysql issues

Posted: Fri Nov 03, 2023 1:56 am
by elinagios
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

/usr/local/nagiosxi/scripts/repair_databases.sh
===============
REPAIR COMPLETE
===============

=======================
nagios database repair succeeded
nagiosql database repair succeeded
nagiosxi database repair succeeded

The error message on website remains asking to do repair.

In logs 2 things i see which are causing the problem i guess.

1) Database Error: Could not connect to database. Access denied for user 'nagiosxi'@'localhost' (using password: YES)
Should i grant some access to nagiosxi too or the initial nagiosxi restore proccess should have done it for me?

2) [1698993298] NDO-3: NDO 3.1.0 (c) Copyright 2009-2023 Nagios - Nagios Core Development Team
[1698993298] NDO-3: Unable to connect to mysql. Configuration may be incorrect or database may have temporarily disconnected.
[1698993298] NDO-3: NDO was not able to initialize the database (main context) and will not start.
[1698993298] Event broker module '/usr/local/nagios/bin/ndo.so' initialized successfully.
[1698993298] Error: Could not load module '/usr/lib64/mod_gearman/mod_gearman_nagios4.o' -> file not found
[1698993298] Error: Failed to load module '/usr/lib64/mod_gearman/mod_gearman_nagios4.o'.
[1698993298] Error: Module loading failed. Aborting.
[1698993298] NDO-3: Callbacks deregistered
[1698993298] NDO-3: NDO - Shutdown complete
[1698993298] Event broker module '/usr/local/nagios/bin/ndo.so' deinitialized successfully.

In original setup im using mod-gearman and in the new setup i want to move away from it as it is no longer supported. Where is it in cofiguration to disable mod-gearman?

Re: restoring to different platform - mysql issues

Posted: Fri Nov 03, 2023 9:03 am
by gwesterman
Hi @elinagios,

This forum answer covers how to uninstall mod-gearman.

Let us know if this works for you.