Tuesday, July 9, 2013

vmware powercli Script to get the wwn of esxi5.x host in cluster

To get the all the wwn of the host in cluster use the below simple script.



#Input Cluster
$cluster = Read-Host "Enter Cluster name"
#will fetch the list of host in the cluster
$esxi = get-cluster -name $cluster | get-vmhost
#will get the wwn of host in the cluster,
Get-VMHostHba -VMHost $esxi| Select VMHost,Device,@{N="WWN";E={"{0:X}" -f $_.PortWorldWideName}}



copy this to a notepad and Save this as script_wwn.ps1 to any location and point to the location from  vmware powercli console and run the script , as follows.

it will ask for cluster name, enter the cluster name and output will be as follows;

VMHost                                            Device                                            WWN
------                                            ------                                            ---
ESX01                                       vmhba0                                            218000E08B000186
ESX01                                       vmhba1                                            218100E08B200186

VMware Powercli command to get the esxi5.x host wwn number

Take VMware powercli console and connect to vCenter, use the following vmware power cli command to get the wwn number.

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Connect-VIServer vcenterserver (vcenter servername)

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI>Get-VMHostHba -VMHost ESXi01 | Select VMHost,Device,@{N="WWN";E={"{0:X}" -f $_.PortWorldWideName}}

output will be as follows

VMHost                                            Device                                            WWN
------                                            ------                                            ---
ESXi01                                        vmhba0                                            218000E08B000186
ESXI01                                        vmhba1                                           218100E08B200186

To get the status of HBA


Get-VMHostHba -VMHost (hostname).


Monday, July 8, 2013

Check the network link status and adapter model, firmware version in vsphere 5.X ESXI5.x

To trouble Network Link status on esxi 5.0.

Take SSH to ESXI and use following commands to list the available nic cards and link status.

~ # esxcfg-nics -l
Name    PCI           Driver      Link Speed     Duplex MAC Address       MTU    Description
vmnic0  0000:01:00.00 bnx2        Up   1000Mbps  Full   00:1a:64:76:04:10 1500   Broadcom Corporation Broadcom NetXtreme II BCM5709 1000Base-SX
vmnic1  0000:01:00.01 bnx2        Up   1000Mbps  Full   00:1a:64:76:04:11 1500   Broadcom Corporation Broadcom NetXtreme II BCM5709 1000Base-SX
vmnic2  0000:07:00.00 bnx2x       Up   10000Mbps Full   00:1a:64:76:04:14 1500   Broadcom Corporation NetXtreme II 57711 10Gigabit Ethernet
vmnic3  0000:07:00.01 bnx2x       Up   10000Mbps Full   00:1a:64:76:04:16 1500   Broadcom Corporation NetXtreme II 57711 10Gigabit Ethernet

Also you can use this as a alternatetive to get the same output.
~ # esxcli network nic list
Name    PCI Device     Driver  Link  Speed  Duplex  MAC Address         MTU  Description
------  -------------  ------  ----  -----  ------  -----------------  ----  --------------------------------------------------------------
vmnic0  0000:001:00.0  bnx2    Up     1000  Full    00:1a:64:76:04:10  1500  Broadcom Corporation Broadcom NetXtreme II BCM5709 1000Base-SX
vmnic1  0000:001:00.1  bnx2    Up     1000  Full    00:1a:64:76:04:11  1500  Broadcom Corporation Broadcom NetXtreme II BCM5709 1000Base-SX
vmnic2  0000:007:00.0  bnx2x   Up    10000  Full    00:1a:64:76:04:14  1500  Broadcom Corporation NetXtreme II 57711 10Gigabit Ethernet
vmnic3  0000:007:00.1  bnx2x   Up    10000  Full    00:1a:64:76:04:16  1500  Broadcom Corporation NetXtreme II 57711 10Gigabit Ethernet


Use the following command to get the network adapter driver, firmware, linkstatu and network adapter properties informaiton.

~ # esxcli network nic get -n vmnic0
   Advertised Auto Negotiation: true
   Advertised Link Modes: 1000baseT/Full
   Auto Negotiation: true
   Cable Type: FIBRE
   Current Message Level: -1
   Driver Info:
         Bus Info: 0000:01:00.0
         Driver: bnx2
         Firmware Version: bc 6.2.0 NCSI 2.0.11
         Version: 2.0.15g.v50.11-5vmw

   Link Detected: true
   Link Status: Up
   Name: vmnic0
   PHYAddress: 2
   Pause Autonegotiate: true
   Pause RX: false
   Pause TX: false
   Supported Ports: FIBRE
   Supports Auto Negotiation: true
   Supports Pause: true
   Supports Wakeon: true
   Transceiver: internal
   Wakeon: MagicPacket(tm)




 

Tuesday, May 14, 2013

VMware Powercli script to remove the detached device in vsphere 5, Script to remove detached device.

Simple script to remove the detached list from the esxi in the cluster. copy the below and save as remove_detached_device.ps1, run the below script on power shell.

#All host is the cluster with ESXCLI
$e1 = get-cluster -name Clustername| get-vmhost | get-esxcli
#Each ESXi in the cluster with the detached device will be removed.
foreach ($esx in $e1)
{
$esx.storage.core.device.detached.list() | Select -ExpandProperty DeviceUID | Select -First XX(no of disk) | %{ $esx.storage.core.device.detached.remove($_) }
}

 or

Get the list of device that needs to be removed from detached list and put in notepad  as detachlun.txt save in desktop. copy the below and save as remove_detached_device.ps1, run the below script on powershell.

$e1 = get-cluster -name clustername| get-vmhost | get-esxcli
$lun = get-content c:\users\test\desktop\detachlun.txt
foreach ($esx in $e1)
{
$lun | %{ $e1.storage.core.device.detached.remove($_)}
}
used with vsphere 5.0 and VMware vSphere PowerCLI 5.0.1 work perfectly, need some fine tuning to it to produce a report, once done i will update this again.


 

Thursday, March 7, 2013

vCenter server heartbeat 6.5 plugin manual registration error, vcenter serve heart beat 6.5 icon not visible in vsphere client. VCHB 6.5 plugin not registered in vsphere client.

My lab setup, upgraded vcenter server 5.0 U1 to vcenter server 5.0 U2 and vcenter server heatbeat version 6.5 used.

This is a virtual to virtual configuration for vcenter server high availability.
Installation was success full, configured heartbeat and every thing was working fine.
But heart beat icon is missing in vsphere client when i connected to vcenter.
checked if the vcenter server heart beat plugin is visible in plugin manager and i don't see it there.
searched and found this KB LINK about Registering vCenter Server Heartbeat plug-in manually

followed the steps in the KB
To manually register the vCenter Server Heartbeat plug-in manually:
  1. With the vCenter Server Heartbeat pair in sync, on the active server, open an elevated command prompt and navigate to C:\Program Files\VMware\VMware vCenter Server Heartbeat\tomcat\apache-tomcat-6.0.32\bin.
  2. Run the command:RegExt -register vchost[:port] username password hbconf.xml PublicServiceName
    Where:
    • vchost is the name/IP of the vCenter Server to which you want to register
    • port is the https port on which vCenter Server is running
    • username is the valid username with administrator privileges on the vCenter Server
    • password is the password of the user with administrator privileges on the vCenter Server
    • PublicServiceName is the public name of the vCenter Server Heartbeat server pair
  3. Copy the hbconf.xml file created at the previous step to C:\Program Files\VMware\VMware vCenter Server Heartbeat\tomcat\apache-tomcat-6.0.32\webapps\vcshb.
  4. Perform a switchover to make the Secondary server active.
  5. Repeat Steps 1-3 on the Secondary server.

Got the following error when i run the regext command, mentioned the KB

C:\Program Files\VMware\VMware vCenter Server Heartbeat\tomcat\apache-tomcat-6.0.32\bin>RegExt -register LABVC01:443 vchbtev VC@123 hbconf.xml LABVC01N1
Connecting to vCenter via: https://LABVC01/sdk/vimService
inside connect, url is: https://LABVC01/sdk/vimService
session manager was non-null
connect succeeded
server type is VirtualCenter
API version is 5.0
DomainName: lab.com
Registering as LABVC01N1.lab.com with non-local vCenter at LABVC01:443
Searching for VM with host name: LABVC01N1
Searching for VM with host name:LABVC01N1.lab.com
Found 0 matching VM(s)
No VMs matching LABVC01N1 found. Unable to register the vSphere client extension
Management through the vSphere client is not available, use the Heartbeat management Client instead
No vSphere plugin registered
disconnecting from vCenter
disconnect succeeded
disconnect succeeded


Finally the issue its a KB update needed, instead of using vcenter public name labvc01, we need to use "localhost" as follows.

instead of below.
C:\Program Files\VMware\VMware vCenter Server Heartbeat\tomcat\apache-tomcat-6.0.32\bin>RegExt -register LABVC01:443 vchbtev VC@123 hbconf.xml LABVC01N1

 user the following on the active node and switch to secondary perform the same to successfull register vcenter server heart beat to vsphere client.

C:\Program Files\VMware\VMware vCenter Server Heartbeat\tomcat\apache-tomcat-6.0.32\bin>RegExt.exe -register localhost:443 vchbtev VC@123 hbconf.xml
Connecting to vCenter via: https://localhost/sdk/vimService
inside connect, url is: https://localhost/sdk/vimService
session manager was non-null
connect succeeded
server type is VirtualCenter
API version is 5.0
DomainName: lab.com
Setting VC custom attribute for vSphere client
Removing existing web client extension com.vmware.hbwc
unregister extension succeeded
register web client extension succeeded
Removing existing extension com.vmware.heartbeat
unregister extension succeeded
register extension succeeded
Writing XML config file to hbconf.xml
Persisting vcConnection info
Persisting vCenter host: localhost:443
Persisting vCenter connection info
register extension succeeded
disconnecting from vCenter
disconnect succeeded
disconnect succeeded

That's it the vcenter heartbeat was started visible here.
login to vcenter via vsphere client and see if the plugin is visible as follows;


now got home -- inventor -- host and cluster.
click on vcenter server and in the right side you will see the heartbeat tab as follows.
 
I have requested for a kb to be updated as localhost instead of vchost, but still i dont see it is updated. mean time just for reference.
 
 
  1. With the vCenter Server Heartbeat pair in sync, on the active server, open an elevated command prompt and navigate to C:\Program Files\VMware\VMware vCenter Server Heartbeat\tomcat\apache-tomcat-6.0.32\bin.
  2. Run the command:RegExt -register vchost[:port] username password hbconf.xml PublicServiceName
  • vchost is the name/IP of the vCenter Server to which you want to register
  • port is the https port on which vCenter Server is running
  • username is the valid username with administrator privileges on the vCenter Server
  • password is the password of the user with administrator privileges on the vCenter Server
  • PublicServiceName is the public name of the vCenter Server Heartbeat server pair



  •  

    Thursday, February 21, 2013

    vCenter Server Heart Beat 6.5 with vCenter 5.0 U2 Installation verification testing results auto fail over issues.

    vCenter Server heart beat 6.5 installation verification testing.

    Not going to discuss on installation procedure, Refer installation document for pre requites and procedure, here i am going to detail only about the testing and verification that was done for vCSHB with VC 5.0 U2, in my lab.
    vCenter server heart beat provides uses 4 terms for switch over and failover process as follows.

    Managed switchover - Manually making the passive server to active and vice versa, with in the summary tab.
    Automatic switchover - Automatically triggered when there is a failure in protected services detected.
    Managed Failover -  If the passive server detect that the active server has failed, can send alerts to administrators, there administrator has to perform a manual failover.
    Automatic Failover - Automatic failover same as automatic switchover, triggers when passive detects that active is not reachable.

    1. Testing Managed Switchover\failover:

    Usually performed when there is a maintenance or reboot required for the active nodes.

    Connect vCenter server heart beat via Manage Server ( Considering that the groups are added already).
    Click on connection under server tab in summary, you will see node, select the passive node and click on make active.
    Successfull completion of switch over indicates the managed switchover completion.

    2. Automatic switchover\failover:

    Here come's the issue.

    Logged on to the active server and did a shutdown of the server and failover didn't happen, was surprised and investigate further, later got a update from vmware support saying that its expected and only in case of power failure or a server crash the auto fail over or switchover will happen.

    So incase of server shutdown, there is no auto failover.

    then powered off the VM and clicked on edit setting, under option tab, clicked on vmware tools and changed the stop option from shutdown to power off.

    then tested power off(that is unplug power cord), auto failover was successful.

    Note: as per the installation document, it is mentioned that VMware recommends against
    attempting to test failover on a properly operating Pair by methods such as unplugging a power cord. At the
    moment power is lost, any data not written to the passive server is lost. VMware recommends that all actions intended to verify operation of the passive server be performed as a switchover rather than a failover.

    Let me know your test out come or issue to discuss more.










    Saturday, February 9, 2013

    vCenter Support Assistant 5.1

    vCenter support Assistant release 24 Jan 2013,


    This is a free plugin for vcenter, to create support request, upload logs, view and update services request etc.

    Tried this at my lab and following are the one that has to noted for successful installation of this plugin.

    1. vcenter support assistant is a appliance, download it from here.
    2. easy installation and configuration refer this.
    3. Appliance need Internet access, make sure if you have proxy you have provide with the right credentials for authentication. If it dont have access to Internet then this will not work.
    4. DNS resolution is important between appliance and vcenter vice versa.
    5. Make sure you have network communication between vcenter and appliance works fine and if there is a firewall necessary ports are open.
    6. on successful installation and configuration, a icon in the vsphere client under solutions and applications will show vcenter support assistant as follows.

    7. click on that and provide the valid login for vmware support.
    8. In the diagnostics all the below should be passed for uploading logs, creating services request.
     
    

    after the appliance configuration few things to be tested to make sure the appliance works fine.

    We need to make sure if the appliance is able to communicate to the below web address and then to vcenter.
       * Connectivity to https://supportassistant.vmware.com and
         https://*.nirvanix.com

       * Connectivity to the vCenter Server and ESX/ESXi hosts
         that you wish to generate log bundles from
    you should pass the below when used wget command.

     # wget https://supportassistant.vmware.com
    --2013-02-10 07:49:08--  https://supportassistant.vmware.com/
    Resolving supportassistant.vmware.com... XX.XX.XX.XX
    Connecting to supportassistant.vmware.com|XX.XX.XX.XX|:443... connected.

    faced lot of issue while configure this, below are once that made issue to me.

    1. issue is while to try to register support assistant, error as "failed to register."
    Fix was communication between vc and appliance was not there.
    used domain account, changed that to local account worked fined.

    2. connectivity of virtual appliance to vmware.com.
    Issue with proxy connection, create a exception for this appliance and resolved.

    DNS resolution between VC and appliance.
    Internet connectivity to appliance.