Script to remove stale service registrations from vCenter.
search cancel

Script to remove stale service registrations from vCenter.

book

Article ID: 371365

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

  • If there is an unclean removal of the 6.x PSC node or any vCenter from ELM, we might see stale service registration entries on the vCenter which can lead to other vCenter issues.

    Steps to check if there are stale registrations:

    1. Take the service registration output
      • /usr/lib/vmware-lookupsvc/tools/lstool.py list --url https://localhost/lookupservice/sdk --no-check-cert > /tmp/psc.txt

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

      • For an environment with 2 VCs in ELM, there would be 2 service registrations for each service. If there are more than two, then these can be potentially stale ones.
    3. Check the above file(psc.txt) and identify the stale node:
      • For Example:
        • The below service registration belongs to vcsa02.domain.local
                  Name: cis.vcha.ServiceName
                  Description: cis.vcha.ServiceDescription
                  Service Product: com.vmware.cis
                  Service Type: vcha
                  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://vcsa02.domain.local:443/vcha/sdk
                          SSL trust: 
                          Endpoint Attributes:
                                  cis.common.ep.localurl: http://localhost:11080/vcha/sdk
                  Attributes:
                          com.vmware.cis.cm.HostId: 603b3XX1-fXXb-4XX2-aXX5-81517XX8f47a
      • If vcsa02 is no longer in ELM but multiple service registrations are still present. These must be removed

Environment

vCenter 7.x

vCenter 8.x

Cause

Unclean removal of a node from ELM

Resolution

    1. Shut down all the vCenter nodes in ELM and take a powered-off snapshot from the ESXi host.
    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
          • It will ask for user name and password:
          • The username would be administrator@<sso-domain>, by default it's adminstrator@sso-domain
          • Enter the password for the same.
    7. Once the script completes, we can verify the removed services by following the steps mentioned in the Issue section of this KB.

Additional Information

Note: 

The above script will remove most of the stale service registrations except a few service registrations that do not have node IDs, for example sso:groupcehck, sso:admin etc. 
These services can be unregistered either from jxplorer or by following the steps mentioned in the below KB: Error: "Could not connect to one or more vCenter Server Systems" in the vSphere Client(316404)

Attachments

service_unregister_stalenode.txt get_app