Monday, March 11, 2013

Basics of Server Cluster

One of my dearest friend asked me to write a blog on cluster and the hidden technology beneath. So, let's talk about cluster and understand it..

First of all "What is Microsoft Server Cluster"?
Server cluster is a group of independent servers running Windows Server Operating System and working together to provide high availability of services for the client. In case of any failure the services are redirected to other node in the cluster and share the work load. You will find more detailed info on TechNet

OK, now we know the terminology of what cluster means and what it does. So, how does it really works? It is quite interesting how the cluster technology evolved and improved since Windows 2000. Let's us understand the basic components on which cluster works and provide services:
  • Cluster IP Address.
  • Cluster Name
  • Cluster Disk
  • Cluster Node
  • Cluster Application

Cluster IP Address:
As we all know, if you want your machine to communicate with other machines on the network, it has to have an IP address. Cluster IP address resource is the prime component and helps cluster to communicate with clients as well as other nodes/servers part of the cluster. 

Cluster Name:
Like any other machine on your domain you need a name for your cluster to register itself in AD to have an identify in the your domain and provide the services. Cluster Name resource has dependency on cluster IP address resource and act as bridge for communication. So, its quite logical if Cluster IP address resources goes down, cluster Name resource will go down as well.

Cluster Disk:
Ok, so now you have a Cluster IP & Name resource for network communication but what can it communicate? End user data? Print Data? Or your customer application code? Or Cluster configuration?

What's Quorum disk?
The quorum resource plays a crucial role in the operation of the cluster. In every cluster, a single resource is designated as the quorum resource. A quorum resource can be any resource with the following functionality:
·         It offers a means of persistent arbitration. Persistent arbitration means that the quorum resource must allow a single node to gain physical control of the node and defend its control. For example, Small Computer System Interface (SCSI) disks can use Reserve and Release commands for persistent arbitration.
·         It provides physical storage that can be accessed by any node in the cluster. The quorum resource stores data that is critical to recovery after there is a communication failure between cluster nodes

What's Data Disk?
Now, you got data for you cluster but you surely need data for other applications that's configured to provide services through Cluster. Forex: Disks for File Services or Print Services.


Cluster Node:

Now, we have an IP, a Computer Name & Data so how can we process this? I hope it's not difficult to find ? Is it? Let me help you then, we need  Processor, Memory and other hardware components for data computation. So, we give cluster virtual resources to act like a computer and provide the services.

Like every computer cluster does require hardware resources to compute stuff and that requirement are fulfilled by servers part of cluster or so called nodes. These nodes virtually take over cluster resources and provide services to clients. The nodes run in the background using Virtual Cluster Name & IP address.

Cluster Application:

You have an IP, a Computer Name, Disks and a Node which means now you fulfill the basic requirement to run an application. In an cluster environment the application instance is installed on all the nodes part of the cluster or the nodes which will host the application. The application can be as simple as Notepad or DHCP Exchange or SQL.

If you have all the above components running, you have your Cluster working :)

Hopefully, the blog provides you a basic idea about pillars of cluster technology and their roles. I will write a detailed blog soon on Cluster explianing the archetecture.










Friday, March 8, 2013

PowerShell - Calculate size for a folder/drive/item

Guys,

One of the tasks an administrator or help-desk has been doing for ages is to calculate the size of a folder or drives or an item. Recently i had to work on a script that require space calculation, so i thought i should share the information as it could be handy for the new learners :-)

Here's the small code you can use:

 (Get-ChildItem -Path 'Folder/Drive Path' -Recurse | Measure-Object -Sum Length).sum /1GB

The above command will provide you the output in GB (gigabytes).

Let's understand how it works

 (Get-ChildItem -Path 'Folder/Drive Path' -Recurse | Measure-Object -Sum Length).sum /1GB

The () used above is to contain the command that will calculate the size of the object for you.

So what's running in the ()

(Get-ChildItem -Path 'Folder/Drive Path' -Recurse | Measure-Object -Sum Length).sum /1GB

Get-ChildItem 
As the name suggest, the command will get the child items in the Path specified.

Check TechNet Article to find more :
http://technet.microsoft.com/library/hh849800.aspx

-Path 
Specifies a path to one or more locations. Wildcards are permitted. The default location is the current directory. You can specify folder on the local disk or a network share where you have the access to read the data. For ex: D:\ , c:\foldertoread or \\calculate\foldersize or c:\yourfile.docx

-Recurse
Gets the items in the specified locations and in all child items of the locations.

In Windows PowerShell 2.0 or earlier versions of Windows PowerShell, the Recurse parameter works only when the value of the Path parameter is a container that has child items, such as c:\windows and not when it is an item does not have child item, such as C:\Windows\*.exe

Ok, now we have the path and PowerShell now knows what and where to look. 

This is used to pipe the output to the next command.

Measure-Object
Calculates the numeric properties of objects, and the characters, words, and lines in string objects, such as files of text
Check TechNet article for more details

-Sum
Displays the sum of the values of the specified properties 

Length
Is the file size of the item.

.Sum
Will give you the sum total of the all the items accessed by PowerShell in the ().

/1Gb or /1Mb or /1Kb 
This will divide the size into GB, MB or KB.

OK, now we have understood the command so let's use it as a script 

$Path = Read-host 'Provide the path to calculate the size'

$TotalSize = (Get-ChildItem -Path $Path -Recurse | Measure-Object -Sum Length).sum

$SizeinGB = $TotalSize /1GB
$SizeinMB = $TotalSize /1MB
$SizeinKB = $TotalSize /1KB

Write-Host "$SizeinGB GB , $SizeinMB MB, $SizeinKB KB"

Copy the code and save the file as .ps1 ;-)

Thanks for reading it, i hope you find it useful.