Virtual
Machine Management Commands
-
Command: #Services.sh restart
This command will restart all the management agents and services
running on the host. You should see each service stopping and then
being started.
-
Command: #vim-cmd vmsvc
This is the most useful command for emergency maintenance and takes
several extensions.
-
Command: #vim-cmd vmsvc/getallvms
This command will display the list of virtual machines registered on
the ESX/ESXi host (Powered Off or Powered On). The list contains
additional information such as vmid, name of the virtual machine,
Guest OS type, VM HW version, location of the virtual machine
configuration file and annotations.
Vmid Name File Guest OS Version Annotation
-
Command: #vim-cmd vmsvc/power.getstate <vmid>
This command will display the power status of the virtual machine in
question.
-
Command: #vim-cmd vmsvc/power.off <vmid>
This command will power off the virtual machine in question.
-
Command: #vim-cmd vmsvc/power.on <vmid>
This command will power on the specified virtual machine and boot the
Guest OS
-
Command: #vim-cmd vmsvc/power.reboot <vmid>
This command will reboot the guest operating system.
-
Command: #vim-cmd vmsvc/power.reset <vmid>
This command will reset the virtual machine in question.
-
Command: #vim-cmd vmsvc/power.shutdown <vmid>
This command will shutdown the guest operating system running inside
the virtual machine.
-
Command: #vim-cmd vmsvc/power.suspend <vmid>
This command will suspend the virtual machine in question.
-
Command: #vim-cmd vmsvc/power.suspendresume <vmid>
This command will revert the virtual machine from suspended state to
normal state.
-
Command: #vim-cmd vmsvc/power. Hibernate <vmid>
This command will place the guest operating system in standby mode.
-
Command: #vim-cmd vmsvc/snapshot.create
Usage: snapshot.create <vmid> [snapshotName]
[snapshotDescription] [includeMemory] [quiesced]
This command is used to take snapshot of the virtual machine.
Virtual
Networking Commands
-
How to create a standard virtual switch.
#esxcfg-vswitch
-a <vswitch name>
EX: [root@server
root]# esxcfg-vswitch –a vSwitch1
-
How to add a port group to the virtual switch
#esxcfg-vswitch
-A <Portgroup name> <vswitch name>
EX: [root@server
root]# esxcfg-vswitch –A “Service Console” vSwitch1
-
How to check whether the specified virtual switch exists or not
#esxcfg-vswitch
-c <vswitch name>
-
How to check whether the specified portgroup exists or not
#esxcfg-vswitch
-C <portgroup name>
Output: Will print 1 if the virtual switch exists and 0 if not
-
How to remove the virtual switch
#esxcfg-vswitch
-d <vswitch name>
Output: Remove the virtual switch. This command fails if any
ports on the virtual switch are in use by vmkernel networks or
virtual machines.
-
How to remove a port group from virtual switch?
#esxcfg-vswitch
-D <port group> <vswitch name>
Output: Removes the port group. This command fails if any port
group on the virtual switch is in use
-
How to add an uplink adapter to the virtual switch ?
#esxcfg-vswitch
-L <physical_nic> <vswitch_name>
Des: Running the
command with this option attaches a new unused physical network
adapter to a virtual switch
EX: [root@server
root]# esxcfg-vswitch –L vmnic1 vSwitch1
-
How to list all virtual switches and their port groups?
#esxcfg-vswitch
-l
-
How to remove an uplink adapter from the virtual switch?
#esxcfg-vswitch
-U <physical_nic> <vswitch_name>
Des: Remove an
uplink adapter from a virtual switch. An uplink adapter corresponds
to a physical Ethernet adapter to which the virtual switch is
connected. If you remove the last uplink adapter, you lose physical
network connectivity for that switch.
-
How to set VLAN ID for a specific port group?
#esxcfg-vswitch
-v <vlan_id> --pg <portgroup_name> <vswitch_name>
EX: [root@server
root]# esxcfg-vswitch -v <VLAN> -p “Service Console”
vSwitch0
Des: Set the VLAN
ID for a specific port group of a virtual switch. Setting the option
to 0 disables the VLAN for this port group. If you specify this
option, you must also specify the --portgroup
option.
esxcfg-vmknic
The esxcfg-vmknic
command adds, deletes, and modifies VMkernel network interfaces. In
vSphere 5, equivalent ESXCLI commands are available.
-
How to add a vmkernel nic to the system?
#esxcfg-vmknic
-a -i <ip_address> -n <netmask> <portgroup_name>
EX: esxcfg-vmknic
-a –i 192.168.5.6 –n 255.255.255.0 "VMkernel"
Des:
Add a VMkernel NIC to the system. When the command completes
successfully, the newly added VMkernel NIC is enabled.
-
How to remove a vmkernel nic?
#esxcfg-vmknic
-d <vmknic_name>
EX: esxcfg-vmknic
-d "VMkernel"
-
How to disable a specified vmkernel nic?
#esxcfg-vmknic
--D --interface-name=<nic> --enabled=[true| false]
-
How to enable a specified vmkernel nic?
#esxcfg-vmknic
-e <vmknic_name>
-
How to list all vmkernel nics?
#esxcfg-vmknic
-l
EX: esxcfg-vmknic
-lInterface Port Group
IP Address Netmask
Broadcast MAC Address
MTU TSO MSS Enabled
vmk0 VMkernel 192.168.5.5 255.255.255.0 192.168.5.255 00:51:47:3c:20:cc 1500 40960 true
vmk0 VMkernel 192.168.5.5 255.255.255.0 192.168.5.255 00:51:47:3c:20:cc 1500 40960 true
Esxcfg-route
Setting the vmkernel Default Gateway
-
How to set vmkernel default gateway?
#esxcfg-route
-a 19.2.168.100.0 255.255.255.0 192.168.0.1
Or
#esxcfg-route
-a default 192.168.0.1
-
How to delete a vmkernel gateway?
#esxcfg-route
-d 192.168.100.0/24 192.168.0.1
-
How to list vmkernel gateway configured?
#esxcfg-route
-l
Esxcfg-vswif
Used
to configure service console networking in 4.x systems. Not needed
and not available in the ESXi 5.x ESXi Shell
-
How to display service console interface?
#esxcfg-vswif
-l
EX:
esxcfg-vswif
-l
Name Port Group IP Address Netmask Broadcast Enabled DHCP
vswif0 Service Console 192.168.5.5 255.255.255.0 192.168.5.255 true false
Name Port Group IP Address Netmask Broadcast Enabled DHCP
vswif0 Service Console 192.168.5.5 255.255.255.0 192.168.5.255 true false
-
How to add a new service console networking interface?
#esxcfg-vswif
-a -p “service console” -i <ip address> -n <netmask>
vswif0
-
How to delete a service console networking interface?
#esxcfg-vswif
-d vswif0
No comments:
Post a Comment