Categories
How To SQL Server

Monitoring SQL Server using Alerts

There are many after market tools available to monitor health of SQL Server. But with help of built-in tools you can actually create some pretty neat solution by yourself too. And one of the most handy tool is “Alerts” in SQL Server. With help of Alerts you can monitor SQL Server Events, Various Performance Conditions and oddly WMI events !! And what great thing about it is you can setup it to notify users and / or run specific job (stored in SQL Agent) to handle specific event.

It is very simple to setup Alerts using SQL Server Management Studio (SSMS). Since Alert notification uses Database Mail, you need to have a valid mail profile in order to be able to sent notifications. You can actually use your gmail account for testing. While back I did post about it.

First you need to create an operator which will receive an alerts via Email or  Net Send or Pager. You can create new operator in SSMS –> SQL Server Agent –> Operators. Right click on Operators and select “New Operator”.

It has two simple parts, in 1st General part you provide way you want to get notification … be it Email, Net Send Address or Pager. Furthermore you can setup pager schedule. For demo, I will be using my Gmail account as operator email.

Categories
How To SQL Server

Send emails using Database Mail … from SQL Server

Back in Pre SQL Server 2005 editions of SQL Server there was nice feature called SQL Mail which basically allowed users to send email from within database server. But that system has many dependencies and major one was requirement of Microsoft Exchange… thus usage was severely limited to enterprise customers who has resources to setup such a system. When MSFT released SQL Server 2005 they introduced new feature called Database Mail which replaced SQL Mail … and they removed all kind of external dependencies. Now all you had to do was to provide just SMTP server and you are all set !!

I always thought that I have blogged about process to setup Database mail but it appears that I never did so today I am going to write about step-by-step process to setup / configure database mail. Since we have moved on from 2005 to 2008 to 2008R2 to 2012 …. I am going to use SQL Server 2012 edition but process remains same for previous editions too.

Database Mail can be found under “Management” group in SQL Server Management Studio. To configure Database Mail right click on it and select “Configure Database Mail” which will start configuration wizard. It will show bunch of options like “Set up Database Mail”, “Manage”, “Change system parameters”. Since we have not setup this before we are going to select first option, “Setup Database Mail by performing following tasks”. And with that selected click next.

Categories
How To Windows

Setting up Domain Controller in Virtual System … Part II

So after setting up Domain Controller (DC) next step is to configure workstations and add them into newly created Domain. It is actually not that difficult part but during my early trials I spent quite a bit time to make these workstations connect to DC. Because even though they were part of same network they were not able to “see” DC because they had different DNS and it took me while to figure that out.

Anyways, first step is to setup fixed IP of workstation. And make sure that in it’s DNS, use IP of DC.

Categories
How To Windows

Setting up Domain Controller in Virtual System … Part I

If you are like me, who like to “experiment” with random software downloaded from Source Forge, CodePlex or anything alike … on top of working on bunch of side projects in different work environments … and you have a “bug” in your mind which make you learn anything and everything .. then I am sure that you have always craved to have a domain controller of your own .. I mean imagine about trying different networking theories to server-client application development to database management … In love

But biggest issue with having personal Domain Controller is you need separate hardware which you can use as a domain controller and it has to be running all the time which could be biggest constraint for many follow IT Professionals and if you are cheapskate like me then you probably have very nice machine but just 1 or 2 machines (not talking about puny laptops … but bigass desktops)… and you want to get as much juice as you can get from that beast (!!) . But if you are not that serious then you can actually use one virtual machine to be as Domain Controller and many other virtual machines as your toys. And in this post I am going to show step by step how to do that ….

To my surprise there are not many “how to” available about setting up domain controller using virtual machines .. hack they don’t have much posts about setting up DC with real hardware !! So it took me real long .. and many tries to have some proper machine to have working domain controller (some were due to unforeseen side effect of using virtual machine). Mainly because this process is not as straight forward as it seems (or that’s what networking guys makes you think Open-mouthed smile)… Okey enough babbling … now the process ….

First you need a good clean virtual machine with new SIDs. Alternatively you can create your own clean image using SYSPREP (built into Windows). I can’t stress enough that if you have an existing image of virtual machine make sure that you use this SYSPREP to prepare nice clean image and use THAT image to setup DC otherwise you will run into weird issues and you will spend hours scratching your ….. head Winking smile. I am using evaluation edition Windows Server 2008 R2 Enterprise, because later on I also want to setup 2 node cluster but that will take some time Smile for now just stick with current task at hand … setting up virtual Domain Controller.

If the image is created using SYSPREP then once booted, it will do some installation and configuration of OS.

Domain Controller 1 Domain Controller 2 Domain Controller 3
Categories
How To Installer Tools

Editing MSI with OCRA

If you have worked with MSI then you probably know that it uses an internal database to store all kind of information and you can actually directly modify this information by using a great tool OCRA. It is tiny utility released by MSFT.

But unfortunately it is not “that” simple to get OCRA because it is not available as separate download , instead it is part of Windows SDK. Which means that if you want OCRA you have to download whole Windows 7 SDK. And even after downloading whole 1.4 Gb ISO, this tools is not easily visible. Once you download ISO (for x64 bit download), either make DVD or mount it as virtual drive (my preferred option) then go to \Setup\WinSDKTools_amd64 and open up cab1.cab. Inside that you will see WinSDK_Orca_Msi_5E20C107_DAA3_4D49_AFAE_7FB2594F0CDC_amd64 , extract that file and add extension .msi to it. And that is your installation for OCRA !! I really don’t know why such a great tool is hidden so deep by MSFT (and it is not the only great tool neglected by them). Once you install it you will see an additional entry “Edit with OCRA” in context menu whenever you right click on MSI.

Categories
How To Tips

Remotely execute file on another machine

As usual, I was searching something over internet and going through random crap to look for something (I don’t remember now what was that) and I somehow found that there is really great utility available in good ol’ Sysinternals Suite which literally allows user to remotely execute any application on another machine !! That utility is called PsExec.

Honestly in past sometimes I really had wished that if there is some kind of tool available which can run some program on remote machine so that I don’t have to do something crazy. But I always assumed that it simply is not possible for whatever reasons and so it crossed my mind to even search for something.

Use of this tool is actually pretty simple. And like may other tools of Sysinternals suite this one too doesn’t have any GUI to interact with. Users are required to feed bunch of parameters in order to make it work. And it is very possible that it will not work in first try because of missing parameter. To get list of all parameters you can simply run exe on command prompt and you will see something like this …

PsExec4

Categories
How To Virtualization Windows

Use of SYSPREP to duplicate windows image with new SIDs

From past some time I am trying to create windows domain in home computer with bunch of VMs using Windows Server 2008 R2 for “educational” purposes Open-mouthed smile … my ultimate goal was to setup clustered windows system and have SQL Server in that environment. I want to lean about how SQL Server behaves in clustered systems and what are ups ‘n downs of any clustered system … like OS updates, SQL Server updates, SSIS – SSRS behavior in failover, system crashes etc … I mean you can always lean by reading but I think it gives better idea when you can actually test those theories on some kind of test system Nerd smile

So, by following few blogs, MSDN helps and forums … I was finally able to install and configure everything properly … I had working domain too … but when you try to setup windows cluster, it is recommended by MSFT to validate cluster before setting it up. Which basically runs bunch of tests like check all nodes, their hardware, their compatibility, storage system, network settings etc … and if any test fails then you have to fix that issue before setting up cluster. And if you are not too savvy about these items then it is really painful experience.

So when I tried to run this test .. it failed at one particular point where it validates system configuration. Unfortunately I don’t have screenshot of this error so I can’t show detailed message but it had something to do with system settings. I tried to look for this error and I was not able to find any definitive answer until I found an answer in stackoverflow which mentioned that it could be because of SIDs !