Wednesday, June 11, 2008

SLA - Service Level Agreement for SQL Server 2005

Do you know what an SLA is?

SLA = Service Level Agreement. SLAs are agreements between you and your customers. If you're a DBA, then your customer is typically the company for whom you work. Examples of SLAs are:

1. In the event of a corruption, or other disaster, the maximum amount of data loss is the last 15 minutes of transactions.
2. In the event of a corruption, or other disaster, the maximum amount of downtime the application can tolerate is 20 minutes.

Usually, it's a combination of SLAs such as those above.

Do you know why SLAs are important?

Here's the catch - an SLA is really more than just an agreement between you and your customers - it's more like a contract that you're obligated to meet. This means that if you're a DBA with zero-downtime and zero-data loss SLAs, you need to make sure that in the event of a corruption you can actually meet those SLAs. The obvious thing is that if the SLAs cannot be met then the business will suffer downtime and data loss. The not so obvious thing is that if you're the one who agreed to the SLAs in the first place, and when the disaster strikes, the capabilities of the system are far below the SLA's requirements, then you could lose your job - resume/CV time - I've heard of it happening...

Do you know your SLAs?

You have to know what your SLAs are so you can make sure the system can meet them. Several DBAs I discussed this with don't know what their business' SLAs are, even though they are responsible for making sure they are met. I find this astounding - how can you sign up for meeting an SLA when you don't know that the SLA is? Especially if failing to meet the SLA could lead to resume/CV time...

Do you think you can meet your SLAs?

The other reason to know your SLAs, of course, is so that you can correctly architect your system to meet them. There are a bunch of technologies you can use and strategies you can employ to work towards meeting your SLAs (well beyond the scope of this blog post but will be covered through the year). If you find that you can't meet your SLAs, you need to push-back on your management - otherwise you're setting yourself up for trouble when a disaster occurs and you can't meet the SLAs - you'll be held responsible.

Do you know you can meet your SLAs?

Your disaster recovery plan looks great on paper - but have you actually tried it? I know of one company that has a 15 minute downtime SLA for a 300+GB database but the DBA is relying on clusters to provide that for him. That won't work if the database is corrupt (remember a failover cluster has a single point of failure in its shared-nothing configuration - the disks) and needs to be restored from the last full backup... Another company I know of relies on database mirroring to failover in the event of a disaster but has never tried it to see if their application fails over gracefully... You have to make sure you've practiced recovering from a disaster before the first real disaster happens - you'll be amazed at the little things that are discovered (e.g. if the on-site backups are bad, how long will it take to get the offsite copies brought in-house from the off-site location 100 miles away? Can you still meet your 15 minute downtime SLA in that case?)

SQL Server Specific on SLA

Hours of Operation

1. Hours that the partition/table/database is available to users. The SLAs may be different for various parts of the database, depending on what applications need access to them. Why is it important to differentiate at various granularities? For example, depending on how the unit of data is used, it may require different maintenance than other data and so knowing the availability SLA allows maintenance downtime to be planned.
2. Hours reserved for planned downtime. Again, this may differ at various granularities of data.
3. Amount of advance notice for extended downtime or other changes that affect users. For instance, when my bank upgraded its computer system last year, they gave a series of warnings over the preceeding few months so that people weren't surprised.

Service Availability

1. Percentage of time SQL Server service is running and able to service connections.
2. Percentage of time a particular partition/table/database is available for use (i.e. not exclusively locked for maintenance or restore).

System Performance

1. Number of concurrent users the system supports.
2. Number of transactions supported per unit of time.
3. Acceptable level of performance, such as latency experienced by users for a variety of operations.
4. Minimum time for an update to be replicated to various remote sites.

Disaster Recovery

1. Time allowed for recovery from each type of failure (e.g. accidental data deletion, database corruption, SQL Server crash, OS crash, server failure, site failure).
2. Time it takes to bring critical data online (e.g. the read/write partitions of a sales database) such that operations can continue and less critical data can be recovered later.
3. Time taken to recover data to the point of failure.
4. Maximum acceptable data/transaction/work loss for various kinds of failures.
5. Maximum time for application failover to a remote server/site.

Support

1. Methods available for application users to get help.
2. Maximum response/resolution time from a DBA to respond to various types of problems.

Other

1. Maximum amount of space for user tables/databases.
2. Amount of users in specific roles.

Some other things to consider are how you define an SLA - for example, in transactions per second or in commit latency that users experience - and the interplay between SLAs - for example, the commit latency SLA may be affected if the acceptable data loss SLA is zero and a solution such as synchronous database mirroring or remote SAN mirroring is used.

Bottom line is that although it can be simple to quickly define and announce a set of SLAs for a given application, its very difficult to make sure that each is palatable to all involved, guarantee that each can be met, and allow easy diagnosis of the system to work out which component is failing when an SLA is not met. SLAs really need to be defined while a sytem is being designed as retro-fitting SLAs after-the-fact can be very time-consuming and costly.

Tuesday, June 10, 2008

SQL Server 2005 Performance Statistics Script

PSS SQL Server Engineers : SQL Server 2005 Performance Statistics Script

"Perf Stats Script", since it's useful for troubleshooting lots of issues in addition to blocking. The script takes advantage of the extremely rich set of data exposed by the new Dynamic Management Views in SQL Server 2005.

Download the script from http://blogs.msdn.com/psssql/attachment/1736376.ashx

Monday, June 09, 2008

SAN SRDF based Replication

The replication mode is "Synchronous". This means that when the host server commits a write to a SAN disk, that bit of data will be written to the DR array in Norwest first, the DR array then sends an acknowledgement back to the production array and that bit of data will be written to the prod array when it receives that acknowledgement from the DR side. Meaning that the data between the R1 (prod) and R2 (DR) devices are always in-sync when the SRDF mirrors are established.
• When the SRDF mirror/replication is established, the process write-disables the target devices on the DR array in Norwest, so your DR server will not be able to access the DR SAN devices while that is on. If you want to make the DR LUNs available to the DR host, we will have to split the SRDF mirror for that set of servers.
• Zero data loss? As long as the data has been committed to the SAN disks, it should be covered. As for data that might still be sitting in the server cache but have NOT been flushed out/committed to SAN disk, well, the SAN storage has no control over data that has not been written to it.

Thursday, May 08, 2008

SQL Server 2005 Installation takes longer time


SQL Server 2005 Installation takes longer time




KB Article Number(s): 910070, 917872, 918105, 919357
Language: English
Platform: x64
Location: (http://hotfixv4.microsoft.com/SQL%20Server%202005/nosp/All_SQL2005_Hotfix_1546/09.00.1546.00/free/273291_ENU_x64_zip.exe)
Password: $@fBYZW
Password Changes On: 04/10/2008
Next Password: eXzd@+RVK

Friday, April 11, 2008

Which stored procedure is executing most in the database?

How to list all the columns in the database which are used as identity key in my database?

How to list all the columns in the database which are used as identity key in my database?


Answer: Run following query in query editor.



USE AdventureWorks

GO


SELECT SCHEMA_NAME(schema_id) AS schema_name,
t.name AS table_name,
c.name AS column_name

FROM sys.tables AS t

JOIN sys.identity_columns c
ON t.OBJECT_ID = c.OBJECT_ID

ORDER BY schema_name, table_name;

GO

Sending Email without a Client

Sending Email without a Client

Sending e-mail is typically done from an e-mail client such as Microsoft Outlook. There may be times when you wish you could send an e-mail message without needing a client application.

Thankfully there are a number of ways to accomplish this task.


1) Troubleshooting SMTP can be done via telnet,

2) you can send e-mail from a VBS script or using ASP code,

3) There are tools like MAPISend and Blat that allow you to send email from the command line or a batch file
MAPISend.exe is a command line tool that is available from the Exchange Server 2000 Resource Kit.
You can use MAPISend to connect to a mailbox on your Exchange server and send an email message.
There are a few basic switches you need to know in order to make it work.


* -u is used to specify the profile

* -r specifies the recipients e-mail address

* -s specifies the subject of the e-mail message

* -m specifies the body of the e-mail message



In order for MAPISend to work, a MAPI profile must exist on the computer that the e-mail message is being sent from.

Let’s look at an example of the MAPISend command.



C:\> MAPISend –u “Exchange Profile” –r FFlintstone@thelazyadmin.lab –s “Interested in Bowling Tonight?” –m “Hi Fred Are you interested in bowling tonight? Barney”

Pretty simple isn’t it?


This command can be very useful if you wish to send a message once a batch job has completed running. The message can be sent anywhere. I use this command to send me an e-mail to the SMS address of my Smartphone when certain automated tasks are complete.



If you do not have a copy of the Exchange Server 2000 Resource Kit there is another option called Blat.
Blat is a free, command line, SMTP mailer application. It is very similar to MAPISend; however it does not require a mail profile to be present on the sending computer.

The important command line switches you need to know are:


* -t specifies the sender’s e-mail address

* -r specifies the recipient’s e-mail address

* -subject specifies the subject



The only big difference between MAPISend and Blat is the body of a message sent with Blat is pulled from a TXT file.



C:\> Blat.exe body.txt –t fflintstone@thelazyadmin.lab –f brubble@thelazyadmin.lab –subject “Interested in Bowling Tonight?”



Blat is also very useful for sending messages from batch files to SMS addresses or just regular e-mail addresses.

Wednesday, April 09, 2008

How to troubleshoot problems that occur when you use a Database Maintenance plan in SQL Server

If any task in a Database Maintenance plan fails or encounters an error
message, the maintenance plan job itself may show as failed. The Job
History Details shows the following Error message:



sqlmaint.exe failed. [SQLSTATE 42000] (Error 22029). The step failed.

However, this does not necessarily indicate that the Maintenance Plan
as a whole has failed.

The Maintenance Plan job shows a status of
failed in order to raise a flag to the user that a task in the
maintenance plan requires attention.

Resolution:

Any time a maintenance plan job fails, you must check the plan history
to see what the failure is and then take the appropriate action to
resolve the problem.

How to troubleshoot problems that occur when you use a Database Maintenance plan in SQL Server

Tuesday, April 08, 2008

Monitoring Reliability and Availability of Windows 2000-based Server Systems

Event ID 1074
Events are logged when you manually shutdown the machine using the Event Tracker.

Event ID 1076
Events are logged when the machine shuts down unexpectedly and the Event Tracker pops up when the Administrator (or first user with shutdown rights) logs on to the machine.

Event ID is 6006
The time of this event is approximately the time the operating system becomes unavailable to applications.

Event ID is 6008
The event is recorded when the system restarts and Windows 2000 discovers that the previous shutdown was not clean.

Event ID is 6009
The Event Log service itself is the source of this event whenever the system is started., and the Event ID is 6009.

Event ID: 4097
Dr. Watson utility records application failure events in the Windows 2000 Application Event Log as shown below.

Event ID: 4353
Service Pack installation on Windows

Event ID: 1123
The node lost communication with cluster node

Event ID: 1069
Cluster resource 'SQL Server Fulltext ' in Resource Group 'E38SQL' failed.

Viewing Shutdown Event Tracker events







As you can see in the image above, the Description indicates the reason for the shutdown, the time, the user that initiated the shutdown, as well as the comment that was typed in the Comment box.

To view previous Shutdown Event Tracker event logs, go to the Event Viewer (Start > Programs > Administrative Tools > Event Viewer or Control Panel - Administrative Tools - Event Viewer) and under the System Log, search for Information Events with ID 1074 or 1076. Double click the event to bring up the Event Properties page.

Note:
1074 Events are logged when you manually shutdown the machine using the Event Tracker.
1076 Events are logged when the machine shuts down unexpectedly and the Event Tracker pops up when the Administrator (or first user with shutdown rights) logs on to the machine.

MSI Installer issue on SQL 2005 Setup

Error Message:
The Windows Installer Service could not be accessed. This can occur if you are running Windows in safe mode, or if the Windows Installer is not correctly installed. Contact your support personnel for assistance.
Source:
File:
C:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\LOG\Files
• SQLSetup0001_BOXNAME_SQL.log
• SQLSetup0003_BOXNAME_SQL.log

MSI (s) (68:E8) [23:38:12:124]: Product: Microsoft SQL Server 2005 (64-bit) -- Error 1719. The Windows Installer Service could not be accessed. This can occur if you are running Windows in safe mode, or if the Windows Installer is not correctly installed. Contact your support personnel for assistance.

Resolution:
Error message when you try to add or remove a program on a computer that is running Windows XP or Windows Server 2003: "The Windows Installer service could not be accessed"

http://support.microsoft.com/kb/315346

Trap custom SQL 2005 Installation Success state

C:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\LOG\Files>find /I "comp
leted successfully" SQLSetup0007*.log > Result.txt

Sunday, April 06, 2008

How to restore cluster's share resource

1. Right-click on the desktop and select New Shortcut.


2. In
the window that appears, find the path to the dsm.exe executable
(located by default in directory C:\program
files\tivoli\tsm\baclient\).
Note: If you type the path in, instead of using the Browse button, the path should be enclosed in double quotes. For example: "C:\Program Files\tivoli\tsm\baclient\dsm.exe"


3.
After
you enter the path and executable in the text field, add the following
information after the closing double quotes (add a space between the
double quotes and the following):
-optfile="x:\path\to\cluster\dsm.opt" This
identifies the proper Tivoli Storage Manager cluster options file you
want to use. This example assumes that the cluster options file is
located in the folder ″x:\path\to\cluster\″ and has a filename dsm.opt.



4.
The complete line in the text field now should look similar to the following: "C:\Program Files\tivoli\tsm\baclient\dsm.exe" -optfile="x:\path\to\cluster\ dsm.opt"


5.
Click Next and give this shortcut a meaningful name, such as Backup-Archive GUI: Cluster Group X.


6.
Click Finish.
A desktop icon should now be available. The properties of this icon
will show the following correct Target, as noted in step 4:
"C:\Program Files\tivoli\tsm\baclient\dsm.exe" -optfile="x:\path\to\cluster\ dsm.opt"

Saturday, April 05, 2008

Configuring SSIS to work on Named Instance

Configuring the Integration Services Service to work on named instance:

Modify the MsDtsSvrv.ini file - this is requires for SSIS for SQL2K5 named instance on SQL Server 2005.

File Location:
\90\DTS\Binn\MsDtsSrvr.ini.xml

Changes Requried on:
1) .
Instead of . that denotes default instance Named instance should be there.
Example:
ASQLBox\SQL2K5

2) ..\Packages
If we want to change the file storage location.
Example:
\\ASQLBox\SSISPackages

Reference: http://msdn2.microsoft.com/en-us/library/ms137789.aspx

Connetion to SSIS from client computer failed



Consider the following scenario. A server is running Microsoft SQL Server 2005 Integration Services (SSIS). From a client computer, you use SQL Server Management Studio to connect to Integration Services on the server. To connect to Integration Services on the server, you use a user account that is not a member of the Administrators group on the server. In this scenario, you receive the following error message:

Cannot connect to SSISServer
Additional information: Failed to retrieve data for this request (Microsoft.SqlServer.SmoEnum)
Connect to SSIS Service on machine "SSISServer" failed: Access is denied.

Refer solution at
http://support.microsoft.com/kb/940232/en-us

Error message when you install SQL Server 2005



Error message when you install SQL Server 2005: "The file C:\Windows\Microsoft.NET\Framework\Meaningless_string\mscorlib.tlb could not be loaded"

href="http://support.microsoft.com/kb/918685

Reason for the Error:
This issue occurs because the path of the Mscorlib.tlb file is incorrectly interpreted during the Setup process.

SQL Server 2005 64 Bit Standard Edition Memory

1)Do we really need AWE to get best performance on SQL 2005 x64 bit Standard Edition ?

No. AWE is not required on 64 bit operating system.


2) Can we configure AWE on SQL 2005 x64 bit Standard Edition?

Yes, if the O.S is 32 bit and memory you have is more than 4 GB.

No, if the O.S is 64 bit O.S.

3) Before configuring AWE we need to enabled Lock Pages in Memory Policy,

Can we configure this Policy with SQL Server 2005 64 bit Standard Edition?

Yes, if the O.S is 32 bit and memory you have is more than 4 GB.

SQL Server 2005 Standard edition do not support "Lock Pages in Memory" privileges on the SQL Service account.

Check on the SQL Server ERRORLOG if you get the below message
"Using locked pages for buffer pool". It confirms SQL Server make uses the "Lock Pages in Memory" privileges.


Reference:

SQL Server only uses 2 GB of memory even though the AWE option is enabled

http://support.microsoft.com/kb/811891/en-us
http://support.microsoft.com/kb/918483






It applies only to Microsoft SQL Server 2005 Enterprise Edition

Domain Groups for Clustered Services - SQL 2005 failover cluster Setup



Microsoft KB on setting up Domain Group for SQL Server 2005 Cluster Setup.

http://support.microsoft.com/kb/915846


It is prerequisite for SQL 2005 Cluster setup.

http://msdn2.microsoft.com/en-us/library/ms345196.aspx

Reasons to set up domain groups
When you install a SQL Server 2005 failover cluster, SQL Server 2005 requires domain accounts to start the clustered services. The domain accounts must be added to a domain group.

When you perform a stand-alone installation of SQL Server 2005, SQL Server Setup creates local user groups and then adds the service accounts that you specify to these groups. The Setup program grants permissions for files and folders to these local user groups .

Although the Setup program can create local user groups, the local user groups are not visible to another computer in the failover cluster. When the current computer fails over to another computer, permissions that you grant to the local user groups on the current computer is not visible to another computer. Therefore, the Setup program requires that you provide a domain group that is accessible to all computers in the failover cluster. Then you must add the service account to the domain group when you install a SQL Server 2005 cluster. The Domain Groups for Clustered Services page of the SQL Server Installation Wizard will prompt you to enter the domain name and the group name for each clustered service that you are installing. The Setup program will not create local domain groups in the failover cluster. The Setup program only uses the domain group that you specify.

If you want to change your service account on a SQL Server 2005 cluster, make sure that your new service account is in the related domain group.

Thursday, March 20, 2008

How to find domain name using batch

@echo off
echo.
echo If no Domain is listed below, then you are not part of an NT Domain.
echo.
echo If so, please use your account from one of the supported NT domains,
echo.
echo.
echo.
echo Your current NT Logon is:
echo.

net config workstation | find "User"
net config workstation | find "Logon"

echo.
echo.
echo.
echo.
pause

Monday, February 11, 2008

SQL Server 2005 Default Configuration check list

SQL Server 2005 Configuration check list

http://technet.microsoft.com/en-us/library/ms189631.aspx

http://www.sql-server-performance.com/articles/audit/2005_server_configuration_pt1_p1.aspx

S.No Configuration option Minimum Value Maximum Value Default Value
1 Ad Hoc Distributed Queries (A) 0 1 0
2 affinity I/O mask -2147483648 2147483647 0
3 affinity64 I/O mask (A, only available on 64-bit version of SQL Server) -2147483648 2147483647
4 affinity mask (A) -2147483648 2147483647 0
5 affinity64 mask (A, only available on 64-bit version of SQL Server) -2147483648 2147483647 0
6 Agent XPs (A) 0 1 0
7 allow updates 0 1 0
8 awe enabled (A, RR) 0 1 0
9 blocked process threshold (A) 0 1 0
10 c2 audit mode (A, RR) 0 1 0
11 clr enabled 0 1 0
12 common criteria compliance enabled (A, RR) 0 1 0
13 cost threshold for parallelism (A) 0 32767 5
14 cross db ownership chaining 0 1 0
15 cursor threshold (A) -1 2147483647 -1
16 Database Mail XPs (A) 0 1 0
17 default full-text language (A) 0 2147483647 1033
18 default language 0 9999 0
19 default trace enabled (A) 0 1 1
20 disallow results from triggers (A) 0 1 0
21 fill factor (A, RR) 0 100 0
22 ft crawl bandwidth (max), see ft crawl bandwidth(A) 0 32767 100
23 ft crawl bandwidth (min), see ft crawl bandwidth(A) 0 32767 0
24 ft notify bandwidth (max), see ft notify bandwidth(A) 0 32767 100
25 ft notify bandwidth (min), see ft notify bandwidth(A) 0 32767 0
26 index create memory (A, SC) 704 2147483647 0
27 in-doubt xact resolution (A) 0 2 0
28 lightweight pooling (A, RR) 0 1 0
29 locks (A, RR, SC) 5000 2147483647 0
30 max degree of parallelism (A) 0 64 0
31 max full-text crawl range (A) 0 256 4
32 max server memory (A, SC) 16 2147483647 2147483647
33 max text repl size 0 2147483647 65536
34 max worker threads (A, RR) 128 32767 0
35 media retention (A, RR) 0 365 0
36 min memory per query (A) 512 2147483647 1024
37 min server memory (A, SC) 2147483647 8
38 nested triggers 0 1
39 network packet size (A) 512 32767 4096
40 Ole Automation Procedures (A) 0 1 0
41 open objects (A, RR, obsolete) 0 2147483647 0
42 PH_timeout (A) 1 3600 60
43 precompute rank (A) 0 1 0
44 priority boost (A, RR) 0 1 0
45 query governor cost limit (A) 0 2147483647 0
46 query wait (A) -1 2147483647 -1
47 recovery interval (A, SC) 0 32767 0
48 remote access (RR) 0 1 1
49 remote admin connections 0 1 0
50 remote login timeout 0 2147483647 20
51 remote proc trans 0 1 0
52 remote query timeout 0 2147483647 600
53 Replication XPs Option (A) 0 1 0
54 scan for startup procs (A, RR) 0 1 0
55 server trigger recursion 0 1 1
56 set working set size (A, RR, obsolete) 0 1 0
57 show advanced options 0 1 0
58 SMO and DMO XPs (A) 0 1 1
59 SQL Mail XPs (A) 0 1 0
60 transform noise words (A) 0 1 0
61 two digit year cutoff (A) 1753 9999 2049
62 user connections (A, RR, SC) 0 32767 0
63 User Instance Timeout (A, only appears in SQL Server 2005 Express Edition) 5 65535 60
64 user options 0 32767 0
65 Web Assistant Procedures (A) 0 1 0
66 xp_cmdshell (A) 0 1 0