Virtual appliance migration fails: Duplicate entry for key 'PRIMARY'
search cancel

Virtual appliance migration fails: Duplicate entry for key 'PRIMARY'


Article ID: 42890


Updated On:


STARTER PACK-7 CA Rapid App Security CA API Gateway




The Virtual Appliance Upgrader allows an administrator to migrate a Gateway node from a virtual appliance running version 7.1.0 (on Red Hat Enterprise Linux 6) to version 8.0.0 (running Red Hat Enterprise Linux 6). Because the major version of Enterprise Linux was upgraded, a new installation of RHEL is required.

The upgrader automatically takes a backup and converts the existing data into a format acceptable for the upgraded appliance. It also facilitates migrating other environment-specific items encapsulated in the backup. For more information on the Virtual Appliance Upgrader, please search for the "Layer 7 version 7.1 to 8.0 Upgrade Guide" on the Downloads portal.

In some circumstances, the Virtual Appliance Upgrader will fail to complete the migration and restoration due to a Gateway node and database having existing or currently existing on the appliance. This article will detail how to remove the existing node to complete the migration and restoration.


The upgrader log files may contain the following error logs that indicates the upgrader was unable to complete due to an existing Gateway database or node:
ERROR 1062 (23000) at line 1: Duplicate entry '<value>' for key 'PRIMARY'?
ERROR : Could not restore database backup

If this error message occurs then the upgrade was unable to restore certain items because they were duplicated in the MySQL server used by the Gateway database.


The most expedient method of resolving this error is to go through the Gateway configuration menu and remove the existing node and database. This can be done as follows:
  1. Log into the Gateway appliance as the ssgconfig user.
  2. Select Option #2: Display the Layer 7 Gateway configuration menu.
  3. Select Option #5: Delete the Layer 7 Gateway.
  4. Respond in the affirmative ("Yes") to all prompts.
  5. Confirm the changes and exit.
Once the changes have been implemented, attempt to rerun the virtual appliance migration script. It is possible that a Gateway database node may have already been removed but the database objects have not been cleanly extracted. If the process above does not correct the issue then please implement the workaround detailed in the following section


Several items will need to be manually removed from the Gateway appliance in order to complete the upgrader:
  1. Log into the Gateway appliance as the?ssgconfig user.
  2. Select Option #3: Use a privileged shell (root)
  3. Execute the following SQL queries
DELETE FROM mysql.user WHERE user != "root";
  1. Exit the MySQL prompt.
  2. Attempt to rerun the virtual appliance migration script.
Please note that the value for "ssg"?may vary based on the configuration of the existing node. If you are not certain which values to substitute in place for your installation then please contact Layer 7 Support and reference this article.


Component: APIGTW