<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: org.apache.ambari.server.AmbariException: Cannot add foreign key constraint in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124573#M17741</link>
    <description>&lt;A rel="user" href="https://community.cloudera.com/users/393/aervits.html" nodeid="393"&gt;@Artem Ervits&lt;/A&gt;&lt;P&gt;Error executing query: ALTER TABLE cluster_version ADD CONSTRAINT FK_cluster_version_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters (cluster_id)&lt;/P&gt;&lt;P&gt;clusters table has one row and cluster_version table is empty. that was the reason it is not able to add FK&lt;/P&gt;</description>
    <pubDate>Thu, 04 Feb 2016 02:50:00 GMT</pubDate>
    <dc:creator>chrsvarma</dc:creator>
    <dc:date>2016-02-04T02:50:00Z</dc:date>
    <item>
      <title>org.apache.ambari.server.AmbariException: Cannot add foreign key constraint</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124569#M17737</link>
      <description>&lt;P&gt;ambari upgrade &lt;/P&gt;&lt;P&gt;upgrading ambari-server from 1.7 to 2.2 with mysql 5.6&lt;/P&gt;&lt;P&gt;while running ambari-server upgrade  it failed with org.apache.ambari.server.AmbariException: Cannot add foreign key constraint&lt;/P&gt;&lt;P&gt;any work around, i couldn't even create the FK manually either.. is it a known issue?&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 10:01:57 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124569#M17737</guid>
      <dc:creator>chrsvarma</dc:creator>
      <dc:date>2022-09-16T10:01:57Z</dc:date>
    </item>
    <item>
      <title>Re: org.apache.ambari.server.AmbariException: Cannot add foreign key constraint</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124570#M17738</link>
      <description>&lt;P&gt;what version of HDP is it? &lt;A rel="user" href="https://community.cloudera.com/users/968/chrsvarma.html" nodeid="968"&gt;@Raja Sekhar Chintalapati&lt;/A&gt; you need to upgrade your Ambari 1.7 to 2.1 first then to 2.2. You also need to make sure JDK is at least 1.7 with Ambari 2.2. So follow the documentation for upgrade of Ambari and review system requirements. You also have to be on certain OS levels, RHEL 5 was deprecated.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2016 02:09:56 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124570#M17738</guid>
      <dc:creator>aervits</dc:creator>
      <dc:date>2016-02-04T02:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: org.apache.ambari.server.AmbariException: Cannot add foreign key constraint</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124571#M17739</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/393/aervits.html" nodeid="393"&gt;@Artem Ervits&lt;/A&gt; HW doc doesnt say anything about that...&lt;/P&gt;&lt;P&gt;If your current Ambari version is 1.6.1 or below, you must &lt;A href="http://docs.hortonworks.com/HDPDocuments/Ambari-1.7.0.0/Ambari_Doc_Suite/ADS_v170.html#ref-a1bc8f20-bc41-4adf-aa9d-dccda9f7bb4d"&gt;upgrade the Ambari Server version to 1.7&lt;/A&gt; before upgrading to version 2.2.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2016 02:19:54 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124571#M17739</guid>
      <dc:creator>chrsvarma</dc:creator>
      <dc:date>2016-02-04T02:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: org.apache.ambari.server.AmbariException: Cannot add foreign key constraint</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124572#M17740</link>
      <description>&lt;P&gt;there are system requirements you need to strictly follow like OS and JDK. Try upgrading your ambari to 2.0 first. &lt;A rel="user" href="https://community.cloudera.com/users/968/chrsvarma.html" nodeid="968"&gt;@Raja Sekhar Chintalapati&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2016 02:23:03 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124572#M17740</guid>
      <dc:creator>aervits</dc:creator>
      <dc:date>2016-02-04T02:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: org.apache.ambari.server.AmbariException: Cannot add foreign key constraint</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124573#M17741</link>
      <description>&lt;A rel="user" href="https://community.cloudera.com/users/393/aervits.html" nodeid="393"&gt;@Artem Ervits&lt;/A&gt;&lt;P&gt;Error executing query: ALTER TABLE cluster_version ADD CONSTRAINT FK_cluster_version_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters (cluster_id)&lt;/P&gt;&lt;P&gt;clusters table has one row and cluster_version table is empty. that was the reason it is not able to add FK&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2016 02:50:00 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124573#M17741</guid>
      <dc:creator>chrsvarma</dc:creator>
      <dc:date>2016-02-04T02:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: org.apache.ambari.server.AmbariException: Cannot add foreign key constraint</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124574#M17742</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/968/chrsvarma.html" nodeid="968"&gt;@Raja Sekhar Chintalapati&lt;/A&gt; so you're past the error now?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2016 02:59:38 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124574#M17742</guid>
      <dc:creator>aervits</dc:creator>
      <dc:date>2016-02-04T02:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: org.apache.ambari.server.AmbariException: Cannot add foreign key constraint</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124575#M17743</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/393/aervits.html" nodeid="393"&gt;@Artem Ervits&lt;/A&gt; no it is not&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2016 08:10:00 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124575#M17743</guid>
      <dc:creator>chrsvarma</dc:creator>
      <dc:date>2016-02-04T08:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: org.apache.ambari.server.AmbariException: Cannot add foreign key constraint</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124576#M17744</link>
      <description>&lt;A rel="user" href="https://community.cloudera.com/users/968/chrsvarma.html" nodeid="968"&gt;@Raja Sekhar Chintalapati&lt;/A&gt;&lt;P&gt;The good news is that you can upgrade from 1.7 to 2.2 directly. &lt;A target="_blank" href="http://docs.hortonworks.com/HDPDocuments/Ambari-2.2.0.0/bk_upgrading_Ambari/content/_preparing_to_upgrade_ambari.html"&gt;&lt;/A&gt; "You mentioned this already" &lt;/P&gt;&lt;P&gt;Issue is with the bug in the upgrade process.&lt;/P&gt;&lt;P&gt;You followed the instructions in this &lt;A target="_blank" href="http://docs.hortonworks.com/HDPDocuments/Ambari-2.2.0.0/bk_upgrading_Ambari/content/_upgrade_ambari.html"&gt;link&lt;/A&gt; and hitting this error&lt;/P&gt;&lt;P&gt;Error executing query: ALTER TABLE cluster_version ADD CONSTRAINT FK_cluster_version_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters (cluster_id) clusters table has one row and cluster_version table is empty. that was the reason it is not able to add FK&lt;/P&gt;&lt;P&gt;ambari213=&amp;gt; select * from clusters;&lt;/P&gt;&lt;P&gt; cluster_id | resource_id | cluster_info | cluster_name | provisioning_state | security_type | desired_cluster_state | desired_stack_id &lt;/P&gt;&lt;P&gt;------------+-------------+--------------+--------------+--------------------+---------------+-----------------------+------------------&lt;/P&gt;&lt;P&gt;          2 |           4 |              | HDPTEST      | INSTALLED          | NONE          |                       |                4&lt;/P&gt;&lt;P&gt;(1 row)&lt;/P&gt;&lt;P&gt;ambari213=&amp;gt; select * from cluster_version;&lt;/P&gt;&lt;P&gt; id | repo_version_id | cluster_id |  state  |  start_time   |   end_time    | user_name  &lt;/P&gt;&lt;P&gt;----+-----------------+------------+---------+---------------+---------------+------------&lt;/P&gt;&lt;P&gt;  1 |               1 |          2 | CURRENT | 1447960627766 | 1447960627785 | _anonymous&lt;/P&gt;&lt;P&gt;(1 row)&lt;/P&gt;&lt;P&gt;ambari213=&amp;gt;&lt;/P&gt;&lt;P&gt;Please see the above. We need to find the root cause on "0 rows in  cluster_version" &lt;/P&gt;&lt;P&gt;Can you paste the output of above queries? Also, Do you have access to support?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2016 08:36:17 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124576#M17744</guid>
      <dc:creator>nsabharwal</dc:creator>
      <dc:date>2016-02-04T08:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: org.apache.ambari.server.AmbariException: Cannot add foreign key constraint</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124577#M17745</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/968/chrsvarma.html" nodeid="968"&gt;@Raja Sekhar Chintalapati&lt;/A&gt;  Did you backup the db before upgrade?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2016 08:41:39 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124577#M17745</guid>
      <dc:creator>nsabharwal</dc:creator>
      <dc:date>2016-02-04T08:41:39Z</dc:date>
    </item>
    <item>
      <title>Re: org.apache.ambari.server.AmbariException: Cannot add foreign key constraint</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124578#M17746</link>
      <description>&lt;P&gt;This is known issue for MYSQL DBs and we need to convert all the tables to use InnoDB engine.&lt;/P&gt;&lt;P&gt;You can use the below SQL to generate the commands to alter the tables to InnoDB engine.&lt;/P&gt;&lt;P&gt;SELECT concat('ALTER TABLE ',TABLE_NAME,' ENGINE=InnoDB;')&lt;/P&gt;&lt;P&gt;FROM Information_schema.TABLES&lt;/P&gt;&lt;P&gt;WHERE TABLE_SCHEMA = 'ambaridb' AND ENGINE = 'MyISAM' AND TABLE_TYPE='BASE TABLE';&lt;/P&gt;&lt;P&gt;Once we get the output , remove the ' | ' and run the alter commands.&lt;/P&gt;&lt;P&gt;Once we run alter commands, commit and exit mysql.&lt;/P&gt;&lt;P&gt;and than run ambari-server upgrade.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2016 08:33:32 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124578#M17746</guid>
      <dc:creator>chrsvarma</dc:creator>
      <dc:date>2016-02-05T08:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: org.apache.ambari.server.AmbariException: Cannot add foreign key constraint</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124579#M17747</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/968/chrsvarma.html" nodeid="968"&gt;@Raja Sekhar Chintalapati&lt;/A&gt; did that solve your issue?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2016 08:35:14 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124579#M17747</guid>
      <dc:creator>aervits</dc:creator>
      <dc:date>2016-02-05T08:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: org.apache.ambari.server.AmbariException: Cannot add foreign key constraint</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124580#M17748</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/140/nsabharwal.html" nodeid="140"&gt;@Neeraj Sabharwal&lt;/A&gt; yea...we did follow with support and they said it is a know issue...i posted the comments below..alll we need to do is change the DB engine for all the tables which are MyISAM to InnoDB.&lt;/P&gt;&lt;P&gt;thanks for your response though..&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2016 08:35:35 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/org-apache-ambari-server-AmbariException-Cannot-add-foreign/m-p/124580#M17748</guid>
      <dc:creator>chrsvarma</dc:creator>
      <dc:date>2016-02-05T08:35:35Z</dc:date>
    </item>
  </channel>
</rss>

