This Blog is to share our knowledge and expertise on Linux System Administration and VMware Administration

Wednesday, October 14, 2015

Default route in Linux by command

Wednesday, October 14, 2015 0
By using below command we can add the default route -Temporarily.

#route add gw IP Address Netmask ethx up 

IP Address = Gateway IP Address of your network (ex 192.168.0.1)
Netmask = Your network mask (255.255.255.0)
ethx - Gateway Interface

# route add gw 192.168.0.1 255.255.255.0 eth1 up

How to find the older files & delete in Linux & Unix

Wednesday, October 14, 2015 0
If we have more files in a folder, the normal ls command will not work.

Below command is used to find out the old files.

List the files - 30 days before file

#find /location/to/find/files -type f -mtime +30 -user test -ls  

Delete the files

#find /location/to/find/files -type f -mtime +30 -user test -exec rm {} \

/location/to/find/files - which location you want to find the files
mtime - mention the days, command will find the files older than that days (here 30)
user - if we have more files, mention the user as well

How to replace the failed array disk on Software Raid

Wednesday, October 14, 2015 0
#Follow the below steps to configure and add the new disk to array.

#We can use this command to create the partitions from the other disk(sda) to (sdb):

(testvm:root)$sfdisk -d /dev/sda | sfdisk /dev/sdb
Checking that no-one is using this disk right now ...
OK

Disk /dev/sdb: 8924 cylinders, 255 heads, 63 sectors/track

sfdisk: ERROR: sector 0 does not have an msdos signature
 /dev/sdb: unrecognized partition table type
Old situation:
No partitions found
New situation:
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
/dev/sdb1   *        63    208844     208782  fd  Linux raid autodetect
/dev/sdb2        208845  62990864   62782020  fd  Linux raid autodetect
/dev/sdb3             0         -          0   0  Empty
/dev/sdb4             0         -          0   0  Empty
Successfully wrote the new partition table

Re-reading the partition table ...

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes:  dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
(testvm:root)$

#We have to run the below command to check if both hard drives have the same partitions.

(testvm:root)$ /sbin/fdisk -l

Disk /dev/sda: 36.4 GB, 36401479680 bytes
255 heads, 63 sectors/track, 4425 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   fd  Linux raid autodetect
/dev/sda2              14        3921    31391010   fd  Linux raid autodetect

Disk /dev/sdb: 73.4 GB, 73407488000 bytes
255 heads, 63 sectors/track, 8924 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1          13      104391   fd  Linux raid autodetect
/dev/sdb2              14        3921    31391010   fd  Linux raid autodetect

Disk /dev/md1: 32.1 GB, 32144293888 bytes
2 heads, 4 sectors/track, 7847728 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md1 doesn't contain a valid partition table

Disk /dev/md0: 106 MB, 106823680 bytes
2 heads, 4 sectors/track, 26080 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md0 doesn't contain a valid partition table
(testvm:root)$

#Next we should add /dev/sdb1 to /dev/md0 and /dev/sdb2 to /dev/md1 using below commands.

(testvm:root)$ mdadm --manage /dev/md0 --add /dev/sdb1
mdadm: added /dev/sdb1
(testvm:root)$ mdadm --manage /dev/md1 --add /dev/sdb2
mdadm: added /dev/sdb2
(testvm:root)$

#Now both arrays (/dev/md0 and /dev/md1) will start synchronizing.

#It will take longer time depending on amount of data to synchronize.

#output should be as below when its finished.


(testvm:root)$ cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[1] sda1[0]
      104320 blocks [2/2] [UU]

md1 : active raid1 sdb2[1] sda2[0]
      31390912 blocks [2/2] [UU]

unused devices: <none>
(testvm:root)$


#Start the grub shell to add the grub bootblock to the replaced disk

#You can use the grub geometry command to view disk information:

(testvm:root)$ grub
Probing devices to guess BIOS drives. This may take a long time.


    GNU GRUB  version 0.97  (640K lower / 3072K upper memory)

 [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename.]
grub> geometry (hd0)
geometry (hd0)
drive 0x80: C/H/S = 4425/255/63, The number of sectors = 71096640, /dev/sda
   Partition num: 0,  Filesystem type is ext2fs, partition type 0xfd
   Partition num: 1,  Filesystem type unknown, partition type 0xfd
grub> geometry (hd1)
geometry (hd1)
drive 0x81: C/H/S = 8924/255/63, The number of sectors = 143374000, /dev/sdb
   Partition num: 0,  Filesystem type is ext2fs, partition type 0xfd
   Partition num: 1,  Filesystem type unknown, partition type 0xfd

#Add the bootblock to /dev/sdb:

grub> device (hd1) /dev/sdb
device (hd1) /dev/sdb
grub> root (hd1,0)
root (hd1,0)
 Filesystem type is ext2fs, partition type 0xfd
grub> setup (hd1)
setup (hd1)
 Checking if "/boot/grub/stage1" exists... no
 Checking if "/grub/stage1" exists... yes
 Checking if "/grub/stage2" exists... yes
 Checking if "/grub/e2fs_stage1_5" exists... yes
 Running "embed /grub/e2fs_stage1_5 (hd1)"...  15 sectors are embedded.
succeeded
 Running "install /grub/stage1 (hd1) (hd1)1+15 p (hd1,0)/grub/stage2 /grub/grub.conf"... succeeded
Done.
grub> quit
quit
(testvm:root)$

#That's it, you have successfully replaced /dev/sdb!

How to change the active ethernet interface on Bond configuration

Wednesday, October 14, 2015 0
By Using the below command we can change the active ethernet interface settings on Bond configuration

#ifenslave -c bondx ethx

ethx - which interface you want to make an active
bondx - which bond configuration

HA Advanced Options

Wednesday, October 14, 2015 0
Offcourse, there are lot let me share few important and useful HA advance options.

     das.failuredetectiontime – This setting was introduced in VirtualCenter 2.0.2 to allow the default interval for HA detection to be changed. Previously this was hard-coded so that if a host did not respond in 15 seconds then it would be considered failed. This setting is in milliseconds and can be changed from the default of 15000 milliseconds. For example if you wanted to increase this to 60 seconds you would set it to 60000 milliseconds (don’t use commas in the number).

    das.poweroffonisolation – This setting is the default cluster setting for virtual machine isolation response that is set through the VI Client. The default is true which powers off virtual machines in case of an HA event. Setting this to false leaves the virtual machine still running on the isolated host when an HA event occurs.

    das.isolationaddress – This setting was introduced in VirtualCenter 2.0.2 and is the IP address that HA will ping to determine if a host is isolated from the network. If this option is not specified, the default gateway of the console network is used. This default gateway has to be some reliable address that is known to be available, so that the host can determine if it is isolated from the network. Using multiple isolation response addresses gives HA a potentially more accurate picture of the network connectivity of a host. There may be situations in which a single isolation address would indicate that a host is in a state of complete isolation from the network, but access to additional isolation addresses would show that only a partial network failure has occurred. You can have a total of 10 isolation addresses set using the following format das.isolationaddressX, where X is a number 1-10. If you use this setting you should change the default failure detection time (das.failuredetectiontime ) to 20 seconds or greater. In general the more isolation response addresses configured, the longer you should make the timeout to ensure that proper failure detection can occur.

    das.usedefaultisolationaddress – By default, HA uses the default gateway of the console network as an isolation address. This attribute specifies whether that should be used or not, the values are true or false. If you are using the das.isolationaddress setting then this should be set to false.

    das.isolationShutdownTimeout – The amount of time that HA waits to gracefully shutdown a VM if the “Shutdown VM” option is selected for isolation response. The default is 300 seconds.

    das.defaultfailoverhost – If this is set, HA will first try to fail over hosts to the host specified by this option. This is useful if you want to utilize one host as a spare failover host, but is not usually recommended, because HA tries to utilize all available spare capacity among all hosts in the cluster. If the specified host does not have enough spare capacity, VMware HA tries to fail over the virtual machine to any other host in the cluster that has enough capacity.

    das.failuredetectioninverval – This setting was introduced in vCenter Server 2.5 Update 2 and is the interval that is used for heartbeat detection amongst ESX hosts. The default is that a host will check for a heartbeat every second (1000 milliseconds), you may want to increase this if your hosts are on remote or high latency networks.

    das.allowVmotionNetworks – This setting was introduced in vCenter Server 2.5 Update 2 specifically for ESXi which does not utilize a vswif service console network like ESX hosts and instead uses a special management network and will allow a NIC that is used for VMotion networks to be used for HA also. This is to allow a host that has only has a single NIC configured for the both the service console and VMotion combined to be used for HA; by default VMotion networks are ignored.

    das.allowNetwork – This setting was introduced in vCenter Server 2.5 Update 2 and allows the use of port group names to control the networks used for HA. Starting with vCenter Server 2.5 Update 2, HA has an enhanced network compliance check to increase cluster reliability. This enhanced network compliance check helps to ensure correct cluster-wide heartbeat network paths. This also helps prevent delayed failure detection and “Split Brain” conditions in certain scenarios. When configured, the HA cluster only uses the specified networks for HA communication. You can set the value to be “Service Console 2″ or “Management Network” to use the networks associated with those port group names in the networking configuration. You can set this using the following format, das.allowNetworkX where X is a number starting with 0, i.e. das.allowNetwork0 = “Service Console” or daas.allowNetwork1 = “Service Console 2″. More detail on this setting can be found in the following VMware KB articles: http://kb.vmware.com/kb/1006606 and http://kb.vmware.com/kb/1006541

    das.vmMemoryMinMB – Specifies the minimum amount of memory (in megabytes) sufficient for any virtual machine in the cluster to be usable. This value is used only if the memory reservation is not specified for the virtual machine and is used for HA admission control and calculating the current failover level. If no value is specified, the default is 256MB, reducing this can help prevent the warning about insufficient resources and the red exclamation mark that indicates a cluster does not have sufficient failover capacity.

    das.vmCpuMinMHz – Specifies the minimum amount of CPU (in megahertz) sufficient for any virtual machine in the cluster to be usable. This value is used only if the CPU reservation is not specified for the virtual machine and is used for HA admission control and calculating the current failover level. If no value is specified, the default is 256MHz, reducing this can help prevent the warning about insufficient resources and the red exclamation mark that indicates a cluster does not have sufficient failover capacity.

    das.bypassNetCompatCheck – This setting was introduced in vCenter Server Update 3 to provide the ability to disable the HA enhanced network compliance check that was introduced in vCenter Server 2.5 Update 2. The enhanced network compliance check helps to ensure correct cluster-wide heartbeat network paths. This setting allows you to bypass this check to prevent HA configuration problems. To bypass the check, add das.bypassNetCompatCheck=true to the HA advanced settings.
    das.iostatsInterval – Used for virtual machine monitoring, occasionally virtual machines that are still functioning properly stop sending heart-beats. To avoid unnecessarily resetting such virtual machines, the VM Monitoring service also monitors a virtual machine’s I/O activity. If no heartbeats are received within the failure interval, the I/O stats interval (a cluster-level attribute) is checked. The I/O stats interval determines if any disk or network activity has occurred for the virtual machine during the previous two minutes (120 seconds). If not, the virtual machine is reset. This default value (120 seconds) can be changed using this setting.

To configure HA with any of these advanced settings just follow the below steps:

  •     Select your cluster in the VI Client and right-click on it and select “Edit Settings”.
  •     Select VMware HA in the left hand pane.
  •     In the right hand pane click the “Advanced Options” button.
  •     When the Advanced Options window is display double-click on one of the blank fields under the Options column to edit it.
  •     Enter an option name (i.e. das.failuredetectiontime) and hit Enter.
  •     Double-click on the field next to it in the Value column and edit a value (i.e. 60000) and hit Enter.
  •     Repeat this procedure for any additional options that you want to add and click the OK button.

Overview of VMware Tools

Wednesday, October 14, 2015 0
VMware Tools is a suite of utilities that enhances the performance of the virtual machines guest operating system and improves management of the virtual machine. Without VMware Tools installed in your guest operating system, guest performance lacks important functionality. Installing VMware Tools eliminates or improves these issues:

    Low video resolution
    Inadequate color depth
    Incorrect display of network speed
    Restricted movement of the mouse
    Inability to copy and paste and drag-and-drop files
    Missing sound
    Provides the ability to take quiesced snapshots of the guest OS
    Synchronizes the time in the guest operating system with the time on the host
    Provides support for guest-bound calls created with the VMware VIX API

VMware Tools includes these components:

    VMware Tools service
    VMware device drivers
    VMware user process
    VMware Tools control panel

VMware Tools is provided in these formats:

    ISOs (contain .tar files): These are packaged with the product and are installed in a number of ways, depending upon the VMware product and the guest operating system installed in the virtual machine. For more information, see the Installing VMware Tools section. VMware Tools provides a different ISO file for each type of supported guest operating system: Windows, Linux, NetWare, Solaris, and FreeBSD.
    Operating System Specific Packages (OSPs): These are downloaded and installed from the command line on an ESXi/ESX host. VMware Tools is available as separate downloadable, light-weight packages that are specific to each supported Linux operating system and VMware product. OSPs are an alternative to the existing mechanism for installing VMware Tools and only support Linux systems running on ESXi/ESX. To download OSPs and to find important information and instructions.

Installing VMware Tools

The steps to install VMware Tools vary depending on your VMware product and the guest operating system you have installed.

For specific instructions to install, upgrade, and configure VMware Tools, see one of these documents on the VMware Documentation

    VMware Workstation User's Manual
    VMware ESX Basic System Administration guide
    VMware Server User’s Guide
    VMware Player in-product help

    Note: Select Help > Help Topics from the VMware Player product interface to access the online help.

Tuesday, October 13, 2015

Single line Powercli command to find whether SSH service Running or not in all your ESXI ...

Tuesday, October 13, 2015 0
Powercli command to find whether SSH service is Running on ESXI.

Get-VMHost | Get-VMHostService | Where { $_.Key -eq "TSM-SSH" } |select VMHost, Label, Running

or


Get-VMHost | Foreach {
  Start-VMHostService -HostService ($_ | Get-VMHostService | Where { $_.Key -eq "TSM-SSH"} )
}

Hope it is useful !

Powercli command for Changing networkadapter of required vms at time

Tuesday, October 13, 2015 0
#  Create a text file with list of vms that you want to change network adapter

$VMlist = Get-content C:\Users\ap_vn1651\Documents\VMlist.txt
Get-VM $VMlist | Get-NetworkAdapter | set-networkadapter -type vmxnet3 -confirm:$false