1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu SQL Server MVP Deep Dives- P15 ppt

40 456 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Successfully Implementing Kerberos Delegation
Tác giả Brad Turner, Steve Patrick, Brian Murphy-Booth, James World, Rob Kerr, Microsoft SQL Server Protocols Team, Tomek Onyszko
Trường học Microsoft Corporation
Chuyên ngành Information Technology
Thể loại presentation
Năm xuất bản 2008
Thành phố Redmond
Định dạng
Số trang 40
Dung lượng 1,34 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Resources to assist in more complex infrastructures SQL 2008, Kerberos and SPNs Tomek Onyszko, Warsaw, Poland http://blogs.dirteam.com/blogs/tomek/archive/2008/04/09/ sql-2008-kerberos-a

Trang 1

514 CHAPTER 38 Successfully implementing Kerberos delegation

gssMonger—tool for verifying Kerberos

authentication interoperability between

Windows and other platforms

http://www.microsoft.com/downloads/details.aspx?

FamilyID=986a0a97-cfa9-4a45-b738-535791f02460&

DisplayLang=en Kerberos/delegation worksheet http://blogs.inetium.com/blogs/jdevries/archive/2006/06/26/

245.aspx

Table 2 Blog posts

Ask the Directory Services Team

(all articles tagged with Kerberos)

http://blogs.technet.com/askds/archive/tags/Kerberos/ default.aspx

Kerberos Delegation to SQL Server

Darwin, Australian in UK—Delegation Guy

http://blogs.msdn.com/darwin/archive/2005/10/19/ 482593.aspx

The Problem with Kerberos Delegation

Brad Turner, ILM MVP (Gilbert, AZ, US)

delegation.html

http://www.identitychaos.com/2008/03/problem-with-kerberos-Spat’s Weblog: “Kerberos delegation end

to end”

Steve Patrick (Spat), Critical Problem

Resolution, Microsoft Corporation

Part I: http://blogs.msdn.com/spatdsg/archive/2007/11/14/ kerberos-delegation-end-to-end-part-i.aspx

Part 2: http://blogs.msdn.com/spatdsg/archive/2007/11/20/ kerberos-delegation-end-to-end-part-ii.aspx

Part 3: http://blogs.msdn.com/spatdsg/archive/2007/11/26/ kerb-part-3.aspx

DelegConfig (Kerberos/delegation

configura-tion reporting tool)

Brian Murphy-Booth, Support Escalation

Engineer, Microsoft Corporation

http://blogs.iis.net/brian-murphy-booth/archive/2007/03/09/ delegconfig-delegation-configuration-reporting-tool.aspx

Essential Tips on Kerberos for SharePoint

Developers

James World, Microsoft Developer

Consul-tant, Microsoft UK

http://blogs.msdn.com/james_world/archive/2007/08/20/ essential-guide-to-kerberos-in-sharepoint.aspx

Microsoft BI with Constrained Kerberos

Delegation

Rob Kerr, MCDBA, MCTS; Principal

Consul-tant, BlueGranite

Constrained-Kerberos-Delegation.aspx

http://www.robkerr.com/post/2008/05/Microsoft-BI-with-Enterprise Portal Kerberos Delegation for

connecting to Reporting/Analysis Services

on a different box

Microsoft's Enterprise Solutions blog

http://blogs.msdn.com/solutions/archive/2008/02/28/ enterprise-portal-kerberos-delegation-for-connecting-to-reporting- analysis-services-on-a-different-box.aspx

Understanding Kerberos and NTLM

authenti-cation in SQL Server Connections

Microsoft SQL Server Protocols team

http://blogs.msdn.com/sql_protocols/archive/2006/12/02/ understanding-kerberos-and-ntlm-authentication-in-sql-server- connections.aspx

Table 1 Free tools for testing and implementing (continued)

Trang 2

Resources to assist in more complex infrastructures

SQL 2008, Kerberos and SPNs Tomek Onyszko, Warsaw, Poland

http://blogs.dirteam.com/blogs/tomek/archive/2008/04/09/ sql-2008-kerberos-and-spns.aspx

Table 3 Microsoft TechNet articles

Kerberos Authentication in Windows Server 2003: Technical Resources for IT Pros

http://technet2.microsoft.com/windowsserver/en/technologies/ featured/kerberos/default.mspx

Kerberos Explained http://technet.microsoft.com/en-us/library/bb742516.aspx How to: Configure Windows Authentication

http://support.microsoft.com/default.aspx/kb/909801

How to configure a Windows SharePoint Services virtual server to use Kerberos authentication

http://support.microsoft.com/default.aspx/kb/832769

You receive an “HTTP Error 401.1 - Unauthorized:

Access is denied due to invalid credentials” error message when you try to access a Web site that

is part of an IIS 6.0 application pool

http://support.microsoft.com/default.aspx/kb/871179

Authentication may fail with “401.3” Error if Web site’s “Host Header” differs from server’s Net- BIOS name

http://support.microsoft.com/default.aspx/kb/294382 Table 2 Blog posts (continued)

Trang 3

516 CHAPTER 38 Successfully implementing Kerberos delegation

How to troubleshoot the “Cannot generate SSPI

context” error message

Applications Using Windows Server

Balanced Web Sites

http://www.microsoft.com/downloads/details.aspx?FamilyID=

035465f0-5090-4f9c-ac44-fc0500769be9&DisplayLang=en Troubleshooting Kerberos Errors http://www.microsoft.com/downloads/details.aspx?FamilyID=

7dfeb015-6043-47db-8238-dc7af89c93f1&DisplayLang=en Windows 2000 Kerberos

Authentication

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

Table 6 Microsoft webcasts

Introduction to Kerberos http://support.microsoft.com/kb/822248

Troubleshooting Kerberos authentication with secure

web applications & SQL Server

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

How to understand, implement, and troubleshoot

Ker-beros double-hop authentication

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

Configuring Microsoft SQL Server 2005 Analysis

Ser-vices for Kerberos authentication

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

Understanding, implementing, and troubleshooting

Kerberos double-hop authentication

http://support.microsoft.com/servicedesks/webcasts/ seminar/shared/asp/view.asp?url=/servicedesks/ webcasts/en/WC102704/manifest.xml

Table 4 Microsoft Help and Support articles pertaining to Kerberos delegation (continued)

Trang 4

I hope you have a better understanding of Kerberos delegation, and why and whenyou need it Most of all, I hope that you were able to successfully implement Kerberos

in your environment after reading this chapter

About the author

Scott Stauffer is an independent consultant working out of themetro Vancouver area, assisting clients with data systems solu-tions to their business challenges He has worked in IT for morethan 13 years, and although Scott has managed systems withearly version SQL Server on OS/2, he really started diggingdeep into SQL Server with the release of SQL Server 6.5 With akeen interest in continuous learning, sharing knowledge, andbuilding community, Scott founded the Vancouver PASS chap-ter (http://www.Vancouver.SQLPASS.org) back in September

2004 More recently, he started the Vancouver BI PASS chapter(http://www.VancouverBI.SQLPASS.org) in order to dive deep into the business intel-ligence features that SQL Server has to offer

Trang 5

39 Running SQL Server

on Hyper-V

John Paul Cook

Virtualization is a popular term covering several technologies In the server space,virtualization is beneficial for several reasons:

ƒ Disaster recovery is simple You merely copy a small number of files fromyour normal production environment to your disaster recovery environ-ment Your disaster recovery hardware doesn’t have to match your produc-tion hardware

ƒ Provisioning a virtual machine is simpler and faster than provisioning a ical machine Virtualization tools make it simple to clone a production serverand run it on different hardware Development and test servers can be provi-sioned quickly, which can boost the efficiency of regression testing

phys-ƒ With fewer physical servers needed, less rack space, cooling, and electricityare consumed, making for a greener and more affordable infrastructure

ƒ Microsoft offers savings on licenses A single copy of Windows 2008 ServerStandard Edition on a physical machine allows you to also run one virtualcopy of Windows 2008 Server Standard Edition at no additional licensingcost With Windows 2008 Server Enterprise Edition, up to four virtual copies

of Windows 2008 Server can be run at no additional cost One copy of dows 2008 Server Datacenter Edition allows an unlimited number of Win-dows Server virtual machines to be run on the same physical machine, allcovered by the one datacenter license Licensing can be complicated byassignment and downgrade rights which are explained here: http://blogs.technet.com/mattmcspirit/archive/2008/11/13/licensing-windows-server-in-a-virtual-environment.aspx

Win-In this chapter, we will begin with an overview of virtualization architecture beforeexploring a number of key issues such as configuration, clock drift, and backups

Trang 6

2005 R2 Service Pack 1 (SP1) and VMware Server.

When the Hyper-V role is enabled on Windows 2008 Server, the original Windows

2008 operating system is transformed into a virtual machine, which is called the ent partition The virtual machines are called child partitions Each partition is iso-lated from the other Figure 1 highlights this relationship

For supported operating systems, additional software may be installed into a virtualmachine to facilitate interaction with the physical hardware devices For Hyper-V, thissoftware is called Integration Services It provides special device drivers call syntheticdrivers, which are optimized for the virtual world and which are necessary for achiev-ing near native performance With synthetic drivers, the overhead of hardware emula-tion is avoided

Table 1 Types and examples of virtualization technologies Server hardware virtualization

(hypervisor) Microsoft Hyper-V, VMware ESX, Xen Hypervisor

Server software virtualization Microsoft Virtual Server 2005 R2, VMware Virtual Server

(for-merly GSX) Presentation virtualization Terminal Services, Citrix XenApp Application virtualization Microsoft App-V, VMware ThinApp, Citrix XenApp streaming Desktop virtualization Microsoft Virtual PC and MED-V, VMware Workstation, Paral-

lels Desktop

Intel VT or AMD-V x64 hardware Microsoft Hyper-V

Windows 2008 x64 parent partition

Virtual Machine 1 x32 or x64 child partition

Virtual Machine 2 x32 or x64 child partition

Figure 1 A virtual machine running

on Hyper-V only passes through a thin hypervisor layer to access the physical hardware.

Trang 7

520 CHAPTER 39 Running SQL Server on Hyper-V

Server software virtualization products such as Microsoft Virtual Server 2005 R2 SP1, asshown in figure 2, incur more overhead than hypervisors and are slower VirtualServer 2005 R2 SP1 is installed as an application running on the physical machine’soperating system Virtual operating systems are installed into Virtual Server 2005 R2SP1 The virtual operating system must pass all of its hardware calls to the virtualiza-tion application, which in turns passes them to the host operating system For exam-ple, if Windows 2003 Server is installed as a guest operating system in Virtual Server

2005 R2 SP1, which is installed on Windows Server 2008, operating system calls in 2003Server are passed through Virtual Server 2005 SP1 to Windows Server 2008 to finally

be executed The path is less direct than that of a hypervisor and this adverselyimpacts performance

Even with the inherent overhead of software virtualization, small volume SQL ers with limited demands on the hardware can perform acceptably using server soft-ware virtualization such as Virtual Server 2005 R2 For more demanding databaseapplications, hypervisor-based server hardware virtualization is needed Hyper-V offerssignificantly improved disk I/O performance when compared to Microsoft VirtualServer 2005 R2

Serv-Benefits of isolation

When a virtual machine crashes, it doesn’t affect the other virtual machines or thephysical machine because each virtual machine is isolated from the others and thephysical machine Processes in one virtual machine (VM) can’t read, corrupt, or accessprocesses running in other virtual machines Because of this complete isolation, it ispossible to have multiple default instances of SQL Server running on a single physicalserver by having each default instance in its own virtual machine This is particularlyimportant when trying to consolidate third-party applications which require defaultinstances of SQL Server Each application can run in its own virtual machine with eachvirtual machine running a default instance of SQL Server

x32 or x64 hardware

Microsoft Virtual Server 2005 R2 Windows 2003 or 2008 host operating system

Virtual Machine 1 x32 guest

Virtual Machine 2 x32 guest

Figure 2 A virtual machine running

on Virtual Server 2005 R2 passes its operating system calls to the host operating system for execution, which results in a longer, slower path

to the hardware.

Trang 8

Configuring virtual machines

Configuring virtual machines

To obtain the best possible results from a virtual machine, it must be configured erly Configuration of virtual disks, virtual processors, and virtual network adaptersaffect performance

A virtual hard disk is a file that resides on the parent partition’s file system or age area network (SAN)

Dynamically expanding VHDs are best suited for development and test ments because they conserve disk space Dynamically expanding VHDs grow asneeded, which minimizes space usage but tends to cause fragmentation Because thevirtual machine’s operating system is isolated from the physical machine, it has noknowledge of the amount of physical disk space available The virtual machine onlyknows the maximum allowable size of the dynamic VHD This can create a disparitybetween what the virtual machine sees as free space and the reality of free space onthe physical machine

In figure 3, the virtual machine running in the window on the right shows 117 GB

of free space in its VHD But because this dynamically expanding VHD resides on ical disk D, which has no free space left, the 117 GB of free space doesn’t actually exist.Hyper-V places the virtual machine into a paused state because it has no physicalspace to continue operating SQL Server can be configured to provide you with lowfree disk space alerts, but if you are using dynamically expanding VHDs, you may notget the alert The virtual machine doesn’t know when there isn’t room for a dynami-cally expanding disk to grow

Fixed-size VHDs perform better than dynamically expanding VHDs because all oftheir space is preallocated, although the performance difference has been lessenedwith the R2 release of Hyper-V When a fixed VHD is created and its size specified, ittakes all of its space from the physical machine If there isn’t enough space, an erroroccurs and it is not created

Differencing VHDs also grow as needed, but they are linked to another VHD in aparent- child relationship When a differencing VHD is used, all changes are written tothe differencing VHD instead of the parent VHD Although this causes an overall slightdecrease in disk performance, it allows changes to be made without altering the

Trang 9

522 CHAPTER 39 Running SQL Server on Hyper-V

parent VHD Differencing VHDs are useful in test environments because extensivechanges to a virtual machine can be made without changing the original VHD Whendifferencing VHDs are used, any changes to the parent VHD breaks the parent-childrelationship rendering the children differencing VHDs nonfunctional To prevent thisfrom happening accidentally, it is advisable to set a parent VHD to read only You cancreate more than one differencing VHD from the same parent VHD Doing this allowsyou to create different branches sharing a common ancestor For example, you mighthave a parent VHD with a client application that accesses SQL Server You could usetwo different differencing VHDs for testing two independent and different enhance-ments to the client application

Hyper-V allows you to take a snapshot of a running virtual machine After creating

a snapshot, all changes to the virtual machine are written to a separate virtual disk file.This is similar to a differencing disk in that performance is reduced slightly because ofthe additional overhead of a file depending on another file Snapshots are particularlyuseful in testing service packs Before applying a service pack, create a snapshot Aftertesting the service pack you can create another snapshot, revert to your snapshotmade before the service pack was applied, or merge the snapshot’s changes to the ini-tial VHD Although snapshots allow recovery of a virtual machine to a particular priorstate, they are not substitutes for backup and should not be considered as such

Figure 3 A dynamically expanding virtual hard disk is seen by the virtual machine as having 117 GB of free space when there is actually no disk space left on the physical file system This forces the virtual machine into a paused state

Trang 10

Configuring virtual machines

Although Windows 2008 Server is generally considered a server operating tem, many developers and people who demonstrate software use Windows Server

sys-2008 so that they can use Hyper-V For these use cases, performance is usually less of

an issue than minimizing physical disk space usage; therefore dynamically ing virtual hard disks are a good compromise on minimizing space while maintain-ing good performance

Virtual hard disks can be attached to either IDE or SCSI buses Hyper-V virtualmachines must boot from a VHD attached to an IDE bus A virtual SCSI bus supportsmore devices than a virtual IDE bus If you need more than four VHDs, you’ll have touse a virtual SCSI bus

Virtual machines and physical machines are more alike than not The same ples of maximizing disk performance that apply to physical machines also apply to vir-tual machines When there is concurrent disk access, separate spindles or logical unitnumbers (LUNs) should be used to avoid disk contention On a physical machine, tomaximize performance by minimizing contention, you might put tempdb on a spin-dle or LUN by itself Translating this to the virtual world, tempdb would exist by itself

princi-in its own VHD This VHD contaprinci-inprinci-ing tempdb would princi-in turn be placed on its own spprinci-in-dle or LUN to avoid I/O contention If other VHDs were stored on the same physicaldevice, I/O contention could occur

spin-CPU configuration

Hyper-V allows up to four processor cores to be allocated to a virtual machine and refers

to them as logical processors If your SQL Server workload requires more than four cessors, it is not a suitable candidate for virtualization with Hyper-V

If you have two SQL Server instances running on identical hardware, you mightwant to consolidate them onto one physical machine by migrating both of them intovirtual machines If they typically run at under 40 percent of the available CPUresources on the physical machines, having two of these running as virtual machines

on the same hardware will not overtax the available physical resources If a third SQLServer instance is added to the physical machine, and it uses as much CPU as the othervirtual machines, the total CPU demand from all three virtual machines exceeds thephysical CPU available In this example, with three virtual machines each needing 40percent of the available CPU, they will all perform suboptimally because there isn’tenough physical resource available

Conventional approaches to performance monitoring are not adequate for fying all performance problems in virtualized SQL Server instances Task Managershows the CPU usage within the virtual machine in isolation An individual SQL Servermay show only minimal CPU usage but actually be starved for CPU If the running vir-tual machines collectively are overtaxing the physical machine, all virtual machineswill suffer

In figure 4, Task Manager in the child partition (shown on the right side of thescreen capture) gives the appearance of ample CPU resource availability, which isclearly not the case The child partition has no visibility of the load in other partitions

Trang 11

524 CHAPTER 39 Running SQL Server on Hyper-V

As you can see, the parent partition is using 83 percent of the available CPU resources

If a process running in the child increases to take 40 percent of the available CPU, petition for the overtaxed CPU resources occurs The child takes resources from theparent, reducing the resources for the parent There isn’t an overall Task Manager forthe entire physical machine that shows the sum of all of the individual Task Managers.Hyper-V provides its own set of Perfmon counters to provide a view of both what ishappening at the overall physical server level as well as within the Hyper-V environ-ment These Hyper-V counters are exposed in the parent partition (that is, physicalmachine) You may choose from many different categories of Hyper-V counters Refer

com-to the Hyper-V documentation and product team blogs com-to determine which countersare most useful to you Tony Voellm’s blog at http://blogs.msdn.com/tvoellm/ is anexcellent source of in-depth information on Hyper-V performance monitoring Usethe Hyper-V counters to make sure that the total physical CPU resources on yourHyper-V server are adequate to service all of your running virtual machines

Configuring networking

Hyper-V offers both legacy network adapters and synthetic network adapters Legacynetwork adapters are emulated devices and as such offer lower performance than syn-thetic adapters, but offer greater compatibility with older operating systems Syntheticadapters provide near-native performance and require that Integration Services beinstalled in the virtual machine, which is not possible in all cases When Integration

Figure 4 Task Manager results are local to the partition in which it runs.

Trang 12

Backup considerations

Services is installed, it installs drivers that enable synthetic (virtual) devices to work Alegacy network driver is slower because it emulates a physical device instead of being

an outright substitute like a synthetic device Integration Services cannot be installed

in Windows Server operating systems prior to Windows Server 2003 R2 Service Pack 2.For example, a SQL Server 6.5 instance running in an NT 4 virtual machine must use alegacy network adapter

The minimum number of recommended physical network adapters for a Hyper-Vphysical machine is two (although it is possible to run with a single network adapter).One should be reserved for use only for administering the physical machine Theother is used for the virtual machines If there is substantial network traffic, it may benecessary to have one or more physical network adapters for each virtual machine Toensure optimal network performance, check with your hardware vendor to ensurethat you have all of the latest drivers Network-intensive workloads use more CPU in avirtual machine than on a physical machine For deeper technical information andbest practices, see Microsoft’s whitepaperRunning SQL Server 2008 in a Hyper-V Envi- ronment, downloadable from http://download.microsoft.com/download/d/9/4/d948f981-926e-40fa-a026-5bfcf076d9b9/SQL2008inHyperV2008.docx

Memory configuration

Hyper-V does not allow memory to be overallocated If 2 GB of memory is allocated to

a virtual machine, but only 1 GB is ever actually used, the 1 GB of unused RAM is notavailable for use by other virtual machines This imposes a limit on how many virtualmachines can be running at any given time The sum of the memory allocation for allrunning virtual machines should be 1-2 GB less than the server’s physical memory.Enough memory has to be left available so that the hypervisor itself (and any antivirussoftware running in the parent partition) has enough RAM to avoid paging

Addressing clock drift issues

It is common for database applications to need accurate timestamps for data ing systems employ various techniques to minimize clock drift where the time on thecomputer diverges from the time Multiprocessor virtual machines can introduceadditional clock drift because of how processor resources are shared By default,Hyper-V Integration Services synchronize the virtual machines with the physicalmachine If you want to treat the virtual machine more like a physical machine, youcan disable the time synchronization in Integration Services and instead use synchro-nization with an external time source or a primary domain controller (PDC) emulator

Operat-Backup considerations

SQL Server backup strategies have to consider both data loss as well as catastrophicloss of the server The Hyper-V Volume Shadow Copy Service (VSS) Writer IntegrationComponent enables virtual machines to be backed up so that VSS-aware applicationsrunning in virtual machines are backed up in an application-consistent manner

Trang 13

526 CHAPTER 39 Running SQL Server on Hyper-V

When Integration Services are installed, VSS on the physical machine coordinates withVSS in the virtual machine Having backups of virtual hard disk files and configurationfiles allows a virtual machine to be restored to a different physical machine

When planning a data backup strategy, it is best to think of a virtual SQL Serverinstance as being like a physical SQL Server instance The real value of SQL Server back-ups is the ability to do point-in-time recovery This requires true SQL Server backuptools and strategies Running SQL Server inside a virtual machine doesn’t change that.Backups of the Hyper-V server do not eliminate the need for traditional SQL Serverbackups

Advantages of physical to virtual migration

Existing physical machines can be converted to virtual machines and continue ing just as they did when they were physical machines This also opens up new possibil-ities When a physical or virtual machine isn’t functioning properly, a virtual copy can

operat-be made The problematic machine can operat-be fixed or replaced and brought back onlinewhile preserving the problem condition in the virtual copy The virtual machine can bedebugged at length without disturbing the original environment from which it came System Center Virtual Machine Manager (SCVMM) 2008 has a tool for convertingphysical machines to virtual machines, which is known as P2V It can also do virtual-to-virtual or V2V conversions of Microsoft Virtual Server or VMware virtual machines.You may also use third-party conversion tools that can be purchased or even obtainedfor free

System Center Virtual Machine Manager (SCVMM) conversion can be valuable introubleshooting difficult-to-reproduce problems Instead of telling your end user that

a problem can’t be reproduced, SCVMM 2008 can be used to do a P2V of the problemmachine You can provide the virtual machine to support personnel to analyze theproblem at length without disrupting or inconveniencing the user

Test environments and virtualization

Virtual machines are well suited for creating test environments To obtain the mum value of a test environment, it must be valid and complete Although a success-ful P2V provides a valid representation of a physical machine, it may not by itselfcomprise a complete test environment For example, to test a global deployment of aSQL Server distributed database application, you would probably need a completeenvironment consisting of many virtual machines Multiple virtual SQL Servers would

maxi-be utilized Each would maxi-be configured to the time zones used at corporate datacentersaround the world End user client experience testing requires multiple client virtualmachines Regional and language settings would be different in the various client VMs

to match the corporate environment

Test environments are generally much more dynamic than production ments To enable agility, templates and prebuilt building blocks such as virtual harddisks and ISO files are needed ISO files are image copies of physical optical media

Trang 14

Summary

such as DVDs and CDs Although Hyper-V supports installing from physical opticalmedia, ISO image files are a better choice because they are read at the speed of thehard drive they reside on Optical drives are much slower than hard drives SCVMM

2008 provides an organized framework for managing virtual building blocks andassets such as ISO files and virtual machine templates Visual Studio Team System 2010has the Microsoft Test and Lab Manager which builds upon SCVMM 2008 and provides

a comprehensive test environment

Summary

Although this is the end of our discussion of running SQL Server in a virtual machine,

it is also the beginning of planning an effective virtualization strategy Remember that

a virtual machine is still a machine The same design patterns for physical machinesapply to virtual machines and effective management policies are as applicable (per-haps more so) than in a physical environment Extend your design patterns by takinginto consideration the unique characteristics of virtual machines to ensure success

About the author

John Paul Cook is a SQL Server application DBA based in ton, Texas In addition to writing about database applicationdevelopment and virtualization, he speaks about SQL Server atconferences and user group meetings John is particularly inter-ested in using version control and virtualization to bring agilityand reliability to the systems development lifecycle His inter-ests also include database performance tuning and deployment.You can read his blog at http://sqlblog.com/blogs/john_paul_cook/default.aspx

Trang 16

Hous-Part 4

Performance Tuning

and Optimization

Edited by Kalen Delaney

There are many different aspects to performance tuning for SQL Server, ing tracking down hardware and network issues, monitoring the SQL Server ser-vice’s use of memory and processor resources, analyzing the causes of blocking,and investigating suboptimal index usage and query plans, to name only a fewareas Performance problems can result in a general slowdown of SQL Serverand the applications running against it, or can just impact individual queries orprocesses, or even individual users

Because there are so many areas that could be the source of performanceproblems, there is no one best way to troubleshoot poor performance Most SQLServer professionals have a few areas of the product where they tend to focus, sothose people might start their troubleshooting efforts in one of those areas Microsoft provides a host of tools to help you track down the source of per-formance problems The earliest versions of SQL Server enabled you to see yourquery plans (albeit, not graphically) through an option called SHOWPLAN or toexamine the system’s behavior using Performance Monitor Slightly later ver-sions started including the ability to trace the activities your SQL Server wasinvolved in, starting with the basic ability to monitor the client-to-server commu-nication and progressing to the ability to see every action of SQL Server, eitherinternal or external The most recent version includes the amazing ability to set

up a data warehouse of performance data that can easily be analyzed using a set

Trang 17

of built-in reports The tool even provides recommendations for how to remedy theproblems encountered So does this mean we don’t need to understand how to trou-bleshoot on our own, because SQL Server can now do everything for us? Of coursenot The tools have always given you a head start, and made things easier when start-ing on your SQL Server journey But the more you know, the better you’ll be able todetermine which tool can give you the information you need, and what you need to

do to solve the problems, including problems that are not detectable by the tools This section includes a wonderful selection of articles from 10 different experts,each describing one area of performance troubleshooting There is a focus onindexes because that’s an area where you can see immediate and drastic performanceimprovements But the section doesn’t just cover indexing options; it includes articles

on deadlocking, using metadata to diagnose system resource problems, examiningdisk I/O behavior, and using SQL Server’s ability to correlate the tracing tool with Per-formance Monitor

I wish to thank all the SQL Server MVPs for their ongoing generosity in providingsupport to the SQL Server community, and especially to the authors for helping tomake this book a reality

About the editor

Kalen Delaney has been working with SQL Server for almost 22years, and writing about it for almost 20 In addition to writing

deep technical books such as Inside SQL Server and SQL Server

2008 Internals, she writes courseware and delivers advanced

SQL Server training around the world

Kalen has been invited by Microsoft to present specialinternal training on many occasions She has spoken at Micro-soft Technical Education Conference (TechEd) and presented

at every PASS (Professional Association for SQL Server) Summitsince the organization’s inception She is delighted that herlove for SQL Server can be put to such good use in the publica-tion of this book

Trang 18

40 When is an unused index

not an unused index?

Rob Farley

Indexes can help you access your data quickly and effectively, but index overheadcan sometimes be costly Keeping an index updated when data is changing is onecost, but there is also the cost of extra storage space and the increased size of back-ups So if an index isn’t being used, you should remove it, right?

In this chapter, I’ll show you ways to find out if an index is used Then I’ll showyou a type of index that may appear to be unused even although it really is used.Hopefully this won’t leave you too disheartened about the idea of researching yourindexes but instead convince you of the power of SQL Server

Overview of indexing

My favorite analogy for indexes is telephone directories I’m not sure whether Iheard this analogy or came up with it—I just know that it’s a way of describingindexes that everyone grasps easily Like most analogies, it doesn’t fit completely,but on the whole it’s fairly good

In Australia, the company Sensis publishes two phone books: the Yellow Pages(which lists entries according to business type) and the White Pages (which liststelephone entries by surname or business name) I assume that somewhere there is

a list of all the information about the telephone numbers in Australia Nowadays itwould be electronic, but for the purpose of the analogy, we’re going to consider apaper-based system Suppose that the master list of the telephone number informa-tion is a massive folder stored at the telecommunication provider’s head office.Suppose also that it’s sorted by telephone number

This folder would not be useful if I wanted to look up the phone number of myfriend Andrew His number could be on any page of the folder, so I’d have to huntthrough the lot—starting on page one and continuing until I found him If he hadtwo numbers, I would have to keep looking to the end, even if it turned out he was

Trang 19

532 CHAPTER 40 When is an unused index not an unused index?

on page one If the folder contains millions of phone numbers, this would not be sible The folder is analogous to a clustered index in SQL Server The folder containsall the information that is available, and the phone number acts as the key to unlockit—providing order to the information and a way of identifying each individual record The White Pages is useful for finding Andrew’s phone number, though I knowAndrew’s surname, so I can find him very quickly As it’s sorted by surname, I can turnstraight to his record (almost—I might have to jump around a little) and see hisphone number there

As I only need his phone number, the White Pages (but I’d rather call it a tered index) is the only resource I need I can say that it covers my query But if Iwanted to get another piece of information, such as his billing number, I’d have to usehis phone number to look him up in the master folder In SQL Server land, this isknown as a key lookup

I won’t go further into indexes now Entire chapters could be written about bestpractices for indexes, and I want to make a point about unused indexes

Unused indexes

If I never used the White Pages, there would be no point in having it in that small board on which the phone sits I could put other, more useful stuff there What’smore, whenever someone moves or changes his name or phone number, the WhitePages must be updated Although I get a new physical copy only once a year, theonline version is updated much more often Perhaps if I were eager, I could keep myeye out for changes to the underlying data and keep my copy of the White Pages up todate But that would be arduous

The same principle applies to indexes in databases If we don’t use an index,there’s little point in having it around Learning how to find the indexes that aren’tused is a fairly useful skill for a database administrator to pick up, and SQL Server

2005 makes this easier

SQL Server 2005 introduced Dynamic Management Views (DMVs) that are usefulfor providing dynamic metadata in the form of queryable views There are other types

of system views, such as catalog views like the useful sys.indexes, but for finding outwhich indexes are used, the most useful view is the DMV sys.dm_db_index_usage_stats Let’s look at the structure of this view, by expanding the relevant part of theObject Explorer in SQL Server Management Studio (SSMS), which is in the SystemViews section under the database of interest Figure 1 comes from SQL Server 2008Management Studio, even though my queries are running against SQL Server 2005.I’m also using administrator access, although you only need VIEW DATABASE STATE per-mission to read from the DMV

Trang 20

Unused indexes

You’ll notice that the DMV lists the number of seeks, scans, lookups, and updates thatusers and the system perform, including when the latest of each type was done TheDMV is reset when the SQL Server service starts, but that’s just a warning to people whomight have thought that data remained there from long ago An index that isn’t usedwon’t have an entry in this view If no seeks, scans, lookups, or updates have been per-formed on an index, this view simply won’t list the index Incidentally, bear in mindthat to get the name of the index, you may want to join this view to sys.indexes You can also find out which indexes are used by looking at the execution plans thatare being used by the queries issued against the database This is even more useful, asthe impact of an index can be easily evaluated by its impact on individual queries Ifyou consider the performance gain on an individual query, and examine how oftenthis query is executed, you have a fantastic metric for the impact of an index Queryplans make it clear which indexes are being used, as an icon is shown for each indexscan or seek SQL Server 2008 Management Studio has significantly improved thereadability of execution plans by displaying only the table name and index name,rather than using the three-part naming convention for the table and the index name.Figure 2 is a screen shot of an execution plan from SSMS 2005 Compare it withfigure 3, which is a screen shot of an execution plan from SSMS 2008

Figure 1 The structure of sys.dm_db_index_usage_stats

Ngày đăng: 15/12/2013, 13:15

TỪ KHÓA LIÊN QUAN

w