When upgrading Ambari Server, in our case from version 2.6.0 to 2.6.2.0, database inconsistencies can occur. For us, Ambari Server would fail to start, and would report database inconsistencies.
Database inconsistency log file:
/var/log/ambari-server/ambari-server-check-database.log
Fixing these issues will require the Ambari DB to have records altered. Please be sure to have a valid backup of your Ambari database before proceeding.
After reviewing the log file, here are some of steps taken to resolve our issue;
First we tried restarting Ambari Server with it’s auto-fix option. This will run some generic SQL to try and cleanup what it can find.
# ambari-server restart --auto-fix-database
In our case Ambari was able to clean up a majority of the WARN’s in the log, but some remained. There were some old configs that seemed to be orphaned now, and were not mapped to any services.
Here is an example such warning messages:
"WARN - You have config(s): kerberos-env-version1500071764352,krb5-conf-version1500071764352 that is(are) not mapped (in serviceconfigmapping table) to any service!" occurs as the Ambari Server fails to start
For some context, our Ambari is using an MySQL database.
With issues persisting, manual changes of the records in Ambari were needed. To fix the orphaned configs, you will have to login to your Ambari DB and perform the following queries.
SELECT config_id,type_name,version_tag FROM clusterconfig WHERE unmapped != 1 AND type_name NOT IN ('cluster-env') AND config_id NOT IN (SELECT cc.config_id FROM clusterconfig cc, serviceconfig sc, serviceconfigmapping scm WHERE cc.type_name != 'cluster-env' AND cc.config_id = scm.config_id AND scm.service_config_id = sc.service_config_id);
CREATE TEMPORARY TABLE orphaned_configs AS (SELECT config_id,type_name,version_tag FROM clusterconfig WHERE unmapped != 1 AND type_name NOT IN ('cluster-env') AND config_id NOT IN (SELECT cc.config_id FROM clusterconfig cc, serviceconfig sc, serviceconfigmapping scm WHERE cc.type_name != 'cluster-env' AND cc.config_id = scm.config_id AND scm.service_config_id = sc.service_config_id));
SELECT * FROM orphaned_configs;
UPDATE clusterconfig SET unmapped = 1 WHERE config_id IN (SELECT config_id FROM orphaned_configs);
This should clear up the last of Ambari DB inconsistency warnings, regarding any orphaned configs, and Ambari Server should now be able to start successfully. Still not having success? Here is a community article similar to this post.
It would also be best practice to cleanup Ambari Server historical data during this time. Hortonworks documentation for this step, provided here!
Performing this operation analyzes tables in the Ambari Server database and removes rows that can be deleted which have a –create-date after the –from-date specified in your command.
As per the documentation, here are the steps to purge your Ambari Server historical data;
Happy Hadooping!
Written by Ryan St. Louis