Hi All,
In this post I am going to publish Commands useful for the administration of ESX server
In this post I am going to publish Commands useful for the administration of ESX server
Change Hostname
$ esxcfg-advcfg -g /Misc/HostName
-g option shows the present
hostname
Value of HostName is
esx2cluster1.testdomain.com
esxcfg-advcfg -s
esx2cluster2.testdomain.com /Misc/Hostname
-s Option sets the new Value
LIST Switches
esxcfg-vswitch –l
ADD New Switch
esxcfg-vswitch -a vSwitch5
ADD New PortGroup
esxcfg-vswitch -A "Backup Network"
vSwitch5
Uplink a NIC
esxcfg-vswitch -L vmnic4 vSwitch5
Delete a NIC
esxcfg-vswitch -U vmnic4 vSwitch5
If ESX host fails, how do you get
the logs?
Command : vm-support
To see the files collected, run: tar
-tzf /root/esx-2008-12-08—20.23.15766.tgz
Monitor : CPU, Memory, Network and
Storage
esxtop
Once esxtop is running,
press c to switch to CPU mode
press the m key to switch to
memory mode.
press the d key to switch to
storage mode.
press the n key to switch to
network mode
Create VMKERNEL PORT
To create a Service Console port at
the command line, you need to create
your port group first and then enable
it as a Service console port.
Convert the portgroup “PortGroup123”
as a service console port
Enter / Exit Maintenance mode :
To enter maintenance mode, use
this command:
vimsh -n -e
/hostsvc/maintenance_mode_enter
To exit maintenance mode, enter:
vimsh -n -e
/hostsvc/maintenance_mode_exit
Change Time on ESX ?
Run these two commands to manually
change the time on the ESX Server:
date 120715002009 (MMDDhhmmYYYY)
hwclock -systohc
Change Time on ESX ?
Run these two commands to manually
change the time on the ESX Server:
date 120715002009 (MMDDhhmmYYYY)
hwclock -systohc
Restart vCenter agent
/etc/init.d/vmware-vpxa restart
Registering a Virtual Machine via
the Command Line
vmware-cmd -s register
/vmfs/volumes/datastore/NAME/NAME.vmx
Unregistering a Virtual Machine via the
Command Line
vmware-cmd -s unregister
/vmfs/volumes/datastore/NAME/NAME.vmx
Enabling SSH on ESXi
1. On your ESXi console, press Alt-F1
to open a command prompt. Next, enter
unsupported along with your system’s
root password.
2. At the command line, edit the
inetd.conf file, which maintains information
for various
services running on your ESXi console.
The file is located at /etc/inetd.conf.
Look for the line that starts with #ssh
and remove the pound sign (#). Save the
file
to finalize your changes.
3. You now need to restart the inetd
service, because making the change in the
configuration
file does not do this automatically. To
do so, enter the following command
at the command line:
/sbin/services.sh restart
If you are running ESX 3.5 Update 4,
you will instead need to issue the
following
command to restart SSH:
kill – HUP inetd
FireWall Settings
To set the security level to low:
esxcfg-firewall --allowIncoming
--allowOutgoing
To set the security level to medium:
esxcfg-firewall --blockIncoming
--allowOutgoing
To set the security level to high:
esxcfg-firewall --blockIncoming
-blockOutgoing
After making these changes, you’ll
need to restart the VMware services in
order for the new rules to take effect:
service mgmt-vmware restart
Using the command line, add a new
vSwitch and associate it with
a service console
1. Log into the ESX Server’s console
and become the root user.
2. Find out what network adapters are
available to use for a new vSwitch:
$ esxcfg-nics –l
3. Get a list of the current vSwitches
on the ESX Server, if any exist:
$ esxcfg-vswitch –l
4. Create a new vSwitch (vSwitch 2)
$ esxcfg-vswitch -a vSwitch2
5. Once you’ve created the new
vSwitch, you’ll need to add a port group with the
label "Service Console". Make
sure you execute the command with the quotation
marks around the label:
$ esxcfg-vswitch -A "Service
Console" vSwitch2
6. Attach a vmnic from step 1 to the
new vSwitch to create an uplink. In this example we
choose to use vmnic49 because it was
not already in use:
$ esxcfg-vswitch -L vmnic49 vSwitch2
7. Create the vswif (service console)
interface on the newly created vSwitch. The -i
option allows us to specify the ESX
Server’s IP address, -p allows us to provide a
label, and the -n option specifies the
network mask:
$ esxcfg-vswif -a vswif0 -i
172.10.45.11 -n 255.255.255.0 -p "Service Console"
Create a VMkernelPort on vSwitch via
command line:
esxcfg-vmknic --add --ip=x.x.x.x
--netmask=x.x.x.x portgroup
esxcfg-vmknic --enable portgroup
Example:
esxcfg-vswitch –l (List vSwitch)
esxcfg-vswitch –a vSwitch1 (Create
vSwitch)
esxcfg-vswitch –A “ISCSI”
vSwitch1 (Create port group)
esxcfg-vmknic -a -i 10.10.10.33 -n
255.255.255.0 ISCSI
(Assign IP)
esxcfg-vmknic –l
(List VmkernelPort
Enable vMotion on vSwitch via command
line:
Enable a VirtualNic to be used as the
vMotion NIC.
Enable and Disable vMotion via SSH
connection without VirtualCenter
vmware-vim-cmd hostsvc/vmotion/vnic_set
[vnic] vmware-vim-cmd
hostsvc/vmotion/vnic_set vmk0 Disabling
vMotion Port: vmware-vim-cmd
hostsvc/vmotion/vnic_unset [vnic]
vmware-vim-cmd
hostsvc/vmotion/vnic_unset vmk0
Check vSwitch vMotion configuration:
vmware-vim-cmd
hostsvc/vmotion/netconfig_get



No comments:
Post a Comment