File Name: Repairing_The_Nagios_XI_Database.pdf
File Size: 236.98 KB
File Type: Application/pdf
Last Modified: 5 years
Status: Available
Last checked: 2 days ago!
This Document Has Been Certified by a Professional
100% customizable
Language: English
We recommend downloading this file onto your computer
The Industry Standard In Infrastructure Monitoring Nagios XI Repairing The Nagios XI Databases Purpose This document describes how to repair the databases used by Nagios XI
Target AudienceThis document is intended for use by Nagios XI Administrators
Additional DocumentsNagios administrators are urged to read the following document related to the Nagios XI database: • Nagios XI Database Optimization ◦ https://assets.nagios.com/downloads/nagiosxi/docs/Nagios-XI-Database-Optimization.pdfProblem SymptomsIf you experience high load on your Nagios XI server and the MySQL process (mysqld) appears to beconsuming large amounts of CPU, it may be a symptom of one or more crashed tables. The steps outlinedbelow allow you to repair the MySQL database tables used by Nagios XI
Important InformationHistorically MySQL has been the database used by Nagios XI, however in RHEL/CentOS 7.x onwardsMariaDB is used instead of MySQL. MariaDB is simply a fork of the MySQL database, the commands usedare the same however some of the output differs slightly
Separate to this, Nagios XI versions before 5.x used a PostgreSQL database for storing the Nagios XIpreferences. In Nagios XI 5.x this was moved over to the MySQL database
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102 www.nagios.com© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, orregistered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 1 / 7 Updated – July, 2017 The Industry Standard In Infrastructure Monitoring Nagios XI Repairing The Nagios XI DatabasesThe following applies: • Fresh installations of Nagios XI will no longer use PostgreSQL • Upgrading a previous version of Nagios XI will continue to use the PostgreSQL databaseThis is highlighted where necessary in the steps below. If you are unsure, execute the following command onyour Nagios XI server:awk '/"nagiosxi" => array\(/{getline;print}' /usr/local/nagiosxi/html/config.inc.phpWhich should output one of the following: "dbtype" => 'pgsql', or "dbtype" => 'mysql',Database BackupsBefore attempting to repair database tables, you should ensure that you have recent backups of the databasein case of catastrophic failure in the recovery process. Nagios XI includes a MySQL backup script that placesdatabase backups in the /store/backups/mysql/ directory of the Nagios XI server. Verify that thisdirectory contains recent and valid backups before continuing with the repair process
The following documentation explains in detail the backup and restore steps in Nagios XI:https://assets.nagios.com/downloads/nagiosxi/docs/Backing-Up-And-Restoring-Nagios-XI.pdf 1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102 www.nagios.com© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, orregistered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 2 / 7 Updated – July, 2017 The Industry Standard In Infrastructure Monitoring Nagios XI Repairing The Nagios XI DatabasesRepairing MySQL TablesEstablish a terminal session to your Nagios XI server as the root user
Versions Of Nagios XI 2014 OnwardsExecute the following command: /usr/local/nagiosxi/scripts/repair_databases.shThis script which will automatically repair all databases (nagios, nagiosql) (nagiosxi in XI 5.x). Once thescript has completed, please review all of the output generated for any errors. For any errors please refer tothe troubleshooting section in this document
Versions Of Nagios XI BEFORE 2014Stop the MySQL database server with the following command: service mysqld stopRun the Nagios XI database repair script with the following command: /usr/local/nagiosxi/scripts/repairmysql.sh nagiosThe script will check and repair all tables in the nagios MySQL database. This process may take severalminutes to complete, depending on the size of your database. You can re-run the repair script on thenagiosql database. Once the script has completed, please review all of the output generated for any errors
For any errors please refer to the troubleshooting section in this document
Once the script has completed, start the MySQL database server with the following command: service mysqld start 1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102 www.nagios.com© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, orregistered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 3 / 7 Updated – July, 2017 The Industry Standard In Infrastructure Monitoring Nagios XI Repairing The Nagios XI DatabasesTroubleshootingIf you receive an error, similar to this one:SQL: DELETE FROM nagios_logentries WHERE logentry_time < FROM_UNIXTIME(1293570334) SQL: SQL Error [ndoutils] : Table './nagios/nagios_logentries' is marked ascrashed and last (automatic?) repair failedCLEANING ndoutils TABLE 'notifications'..
You may need to run a force repair on the tables: service mysqld stop cd /var/lib/mysql/nagios myisamchk -r -f nagios_
If you receive this error: myisamchk: error: 'nagios_commenthistory.MYI' is not a MyISAM-tableThis means that the MYSQL tables are in the wrong format and they need to be converted. Before youconvert them, do a full backup of the server in case there are any issues. To convert all InnoDB Tables toMyISAM (all databases) follow these steps:Execute the following command to enter the mysql command interface (nagiosxi is the default rootMySQL/MariaDB password): mysql -u root -p'nagiosxi' 1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102 www.nagios.com© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, orregistered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 5 / 7 Updated – July, 2017 The Industry Standard In Infrastructure Monitoring Nagios XI Repairing The Nagios XI DatabasesYou are now logged into the mysql command interface, this is indicated by the mysql> OR MariaDB[(none0]> prompt
Run the following command to convert all of the tables (this is one long command that is wrapped over twolines): SELECT CONCAT('ALTER TABLE ', TABLE_SCHEMA, '.', TABLE_NAME, ' engine=MyISAM;') FROM information_schema.TABLES WHERE ENGINE = 'InnoDB';Now you can exit the mysql command interface: quitAfter this, you can run the following to repair the MYSQL databases
mysqlcheck -f -r -u root -pnagiosxi --all-databasesOnce the command has completed, please review all of the output generated for any errors
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102 www.nagios.com© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, orregistered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 6 / 7 Updated – July, 2017 The Industry Standard In Infrastructure Monitoring Nagios XI Repairing The Nagios XI DatabasesIf you have run out of disk space on your Nagios XI server, the following KB article can provide solutions toresolving this issue:https://support.nagios.com/kb/article.php?id=26Once you've resolved the disk space issue you should run the repair database script again
Finishing UpThis completes the documentation on repairing the Nagios XI databases
If you have additional questions or other support related questions, please visit us at our Nagios SupportForums:https://support.nagios.com/forumThe Nagios Support Knowledgebase is also a great support resource:https://support.nagios.com/kb 1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102 www.nagios.com© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, orregistered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 7 / 7 Updated – July, 2017
Error : Corrupt You will need to execute the following command to fix the table: service mysqld start echo 'repair table nagios_systemcommands use_frm;' mysql -t -u root -pnagiosxi …
Establish a terminal session to your Nagios XI server as the root user. This script which will automatically repair all databases (nagios, nagiosql) (nagiosxi in XI 5.x +). Once the script has completed, please review all of the output generated for any errors.
Historically MySQL has been the database used by Nagios XI, however in RHEL/CentOS 7.x onwards MariaDB is used instead of MySQL. MariaDB is simply a fork of the MySQL database, the commands used are the same however some of the output differs slightly.
Before attempting to repair database tables, you should ensure that you have recent backups of the databasein case of catastrophic failure in the recovery process. Nagios XI includes a MySQL backup script that places database backups in the /store/backups/mysql/ directory of the Nagios XI server. Verify that this.