Script to remove stale service registrations from vCenter Server.
search cancel

Script to remove stale service registrations from vCenter Server.

book

Article ID: 371365

calendar_today

Updated On:

Products

VMware vCenter Server 7.0 VMware vCenter Server 8.0

Issue/Introduction

Improper decommissioning of the 6.x PSC node or any vCenter from ELM might leave stale service registrations on the vCenter which leads to other issues.

Steps to check stale registrations on vCenter Server:

  1. List of the services registered within the Platform Services Controller.
    • /usr/lib/vmware-lookupsvc/tools/lstool.py list --url https://localhost/lookupservice/sdk --no-check-cert > /tmp/psc.txt

  2. Validate the number of service registrations for each vCenter:
    • less /tmp/psc.txt | grep -i "Service Type: " | sort | uniq -c

    • For an environment with two vCenters in Enhanced Linked Mode (ELM), there would be two service registrations for each service. If there are more than two, then these can be potentially stale ones.
  3. Identify a valid registration against stale registration using /etc/vmware/install-defaults/vmdir.ldu-guid to compare Node ID from above file (/tmp/psc.txt):
    • For Example:
      • The below service registration belongs to the mentioned Node ID.
                Name: ServiceName
                Description: ServiceDescription
                Service Product: com.vmware.cis
                Service Type: ServiceType
                Service ID: 1f10XX8f-438d-XXb-90f8-47e7d6XXa94f
                Site ID: default-first-site
                Node ID: b2b7XX1e-5XX9-4a55-88XX-699fXXeb1d6f
                Owner ID: [email protected]
                Version: 1.0
                Endpoints:
                        Type: com.vmware.cis.data.provider
                        Protocol: vmomi
                        URL: https://vcsa.example.org:443/sdk
                        SSL trust: 
                        Endpoint Attributes:
                                cis.common.ep.localurl: http://localhost:11080/sdk
                Attributes:
                        com.vmware.cis.cm.HostId: 603b3XX1-fXXb-4XX2-aXX5-81517XX8f47a
    • The Node ID should match the entry in /etc/vmware/install-defaults/vmdir.ldu-guid.

Environment

VMware vCenter Server 7.x

VMware vCenter Server 8.x

Cause

Improper decommissioning of external PSC or vCenter in Enhanced Linked Mode (ELM).

Resolution

Follow the below steps to remove the stale service registrations from vCenter.

    1. Shut down all the vCenter nodes in ELM and take a powered-off snapshot from each vCenter VM.
    2. Power on all the vCenters.
    3. Log in to any one of the vCenter's SSH session.
    4. Validate the incorrect node by checking the URL from the service registration output.
    5. Note down the Node ID for the incorrect service registration.
    6. Run the attached script attached to this KB.
      • Steps to run the script:
        • ./service_unregister_stalenode.sh <Node_ID of stale node>
          • Example: ./service_unregister_stalenode.sh b2b7641e-5XX9-4a55-8XX9-699fd9XX1d6f
        • You will be prompted for the username/password.
    7. Validate the stale service registrations have been removed successfully.

Additional Information

Note: This script will not remove service registrations that do not have node IDs; example: sso:groupcheck, sso:admin.

These services can be unregistered using jXplorer or by following the steps mentioned in Error: "Could not connect to one or more vCenter Server Systems" in the vSphere Client

Attachments

service_unregister_stalenode.txt get_app