Support Questions

Find answers, ask questions, and share your expertise

org.apache.ambari.server.AmbariException: Cannot add foreign key constraint

avatar
Super Collaborator

ambari upgrade

upgrading ambari-server from 1.7 to 2.2 with mysql 5.6

while running ambari-server upgrade it failed with org.apache.ambari.server.AmbariException: Cannot add foreign key constraint

any work around, i couldn't even create the FK manually either.. is it a known issue?

1 ACCEPTED SOLUTION

avatar
Super Collaborator

This is known issue for MYSQL DBs and we need to convert all the tables to use InnoDB engine.

You can use the below SQL to generate the commands to alter the tables to InnoDB engine.

SELECT concat('ALTER TABLE ',TABLE_NAME,' ENGINE=InnoDB;')

FROM Information_schema.TABLES

WHERE TABLE_SCHEMA = 'ambaridb' AND ENGINE = 'MyISAM' AND TABLE_TYPE='BASE TABLE';

Once we get the output , remove the ' | ' and run the alter commands.

Once we run alter commands, commit and exit mysql.

and than run ambari-server upgrade.

View solution in original post

11 REPLIES 11

avatar
Super Collaborator

This is known issue for MYSQL DBs and we need to convert all the tables to use InnoDB engine.

You can use the below SQL to generate the commands to alter the tables to InnoDB engine.

SELECT concat('ALTER TABLE ',TABLE_NAME,' ENGINE=InnoDB;')

FROM Information_schema.TABLES

WHERE TABLE_SCHEMA = 'ambaridb' AND ENGINE = 'MyISAM' AND TABLE_TYPE='BASE TABLE';

Once we get the output , remove the ' | ' and run the alter commands.

Once we run alter commands, commit and exit mysql.

and than run ambari-server upgrade.

avatar
Master Mentor

@Raja Sekhar Chintalapati did that solve your issue?