Page 1 of 1

Database Error after migration from CentOS to Ubuntu

Posted: Wed Oct 14, 2020 6:43 am
by it_bizup
Hello,
I am trying to migrate an installation of nagios XI from CentOS 6.9 to a freshly set up Ubuntu 20.04 Server.

The version of both installations 5.7.3.
Both are VMs running in Hyper-V on the same server.

I tried the migration by doing the following steps:

1. I upgraded the current prod installation on the CentOS Server to 5.7.3 last Thursday
2. the configuration from the CentOS machine gets backed up by FTP every friday - the backup from last friday is the basis for my migration
3. I installed Nagios XI on the Ubunut Server acc. quick-installation in https://assets.nagios.com/downloads/nag ... -Linux.pdf
4. I copied the backup .tar from to the ubuntu server and tried to restore it acc. https://assets.nagios.com/downloads/nag ... ios-XI.pdf
5. I also executed the repair script mentioned in "After The Restore" as operating system is different

The problem is now, that if I try to access the nagios XI at the Ubuntu server, I get the following error:

Database Error
A database connection error has been detected, please follow the repair prompt below. If the issue persists, 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 already tried the repair_database script - but I still get the same error.
All the scripts above run through successfully.

Thank you very much in advance,

Andreas

Re: Database Error after migration from CentOS to Ubuntu

Posted: Wed Oct 14, 2020 4:38 pm
by ssax
Please PM me a copy of your profile from the Ubuntu 20 system, you can download it from Admin > System Profile by clicking the Download Profile button.

If you're unable to generate the the profile through the web interface, please try generating it from the command line by running these commands as root:

Code: Select all

rm -rf /usr/local/nagiosxi/var/components/profile*​​
/usr/local/nagiosxi/scripts/components/getprofile.sh SUPPORT
Then send me the resulting /usr/local/nagiosxi/var/components/profile.zip​ file.​

If the profile script fails, please include the ENTIRE output.

Re: Database Error after migration from CentOS to Ubuntu

Posted: Thu Oct 15, 2020 2:16 am
by it_bizup
Hi ssax,
Thank you very much for your reply!
The profile script was successful.

It seems, that I need to be unlocked to pm people as it says following at the personal message page:
We are sorry, but you are not authorised to use this feature. You may have just registered here and may need to participate more to be able to use this feature.

Best regards,
Andreas

Re: Database Error after migration from CentOS to Ubuntu

Posted: Thu Oct 15, 2020 3:15 pm
by ssax

Code: Select all

UNABLE TO CONNECT TO DB - EXITING!
Make sure the user/passwords for the nagios DB are the same in /usr/local/nagios/etc/ndo.cfg and in /usr/local/nagiosxi/html/config.inc.php.

Make sure that you edit your /etc/mysql/mysql.conf.d/mysqld.cnf and add this under the [mysqld] section:

Code: Select all

sql_mode=""
Then restart mysql:

Code: Select all

systemctl restart mysql
Additionally, please send the output of this command:
- NOTE: You may need to adjust the -h 127.0.0.1, the -uroot, and -pnagiosxi in the command if your DB is offloaded to another server and/or you've changed the root mysql password

Code: Select all

echo "SELECT table_name AS 'Table', round(((data_length + index_length) / 1024 / 1024), 2) 'Size in MB' FROM information_schema.TABLES WHERE table_schema IN ('nagios', 'nagiosql', 'nagiosxi');" | mysql -h 127.0.0.1 -uroot -pnagiosxi --table

Re: Database Error after migration from CentOS to Ubuntu

Posted: Fri Oct 16, 2020 1:51 am
by it_bizup
Just saw, when trying the select you mentioned, that the root user was identified by auth_socket instead of native password - what is default for root users in mariadb.
So I also tested the login with the users nagiosxi, ndoutils and nagiosql mentioned in /usr/local/nagiosxi/html/config.inc.php.
Login was not possible with any of them.

So i reset the passwords for all three users with "ALTER USER '...'@'localhost' identified by '...'" to the passwords mentioned in the config file and now it seems to work as the error is gone and I can log in at the Ubuntu server.
Seems setting the passwords didn't work in the restore script. (altough, haven't seen any error there)

Re: Database Error after migration from CentOS to Ubuntu

Posted: Fri Oct 16, 2020 4:11 pm
by ssax
Interesting, thanks for posting what resolved it for you!

I labbed this up and was able to replicate it. The reason why this fails is because the XI backup doesn't contain the mysql DB which contains the user/passwords so after the restore is finished the /usr/local/nagiosxi/html/config.inc.php is actually wrong because the fresh install of XI would have created it with the default password.

I've let QA know about this.