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

Saturday, September 16, 2017

What are the mode, we can configure for multipath?

Saturday, September 16, 2017 0

We have 2 types of mode we can configure the multipath.

Redundancy

DM-Multipath can provide failover in an active/passive configuration. In an active/passive configuration, only half the paths are used at any time for I/O. If any element of an I/O path (the cable, switch, or controller) fails, DM-Multipath switches to an alternate path.

Improved Performance

DM-Multipath can be configured in active/active mode, where I/O is spread over the paths in a round-robin fashion. In some configurations, DM-Multipath can detect loading on the I/O paths and dynamically re-balance the load.

Simple Powercli Code to Consolidate all vms which are Consolidation Needed

Saturday, September 16, 2017 0

Powercli Code to Consolidate all  vms  which are Consolidation Needed

Use the below command.

Get-VM |
Where-Object {$_.Extensiondata.Runtime.ConsolidationNeeded} |
ForEach-Object {
  $_.ExtensionData.ConsolidateVMDisks()
}

How to change the Lockdown Mode on all hosts managed by vCenter

Saturday, September 16, 2017 0

change the Lockdown Mode on all hosts managed by vCenter

Follow the below steps to achieve the requirement:

$vCenter = 'vCenterServer_Name_or_IP_address'
Connect-VIServer $vCenter
 $Scope = Get-VMHost #This will change the Lockdown Mode on all hosts managed by vCenter, amend this if you need to foreach ($ESXhost in $Scope) {
 (get-vmhost $ESXhost | get-view).ExitLockdownMode() # To DISABLE Lockdown Mode
 # (get-vmhost $ESXhost | get-view).EnterLockdownMode() # To ENABLE Lockdown Mode
 }
Disconnect-VIServer -Server $vCenter -Confirm:$false

List all orphaned vmdk on all datastores in all VC's at a time by using script

Saturday, September 16, 2017 0
Use the below script to achieve :

# Just paste the code in text file and rename with .ps1
# Purpose : List all orphaned vmdk on all datastores in all VC's
#Here fwvc950","fwvc951","fwvc952","flsan01 are my vcentrer

$arrayVC = "fwvc950","fwvc951","fwvc952","flsan01"
$OutputFile = "C:\OrphanedVMDK.txt"

Foreach ($strVC in $arrayVC)

{
    Connect-VIServer $strVC
    $arrUsedDisks = Get-VM | Get-HardDisk | %{$_.filename}
    $arrDS = Get-Datastore
    Foreach ($strDatastore in $arrDS)
    {
       $strDatastoreName = $strDatastore.name
       Write-Host $strDatastoreName
       $ds = Get-Datastore -Name $strDatastoreName | %{Get-View $_.Id}
       $fileQueryFlags = New-Object VMware.Vim.FileQueryFlags
       $fileQueryFlags.FileSize = $true
       $fileQueryFlags.FileType = $true
       $fileQueryFlags.Modification = $true
       $searchSpec = New-Object VMware.Vim.HostDatastoreBrowserSearchSpec
       $searchSpec.details = $fileQueryFlags
       $searchSpec.sortFoldersFirst = $true
       $dsBrowser = Get-View $ds.browser
       $rootPath = "["+$ds.summary.Name+"]"
       $searchResult = $dsBrowser.SearchDatastoreSubFolders($rootPath, $searchSpec)
       $myCol = @()
       foreach ($folder in $searchResult)
       {
          foreach ($fileResult in $folder.File)
          {
             $file = "" | select Name, FullPath   

             $file.Name = $fileResult.Path

             $strFilename = $file.Name

             IF ($strFilename)

             {

             IF ($strFilename.Contains(".vmdk"))

             {

             IF (!$strFilename.Contains("-flat.vmdk"))

             {

             IF (!$strFilename.Contains("delta.vmdk"))         

             {

                $strCheckfile = "*"+$file.Name+"*"

             IF ($arrUsedDisks -Like $strCheckfile){}

             ELSE

             {            

             $strOutput = $strDatastoreName + " Orphaned VMDK Found: " + $strFilename

             $strOutput | Out-File $Outputfile -width 150 -Append

             }            

             }

             }         

             }

             }

          }

       }      

   }  

}

Friday, September 15, 2017

List the types of DB supported by openldap?

Friday, September 15, 2017 0

Below list of DBs are supported by openldap

bdb

Berkeley DB instance definition. This is the recommended database back-end type. It uses the Sleepycat Berkeley DB to store data.


ldbm

LDAP DBM type. Easy to configure, but not as durable as the bdb database back-end type. It also uses Berkeley DB, GNU DBM, and MDBM to store data.


sql

Uses a SQL database back-end to store data.


ldap

Used as a proxy to forward incoming requests to another LDAP server.

meta

Metadirectory database back-end. It is an improvement on the LDAP-type back-end. It performs LDAP proxying with respect to a set of remote LDAP servers.

monitor

Stores information about the status of the slapd daemon.

null

Operations to this database type succeed, but do nothing. This is the equivalent of sending stuff to /dev/null in Linux/UNIX.

passwd

Uses the system’s plain-text /etc/passwd file to serve user account information.

tcl

An experimental back-end that uses a Tcl interpreter that is embedded directly into slapd.

perl

Uses a Perl interpreter that is embedded directly into slapd.

Rescan All HBA of all ESXI in a simple way.

Friday, September 15, 2017 0

Rescan All HBA of all ESXI in a simple way.

For a Specific Cluster:

get-cluster -name “MY CLUSTER” | get-vmhost | Get-VMHostStorage -RescanAllHBA

All Hosts in VC:

get-vmhost | Get-VMHostStorage -RescanAllHBA

Thursday, September 14, 2017

Repairing Linux ext2 or ext3 FS

Thursday, September 14, 2017 0

Repairing Linux ext2 or ext3 file system

1) File system must be unmounted, you cannot repair it while it is running. Take system down to runlevel one (make sure you run all command as root user):# init 1

2)Unmount file system, for example if it is /home (/dev/sda3) file system then type command

# umount /home OR# umount /dev/sda3


3) Now run fsck on the partition: 

# fsck /dev/sda3

However be sure to specify the file system type using -t option. Recenly one of our sys admin run the command on ext3 file system w/o specifying file system. Result was more corruption as fsck by default assumes ext2 file system.

 # fsck -t ext3 /dev/sda3
OR# fsck.ext3 /dev/sda3


Tip if you don't know your file system type then typing mount command will display file system type.

fsck will check the file system and ask which problems should be fixed or corrected. If you don't wanna type y every time then you can use pass -y option to fsck


# fsck -y /dev/sda3

Please not if any files are recovered then they are placed in /home/lost+found directory by fsck command.

4) Once fsck finished, remount the file system:

# mount /home

5) Go to multiuser mode# init 3

Read man page of fsck for more.

How tcpdump command is used to find out the network switch information which is connected to the physical server?

Thursday, September 14, 2017 0
Run the below tcpdump command on physical server.

[root@testserver001 ~]# tcpdump -nn -v -i eth0 -s 1500 -c 1 'ether[20:2] == 0x2000'
tcpdump: WARNING: eth0: no IPv4 address assigned
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 1500 bytes
05:51:39.526913 CDPv2, ttl: 180s, checksum: 692 (unverified), length 434
        Device-ID (0x01), length: 21 bytes: 'TEST01.switch.com'
        Version String (0x05), length: 295 bytes:
          Cisco Internetwork Operating System Software
          IOS (tm) s72033_rp Software (s72033_rp-ADVIPSERVICESK9_WAN-M), Version 12.2(18)SXF17a, RELEASE SOFTWARE (fc1)
          Technical Support: http://www.cisco.com/techsupport
          Copyright (c) 1986-2010 by cisco Systems, Inc.
          Compiled Tue 02-Mar-10 01:50 by tinhuang
        Platform (0x06), length: 16 bytes: 'cisco WS-C6506-E'
        Address (0x02), length: 13 bytes: IPv4 (1) 159.166.128.131
        Port-ID (0x03), length: 16 bytes: 'FastEthernet3/12'
        Capability (0x04), length: 4 bytes: (0x00000029): Router, L2 Switch, IGMP snooping
        VTP Management Domain (0x09), length: 0 byte: ''
1 packets captured
3 packets received by filter
0 packets dropped by kernel