How to reinstall Virtual Machine Manager 2012 R2 with UR8 or later

Summary

When you have Microsoft System Center 2012 R2 Virtual Machine Manager (VMM 2012 R2) installed, the reinstallation of VMM Update Rollup 8 or a later update fails, and you receive the following error:
time :InnerException.Type: System.Data.SqlClient.SqlException, InnerException.Message: Violation of PRIMARY KEY constraint 'PK_tbl_WLC_ServiceTemplate'. Cannot insert duplicate key in object 'dbo.tbl_WLC_ServiceTemplate'. The duplicate key value is (5fddb85c-4ae5-4c8b-be83-9b2961a316dd). 


More Information

To successfully reinstall Virtual Machine Manager, follow these steps:

  1. When you start the process of removing Virtual Machine Manager, select the Retain Data option.
  2. Open SQL Management Studio, and then connect to the existing VMM database.
  3. Run the following stored procedure:
    /****** Object: StoredProcedure [dbo].[prc_WLC_GetVNetworkAdapterByNicId] Script Date: 12/16/2015 2:13:12 AM ******/ 
    -- =========================================================
    -- Create date: 08/31/2007
    -- Description: Get VNetworkAdapter for a given NicId
    -- =========================================================
    ALTER PROCEDURE [dbo].[prc_WLC_GetVNetworkAdapterByNicId]
    @VNicId uniqueidentifier
    AS
    BEGIN
    DECLARE @error int
    SET @error = 0
    SET NOCOUNT ON;
    SELECT
    [Name],
    [Description],
    [OwnerIdentifier],
    [CreationTime],
    vna.[ModifiedTime],
    [Accessibility],
    [ObjectState],
    [VNicId],
    [HWProfileId],
    [ParentType],
    [VirtualNetwork],
    [MACAddressType],
    [MACAddress],
    [IPv4AddressType],
    [IPv6AddressType],
    [PortId],
    [DeviceId],
    [NetworkAdapterType],
    [VMSubnetId],
    [VMNetworkId],
    [PortClassificationId],
    [PortProfileSetId],
    [VLanEnabled],
    [VLanId],
    [VmwAdapterIndex],
    [VmwPortGroup],
    [SlotId],
    [MACSpoofingEnabled],
    [EnableGuestIPNetworkVirtualizationUpdates],
    [VMNetworkOptimizationEnabled],
    [HostId],
    [LogicalSwitchId],
    [NetworkKBytesReadTieredPerfCounterID],
    [NetworkKBytesWriteTieredPerfCounterID],
    [VMNetworkServiceSetting],
    [UsesSriov],
    [IsUsedForHostManagement],
    [IPv4Addresses],
    [IPv6Addresses],
    [DefaultGateways],
    [DNSServers],
    [TemplateNicName],
    compliance.PortClassificationComplianceErrors AS [PortClassificationComplianceErrors],
    compliance.VMNetworkComplianceErrors AS [VMNetworkComplianceErrors]
    FROM dbo.tbl_WLC_VNetworkAdapter vna
    LEFT JOIN dbo.tbl_NetMan_VirtualNetworkAdapterCompliance compliance
    ON vna.VNicId = compliance.VirtualNetworkAdapterId
    WHERE VNicId = @VNicId
    SET @error = @@ERROR
    SET NOCOUNT OFF
    RETURN @error
    END
    IF EXISTS (SELECT * FROM dbo.sysobjects
    WHERE id = OBJECT_ID(N'[dbo].[prc_RBS_UserRole_Add]')
    AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
    SET NOEXEC OFF
    ELSE
    SET NOEXEC ON
    GO
    /****** Object: StoredProcedure [dbo].[prc_RBS_UserRole_Add] Script Date: 10/03/2007 12:13:45 ******/
    ALTER PROCEDURE [dbo].[prc_RBS_UserRole_Add]
    (
    @RoleID uniqueidentifier,
    @ProfileType tinyint,
    @Description nvarchar(2048),
    @Name nvarchar(256),
    @OwnerIdentifier nvarchar(256),
    @ParentUserRole uniqueidentifier,
    @LastUpdatedTimestamp datetime,
    @ShowPROTips bit,
    @VMNetworkMaximum smallint,
    @VMNetworkMaximumPerUser smallint,
    @VPNConnectionMaximum smallint,
    @VPNConnectionMaximumPerUser smallint,
    @VMNetworkVPNMaximumBandwidthInKbps bigint,
    @VMNetworkVPNMaximumBandwidthOutKbps bigint,
    @NATConnectionMaximum smallint = NULL,
    @NATConnectionMaximumPerUser smallint = NULL
    )
    AS
    BEGIN TRAN
    SET NOCOUNT ON
    DECLARE @error int
    DECLARE @IsDuplicateName bit
    DECLARE @IsRoleAlreadyPresent bit
    SELECT @IsDuplicateName = [dbo].[fn_RBS_UserRole_NameExists](@RoleID, @ParentUserRole, @Name)
    -- This is especially used in Upgrade scenarios where we are inserting Administrator role
    SELECT @IsRoleAlreadyPresent = Count(RoleID) FROM [dbo].[tbl_RBS_UserRole]
    WHERE RoleID = @RoleID
    IF (@IsDuplicateName = 0
    AND @IsRoleAlreadyPresent = 0)
    BEGIN
    INSERT INTO [dbo].[tbl_RBS_UserRole]
    ([RoleID]
    ,[ProfileType]
    ,[Description]
    ,[Name]
    ,[OwnerIdentifier]
    ,[ParentUserRole]
    ,[LastUpdatedTimestamp]
    ,[ShowPROTips]
    ,[VMNetworkMaximum]
    ,[VMNetworkMaximumPerUser]
    ,[VPNConnectionMaximum]
    ,[VPNConnectionMaximumPerUser]
    ,[VMNetworkVPNMaximumBandwidthInKbps]
    ,[VMNetworkVPNMaximumBandwidthOutKbps]
    ,[NATConnectionMaximum]
    ,[NATConnectionMaximumPerUser]
    )
    VALUES
    (
    @RoleID,
    @ProfileType,
    @Description,
    @Name,
    @OwnerIdentifier,
    @ParentUserRole,
    @LastUpdatedTimestamp,
    @ShowPROTips,
    @VMNetworkMaximum,
    @VMNetworkMaximumPerUser,
    @VPNConnectionMaximum,
    @VPNConnectionMaximumPerUser,
    @VMNetworkVPNMaximumBandwidthInKbps,
    @VMNetworkVPNMaximumBandwidthOutKbps,
    @NATConnectionMaximum,
    @NATConnectionMaximumPerUser
    )
    -- Insert flattened tree of the hierarchy for this user role
    INSERT INTO [dbo].[tbl_RBS_UserRoleHierarchy]
    SELECT RoleId, ParentRoleId, hl
    FROM view_RBS_UserRoleParentChildRelation ur where ur.RoleID = @RoleID
    SELECT @error = @@ERROR
    END
    ELSE
    BEGIN
    SET @error = 50008
    END
    SET NOCOUNT OFF
    COMMIT TRAN
    RETURN @error
    Go
    SET NOEXEC OFF
    --------------------------------------------------------------------------------------------
    IF EXISTS (SELECT * FROM dbo.sysobjects
    WHERE id = OBJECT_ID(N'[dbo].[prc_RBS_UserRole_CommonUpdate]')
    AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
    SET NOEXEC OFF
    ELSE
    SET NOEXEC ON
    GO
    /****** Object: StoredProcedure [dbo].[prc_RBS_UserRole_CommonUpdate] Script Date: 10/03/2007 12:13:45 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[prc_RBS_UserRole_CommonUpdate]
    (
    @RoleID uniqueidentifier,
    @Description nvarchar(2048),
    @OwnerIdentifier nvarchar(256),
    @Name nvarchar(256),
    @LastUpdatedTimestamp datetime,
    @ShowPROTips bit,
    @VMNetworkMaximum smallint,
    @VMNetworkMaximumPerUser smallint,
    @VPNConnectionMaximum smallint,
    @VPNConnectionMaximumPerUser smallint,
    @VMNetworkVPNMaximumBandwidthInKbps bigint,
    @VMNetworkVPNMaximumBandwidthOutKbps bigint,
    @NATConnectionMaximum smallint = NULL,
    @NATConnectionMaximumPerUser smallint = NULL
    )
    AS
    SET NOCOUNT ON
    DECLARE @error int
    DECLARE @ParentUserRole uniqueidentifier
    DECLARE @IsDuplicateName bit
    DECLARE @OldName nvarchar(256)
    SELECT @ParentUserRole = [ParentUserRole], @OldName = [Name] FROM [dbo].[tbl_RBS_UserRole]
    WHERE [RoleID] = @RoleID
    IF (@OldName = @Name)
    BEGIN
    -- We are not changing role name. This is necessary if Admin has already an SSU1 and TA created SSU1, we should not error out here
    SELECT @IsDuplicateName = 0
    END
    ELSE
    BEGIN
    SELECT @IsDuplicateName = [dbo].[fn_RBS_UserRole_NameExists](@RoleID, @ParentUserRole, @Name)
    END
    IF (@IsDuplicateName = 0)
    BEGIN
    UPDATE [dbo].[tbl_RBS_UserRole]
    SET [Description] = @Description,
    [OwnerIdentifier] = @OwnerIdentifier,
    [Name] = @Name,
    [LastUpdatedTimestamp] = @LastUpdatedTimestamp,
    [ShowPROTips] = @ShowPROTips,
    [VMNetworkMaximum] = @VMNetworkMaximum,
    [VMNetworkMaximumPerUser] = @VMNetworkMaximumPerUser,
    [VPNConnectionMaximum] = @VPNConnectionMaximum,
    [VPNConnectionMaximumPerUser] = @VPNConnectionMaximumPerUser,
    [VMNetworkVPNMaximumBandwidthInKbps] = @VMNetworkVPNMaximumBandwidthInKbps,
    [VMNetworkVPNMaximumBandwidthOutKbps] = @VMNetworkVPNMaximumBandwidthOutKbps,
    [NATConnectionMaximum] = @NATConnectionMaximum,
    [NATConnectionMaximumPerUser] = @NATConnectionMaximumPerUser
    WHERE [RoleID] = @RoleID
    SELECT @error = @@ERROR
    END
    ELSE
    BEGIN
    SET @error = 50008
    END
    SET NOCOUNT OFF
    RETURN @error
    GO
    SET NOEXEC OFF
  4. Install VMM 2012 R2 from the original installation media. In some cases, the VMM service may not start correctly. However, this behavior can be safely ignored at this point.
  5. Apply the update rollup (for example, Update Rollup 7 or 8) that corresponds to the version of VMM 2012 R2 that was previously installed. This is required for the database to function correctly.
  6. Use SQL Management Studio to run the following stored procedure against the VMM database:
    /****** Object: StoredProcedure [dbo].[prc_WLC_GetVNetworkAdapterByNicId] Script Date: 12/16/2015 2:13:12 AM ******/ 
    -- =========================================================
    -- Create date: 08/31/2007
    -- Description: Get VNetworkAdapter for a given NicId
    -- =========================================================
    ALTER PROCEDURE [dbo].[prc_WLC_GetVNetworkAdapterByNicId]
    @VNicId uniqueidentifier
    AS
    BEGIN
    DECLARE @error int
    SET @error = 0
    SET NOCOUNT ON;
    SELECT
    [Name],
    [Description],
    [OwnerIdentifier],
    [CreationTime],
    vna.[ModifiedTime],
    [Accessibility],
    [ObjectState],
    [VNicId],
    [HWProfileId],
    [ParentType],
    [VirtualNetwork],
    [MACAddressType],
    [MACAddress],
    [IPv4AddressType],
    [IPv6AddressType],
    [PortId],
    [DeviceId],
    [NetworkAdapterType],
    [VMSubnetId],
    [VMNetworkId],
    [PortClassificationId],
    [PortProfileSetId],
    [VLanEnabled],
    [VLanId],
    [VmwAdapterIndex],
    [VmwPortGroup],
    [SlotId],
    [MACSpoofingEnabled],
    [EnableGuestIPNetworkVirtualizationUpdates],
    [VMNetworkOptimizationEnabled],
    [HostId],
    [LogicalSwitchId],
    [NetworkKBytesReadTieredPerfCounterID],
    [NetworkKBytesWriteTieredPerfCounterID],
    [VMNetworkServiceSetting],
    [UsesSriov],
    [IsUsedForHostManagement],
    [IPv4Addresses],
    [IPv6Addresses],
    [DefaultGateways],
    [DNSServers],
    [TemplateNicName],
    compliance.PortClassificationComplianceErrors AS [PortClassificationComplianceErrors],
    compliance.VMNetworkComplianceErrors AS [VMNetworkComplianceErrors],
    [AccessControlListID],
    compliance.NetworkAccessControlListComplianceErrors AS [NetworkAccessControlListComplianceErrors]
    FROM dbo.tbl_WLC_VNetworkAdapter vna
    LEFT JOIN dbo.tbl_NetMan_VirtualNetworkAdapterCompliance compliance
    ON vna.VNicId = compliance.VirtualNetworkAdapterId
    WHERE VNicId = @VNicId
    SET @error = @@ERROR
    SET NOCOUNT OFF
    RETURN @error
    END
    GO
  7. Restart the VMM 2012 R2 server, and make sure that the VMM service starts successfully.


Special notes for installing on highly available VMM installations

In highly available (HA) installations of VMM, follow these steps:
  1. Stop the VMM Server service on the node where VMM is installed.
  2. Run the script from step 3 in the preceding section on the VMM database.
  3. Install VMM 2012 R2 RTM on the second node, and select an existing database to use during installation.
  4. Install SC 2012 R2 VMM UR8 on the second node.
  5. Run the post-install script from step 6 in the preceding on the VMM database.
  6. Start the VMM service on the node that you want to make active if it did not start automatically.

Properties

Article ID: 3132774 - Last Review: 23 Jan 2017 - Revision: 8

Feedback