SQL Server 2000

Published on May 2017 | Categories: Documents | Downloads: 39 | Comments: 0 | Views: 421
of 47
Download PDF   Embed   Report

Comments

Content

Microsoft®

SQL Server 2000
Chapter 4 System Administration
SQL Server 2000 Operations Guide

Abstract This chapter explains best practices for system administration in a Microsoft® SQL Server™ 2 environment! incl"din# re#"lar daily! $ee%ly! and monthly maintenance tas%s& 'ndex creation and maintenance is examined in thoro"#h detail& (ac%"p and restore is addressed! alon# $ith movin# data in vario"s $ays& Advanced administration! presented at the end of the chapter! incl"des topics concernin# memory mana#ement! lo# shippin#! and cl"sterin#& After readin# this chapter! database administrators $ill be able to determine the appropriate needs for their SQL Server 2 database environment! the tools and technolo#ies to be "sed! and a maintenance calendar for the most common administrative activities&

The information contained in this document represents the current view of Microsoft Corporation on the issues discussed as of the date of publication. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication. This Operations Guide is for informational purposes only. M C!O"O#T M$%&" 'O ($!!$'T &", &)*!&"" O! M*+ &,, $" TO T-& '#O!M$T O' ' T- " ,OC.M&'T. Complying with all applicable copyright laws is the responsibility of the user. (ithout limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means /electronic, mechanical, photocopying, recording, or otherwise0, or for any purpose, without the e1press written permission of Microsoft Corporation. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering sub2ect matter in this document. &1cept as e1pressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property.

© 3445 Microsoft Corporation. $ll rights reserved.
Microsoft, (indows, and "6+ "erver are registered trademarks or trademarks of Microsoft Corporation in the .nited "tates and7or other countries. The names of actual companies and products mentioned herein may be the trademarks of their respective owners. 4845

ONTENTS
Microsoft® SQL Server 2 ) )

SQL SERVER 2000 OPERATIONS GUIDE ..................................1 INTRODU TION.........................................................................1 T!E D"A TEAM..........................................................................1 *otation 2 +ffective ,se of Spare Time 2 Comm"nication 2 Alert Messa#es Team .eb Site Contin"o"s Learnin# Service Level A#reement 4 ADMINISTRATIVE TOPI S.........................................................# /oc"mentation and Standardi0ation 4 Tools! 1"nctionality! and Technolo#ies 2 Scriptin# 3 Transact4SQL 3 .indo$s Scriptin# 5ost 6.S57 8 'ndexes and Statistics 8 Cl"stered 9ers"s :on4cl"stered 'ndexes 8 Composite and Coverin# 'ndexes ; 1'LL1ACT<* Settin#s for 'ndexes ; 'ndex 1ra#mentation ) Statistics )) 'ndex and Statistics *ecommendations )) (ac%"p and *estore )2 Types of (ac%"ps )1"ll (ac%"ps )/ifferential (ac%"ps )Transaction4Lo# (ac%"ps )4 /atabase *ecovery )4 =oint4'n4Time *ecovery )4 1ile and 1ile#ro"p Strate#ies )2 (ac%"p Strate#ies )3 *ecovery Models )3 (ac%"p =erformance ); (ac%"p 9alidity 2 A"tomation 2) >obs 2) Alerts 22

/ata Movement /ata Transformation Services 6/TS7 /TS Connections and Tas%s *eplication Latency as a 1actor in *eplication (C= and (,L@ ':S+*T Lin%ed Servers Lo# Shippin# ,sin# (ac%"p and *estore to Move /ata /etachin# and Attachin# /atabases Comparison of /ata Movin# Strate#ies Movin# /atabases @eepin# Lo#ins Synchroni0ed Movin#A'mportin#A+xportin# /ataBLar#e or Small Amo"nts Startin# and Stoppin# Services <perations That *eC"ire a SQL Server *estart /(CC

22 2224 2? 2? 2? 2? 22 22 22 22 22 22 22 28 28

ADMINISTRATIVE S !EDULES...............................................2$ /aily Tas%s .ee%ly Tas%s Monthly Tas%s /atabase Maintenance =lan .i0ard -) ADVAN ED ADMINISTRATIVE TOPI S...................................%1 Availability and =erformance -) 5i#h Availability TechniC"es -2 Lo# Shippin# -2 1ailover Cl"sterin# -2 (ac%in# ,p and *estorin# -3 (ac%in# ,p to /is% and Tape -3 Lo# Shippin# and Cl"sterin# -8 Memory Mana#ement -; Advanced Memory Mana#ement -; Memory Allocation $ith Address .indo$in# +xtensions and =hysical Addressin# +xtensions -; Memory and =rocessor Mana#ement .ith M"ltiple 'nstances 4) SUMMAR&................................................................................#2 More 'nformation 42 .eb Sites 42 =apers 4(oo%s 4=rod"cts 4-

INTRODU T!E D"A TEAM TION
System administration of a Microsoft® SQL Server™ 2 environment is a %ey responsibility of any database administrator 6/(A7& SQL Server 2 offers many different f"nctions to assist the /(A in maintainin# and optimi0in# the environment& Altho"#h reso"rces are available $ithin SQL Server 2 for the /(A to create an optimal server environment! many /(As lac% the necessary s%ills or %no$led#e to ta%e advanta#e of these reso"rces& This chapter foc"ses on ed"catin# the /(A in common areas of system administration& A f"lly f"nctional and optimal environment has several definin# characteristics& 't isD • • • • • • /oc"mented A"tomated Standardi0ed *eliable Available <ptimi0ed

Administration of database systems consists of a variety of administrative! optimi0ation! and tro"bleshootin# tas%s& Since this #"ide has separate chapters on performance t"nin# 6see Chapter ?7 and tro"bleshootin# 6see Chapter 37! those topics are only briefly covered in this chapter& This chapter foc"ses on the follo$in#D • • • The team that is responsible for database administration Tools! f"nctionalities! and technolo#ies available to the database administrator The administrative maintenance tas%s to perform on a daily! $ee%ly! and monthly sched"le • Advanced concepts dealin# $ith lar#e4memory mana#ement! lo# shippin#! and cl"sterin# for hi#hly available systems The role of the database administrator 6/(A7! also %no$n as a database system en#ineer 6/S+7! has chan#ed over time& As databases have become more sophisticated! self4t"nin# and a"tomated administration feat"res have become more common& As a res"lt! the /(A is freed from $or%in# at a tactical level! and can foc"s on more strate#ic initiatives 6for example! analy0in# "sa#e trends to cyclically improve the database! and mana#in# the flo$ of information bet$een points $ithin a company or o"tside it7& S"ccessf"lly mana#in# a database system demands a strate#ic approach! and a hi#h level of acco"ntability in database administration practices& These concepts! $hich in this doc"ment are tar#eted at a data center $ith a team of database professionals! may be s"ccessf"lly tailored to apply to any database environment& To be s"ccessf"l! yo" m"st clearly define ho$ the team does b"siness $ith other teams in the company& 1or this to $or%! it is vital for all the /(As on the team to $or% as a "nit& To enco"ra#e team$or% and cooperation! be#in by assi#nin# shared o$nership for all the database servers to the entire #ro"p& +nco"ra#e and re$ard honesty and responsibility! to b"ild confidence in the team members& The s"ccess

Chapter 4 System Administration )

of the each team member depends on the s"ccess of the other team members& To share the responsibility of s"pportin# many systems! /(As m"st be available to each other d"rin# $or%in# ho"rs 6"sin# a cell phone or e4mail7 and d"rin# their non$or%in# ho"rs 6to some extent7 to ens"re the reC"irements of the SLA are met andAor exceeded& 'f yo" have a system that only one person can r"n! then yo" have introd"ced a sin#le point of fail"re into the system& This is $hy it is so important for the /(A team to act as an inte#rated "nit& Several thin#s can help yo" accomplish this&

Rot'tio(
Assi#n a primary and a secondary /(A for each system! so that there are at least t$o people s"pportin# each one& Also! rotate staff bet$een proEects! bet$een classes of server! and bet$een prod"ction and development environments& *otation enco"ra#es cross trainin#! provides breadth of experience! common practices! and leads to better doc"mentation& The interval bet$een rotations sho"ld be lon# eno"#h that the /(A can become comfortable $ith the system he or she is no$ handlin#&

Effective Use of S)'re Ti*e
Ma%e "se of spare time to brin# teammates "p to speed on "nfamiliar proEects or systems! or ne$ techniC"es that are bein# "sed by a member of the team& 'f there is no spare time! create time for /(A teamb"ildin#& 1indin# this time can be diffic"lt& 'ntrod"ce the concept of the Fbro$n ba#!G $here a presentation is held over a lon# $or%in# l"nch period 6)&? to 2 ho"rs7& =resentations at most maEor conferences ran#e from ) to 2 ho"rs in len#thH C"ite a bit of material can be covered this $ay! especially if meetin#s ta%e place $ee%ly& Another side benefit of a l"nch presentation is that each person is reC"ired to or#ani0e their notes! doc"ment the system in C"estion! and #et some practice addressin# a #ro"p&

o**+(ic'tio(
+nco"ra#e the development of comm"nication s%ills! both spo%en and $ritten& The /(A position is evolvin#! $ith less emphasis on server settin#s and more on mana#in# corporate %no$led#e& The company benefits most from /(As $ho can become leaders in the data center& Also! by establishin# a hi#h level of comm"nication and tr"st amon# team members! the teamIs overall response time $ill increase& As each /(A becomes familiar $ith other systems! the n"mber of iss"es that can be handled by only one person $ill diminish& As a res"lt! the /(As $ill not need to call each other as freC"ently for ans$ers! $hich can save val"able min"tes $hen a server is "navailable&

2

Microsoft SQL Server 2

<perations J"ide

't is cr"cial that the /(A #ro"p have respect $ithin the 'nformation Technolo#y 6'T7 department& 'f a professional and thoro"#h team is presented to the members of the operations and development #ro"ps! a certain respect $ill be #enerated that may be needed in the f"t"re to help the /(A #ro"p override any decisions that $o"ld pose a ris% to the system& Standard processes help to increase the rep"tation of the /(A teamIs serio"sness and reliability&

A,ert Mess'-es
1or conditions that are either escalated to a hi#h priority or remain "nresolved after a set amo"nt of time! consider sendin# alerts to the companyIs help des% in addition to the team members& The help des% sho"ld be able to locate the appropriate personnel 6even if their cell phone is t"rned off7& 'f no /(A is available! the iss"e can be escalated "ntil the problem is resolved& Arran#in# escalation thro"#h the help des% ta%es caref"l plannin#! especially in re#ard to ed"catin# the help des% team abo"t the types of alert messa#es they may receive! the escalation path $ithin the /(A #ro"p! and the people they can contact or the actions they can ta%e 6approved by the net$or% and sec"rity administrators7 if the entire /(A team is "navailable&

Te'* .e/ Site
Another mechanism for %eepin# the entire team in comm"nication is establishin# a team .eb site that displays C"ic% stat"s information for each server& 'n this case! the server behind the team .eb site $o"ld be incl"ded in the alert messa#es that the server broadcasts& +ach /(A team member co"ld post alerts as $ell! th"s comm"nicatin# "pcomin# events or important proEect or system notes to the #ro"p in a centrali0ed manner& This team site can be#in as a simple net$or% share! private to the /(A team& Creatin# a $orld4class database administration service is a cycle& 'mprovements are introd"ced over time! and this effort yields the #reatest benefitD the improvement of the people $ho s"pport the system! by increasin# their %no$led#e and "nderstandin# of the prod"ct&

o(ti(+o+s Le'r(i(/(As need time to learnH database technolo#ies are constantly evolvin#! as is the theory "pon $hich they are based& .hen leadin# a team! be s"re to create time for the team members to learn& 'f part of a team! be persistent in seeking new training and providin# E"stification for it& +nco"ra#e everyone to learn contin"o"sly 6one chapter or s"bsection at a time7! rather than all at once& 9ery lar#e #oals are hard to achieve& 'nstead! enco"ra#e the team to ta%e a cross4section of available materials on a sin#le topic& 1or example! if the #oal is to learn replication! read abo"t it from different so"rcesD boo%s! trade Eo"rnals! .eb sites! ,senet #ro"ps! and so on& Then move to a ne$ s"bEect as the

Chapter 4 System Administration -

ADMINISTRATIVE TOPI S
need or interest chan#es& =resentin# material reinforces ne$ s%ills! and also benefits the #ro"p& The company $ill benefit from this ed"cational investment& =eople $ho %no$ the system best! $ho have ne$ %no$led#e and deeper levels of "nderstandin#! can contin"e to raise the standard for creatin# and maintainin# hi#hly available systems& 't all starts $ith the ri#ht mindset for hi#h availability and d"e dili#ence in all efforts&

Service Leve, A-ree*e(t
The main p"rpose of a service level a#reement for a database system is to establish the expectations that the mana#ement and the "sers have for the system& See Chapter 8 for a detailed disc"ssion of service level a#reements! and their effect on the /(AIs role& ("ildin# a healthy and optimal SQL Server 2 environment reC"ires not only a technical %no$led#e of SQL Server 2 ! its components! and the practical application of those components! b"t also ho$ SQL Server fits into the overall sol"tion or tas% that responds to the b"siness need& @eepin# the data correct! sec"re! and available at all times is the primary foc"s of the /(A&

Doc+*e(t'tio( '(0 St'(0'r0i1'tio(
/oc"mentation and standardi0ation of the SQL Server 2 environment is important to existin# personnel and to ne$ly hired /(As& The /(A is completely responsible for decidin# on the level and depth of the covera#e& /oc"mentation #enerally incl"des the follo$in#D • • • • • Components of the environment =rocesses =rotocols Contact information 'ss"e resol"tion history

Components of the environment incl"de not only the server hard$are and soft$are! b"t also the net$or% infrastr"ct"re! s"ch as T) lines! and the s"ppliers of #oods and services! as $ell as the vario"s staff members involved& =rocesses describe the steps involved in completin# an operation& The operation co"ld be anythin# from addin# a ne$ lo#in to a server to performin# a disaster4 recovery operation& =rotocols are the r"les #overnin# the operations& The r"les ens"re that all of the operations are performed in a consistent and established $ay& Contact information sho"ld be maintained for those $ho are involved $ithin the or#ani0ation and o"tside of it& Those individ"als and #ro"ps $ithin the or#ani0ation

4

Microsoft SQL Server 2

<perations J"ide

incl"de /(As! developers! net$or% personnel! help4des% personnel and mana#ement& Those individ"als and #ro"ps o"tside the or#ani0ation incl"de hard$are representatives and application soft$are representatives 6both sales and s"pport7& Telephone n"mbers! fax n"mbers! cell n"mbers! sched"les! and bac%"p 6secondary7 contact information sho"ld be maintained& 'ss"e4resol"tion history incl"des all steps and contacts involved in resolvin# past prod"ction iss"es 6see Chapter 3 on problem and incident mana#ement7& 5istory sho"ld be stored in a searchable database $ith an easy4to4"se interface! preferably .eb based! to expedite the resol"tion of f"t"re iss"es& Standardi0ation is the %ey to simplifyin# administration& Any operation that can be scripted! sho"ld be scripted! and those scripts sho"ld be doc"mented and maintained& Typically scripts and other critical information are %ept in a r"n boo% and sho"ld be revie$ed and "nderstood by all c"rrent and ne$ /(As 6see Chapter 2 for additional information on creatin# a r"n boo%&7 Standardi0in# confi#"rations across servers is "sef"l in any environment& To do this! create a list of all available settin#s on the server that are not the defa"lt val"e! and doc"ment them& Ma%e this the standard confi#"ration for every ne$ machine& <bvio"sly! many of the systems may immediately depart from the standard& To handle this! simply doc"ment the difference for that machine bet$een the standard confi#"ration and the confi#"ration for the server in C"estion& These doc"ments! stored as read4only files in an easily accessible area 6a .eb repository $o"ld be #ood7! can help yo" better s"pport a lar#e n"mber of servers& 1or the stora#e s"bsystem! standardi0in# drive letters is very helpf"l& Table 4&) provides examples of possible drive4letter desi#nations& Table 4.1 rive!letter esignations Description
<peratin# system! SQL exec"tables ,s"ally a C/4*<M drive *eserve for another system drive! if needed Tempdb /ata files Q"or"m drive SQL exec"tables and system databases Transaction lo# files (ac%"ps! or imported data for b"l% loadin# A standard admin directory to store reports s"ch as lo#s! trace res"lts! s"ldiag.e#e o"tp"t! and so on

Logical Drive Letter
C / + 1 thro"#h 5 ' thro"#h = Q *! S T thro"#h 9 K! L! M NSQLAdmin

1or net$or% drives! consider "sin# "niversal namin# conventions 6,:C7! to allo$

Chapter 4 System Administration ?

maxim"m portability of the code relyin# on these net$or% drives& :o matter ho$ metic"lo"s the standardi0ation is! there are times $hen exceptions m"st be made& Simply doc"ment them! and move onH the #oal is to ma%e ; percent of it standard! and then the remainin# ) percent $ill be easier to remember&

Too,s2 3+(ctio(',it42 '(0 Tec5(o,o-ies
SQL Server 2 ! the .indo$s 2 platform! other Microsoft prod"cts! and vario"s third4party tools! f"nctionalities! and technolo#ies can be inte#rated to create a complete SQL Server 2 administration sol"tion& The tools and "tilities "sed and ho$ they are "sed $ill depend on several factors! incl"din# the follo$in#D • • • • • • +nvironment Mana#ement .or%load Cost =reference ,nderstandin#

A simple and effective example is "sin# a c"stom Microsoft Mana#ement Console 6MMC7 that incl"des the +nterprise Mana#er snap4in 6incl"din# external tools7 and other relevant snap4ins& Lin%s to Microsoft&com 6incl"din# the SQL Server .eb site! Tech:et! and MS/:7 and other "sef"l .eb sites can be inte#rated into the MMC also! to easily b"ild a dynamic mana#ement tool& 6See 1i#"re 4&)&7

2

Microsoft SQL Server 2

<perations J"ide

#igure 9.5 Console !oot

Note: This chapter will focus primarily on SQL Server 2000 functionality. For additional information on Windows 2000 and other Microsoft technologies see hapter !" Monitoring" and the For More #nformation section at the end of this chapter.

Scri)ti(Tr'(s'ct6SQL

'n #eneral! it is better to "se scripts to perform all repetitive operations! $hich are then t"rned into stored proced"res for exec"tion& Scripts red"ce the possibility and occ"rrence of "ser errors& Scripts sho"ld be doc"mented "sin# inline and bloc% comments $ithin the script! and readme&txt or &doc files o"tside the script& Scripts sho"ld be maintained in a centrally sec"red directory str"ct"re for all SQL Servers or! if possible! in a library versionin# tool! s"ch as Microsoft 9is"al So"rceSafe! so that the master copy $ill al$ays be %no$n! and there $ill be no ambi#"ity as to $hich is the c"rrent prod"ction version& Scripts can al$ays be "sed $here the #raphical "ser interface 6J,'7 interfaces and $i0ards may be limited to a certain set of operations $ith only some of the available options& <perations that ta%e place via J,' interfaces and $i0ards can be capt"red! saved! and replayed "sin# SQL =rofiler& 'n addition! "sin# the FSave Chan#eG script b"tton in +nterprise Mana#er means chan#es in obEects s"ch as tables can easily be scripted& This can be very beneficial to an inexperienced /(A $ho "ses +nterprise Mana#er to perform administrative tas%s and is not s"re $hat is ta%in# place behind the scenes& <perations that ta%e place thro"#h c"stom or third4party applications can also be capt"red "sin# SQL =rofiler& /oin# so can assist all /(As in tro"bleshootin# application f"nctionality and performance iss"es& :e$ scripts sho"ld be thoro"#hly tested in a C"ality ass"rance 6QA7 environment prior to their introd"ction into the prod"ction environment& Scripts for rollbac%s sho"ld be created and maintained as $ell& A simple and effective $ay to create similar scripts is to "se the script templates feat"re of the <bEect (ro$ser in Q"ery Analy0er& Templates allo$ /(As to re"se code and lo#ic simply by replacin# template parameters $ith ne$ val"es& The scripts can then be saved to the appropriate folder& To ens"re a"tomation! consistency! sec"rity! and history! the /(A sho"ld encaps"late scripts into stored proced"res& The stored proced"res can contain additional lo#ic to #ive /(As finer control over the operations& 'n addition! they can contain additional code to record information in c"stom tables 6that is! a"ditin#7& These tables can be "sed $ith tri##ers and e4mail to provide enhanced c"stomi0ed sol"tions& To ma%e the process even better! /(As can $or% $ith developers to create a c"stom front4end .eb interface that can be "sed by /(As on any server $ithin the environment&

Chapter 4 System Administration 3

.i(0o7s Scri)ti(- !ost 8.S!9

The .indo$s Scriptin# 5ost 6.S57 enables ActiveK scripts s"ch as 9(Script or >script to be r"n directly $ithin a .indo$s 2 environment& The "ser simply has to exec"te the &vbs file E"st li%e a $%d&#ec file& The .S5 has lo$ memory reC"irements and is more rob"st than MS4/<S commands& Administrators can chan#e scripts easily $itho"t havin# to recompile or contact a developer& Th"s! .S5 is ideal for certain administrative f"nctions of a /(A& 1or example! if a /(A needs to recreate a SQL Server 2 sec"rity environment! the /(A can create one 9(Script to create the domain "ser and #ro"p acco"nt and another Transact4SQL 6T4SQL7 script to create the database lo#ins! roles! and "sers&

I(0e:es '(0 St'tistics
'ndexes are stora#e str"ct"res $ithin SQL Server 2 that allo$ developers to "niC"ely identify records in a table 6this is called entity inte#rity7 and allo$ /(As to increase performance& The 'ndex T"nin# .i0ard 6'T.7 allo$s administrators to easily script o"t the creation and drops of indexes based on capt"red real4$orld C"eries& 1or more information! see F'ndex T"nin# .i0ardG in SQL Server (oo%s <nline&
,+stere0 Vers+s No(6c,+stere0 I(0e:es

There are t$o cate#ories of indexes availableBcl"stered and non4cl"stered& Cl"stered indexes store the act"al data pa#es at the leaf level of their b4tree str"ct"re& The records are physically sorted and stored based on the cl"stered index %ey chosen& 1or this reason! there can be only one cl"stered index on a table at any #iven time& :on4cl"stered indexes store pointers to the data& The pointer chosen $ill depend on $hether or not a cl"stered index exists for the table& The records are sorted lo#ically! based on the non4cl"stered %ey chosen& There can be "p to 24; non4 cl"stered indexes for a sin#le table& 'n the scenario $here a table has a cl"stered index! the non4cl"stered indexes $ill "se the cl"stered index %ey as their pointer to the data& 1or this reason cl"stered4 index %ey val"es sho"ld be %ept at a minim"m len#th& The lar#er the %ey! the lar#er the ro$! the fe$er ro$s that fit on a pa#e! the more pa#es reC"ired! the more 'A< needed to read the pa#es! and the fe$er plans and pa#es that $ill be fo"nd in cache the second time aro"nd beca"se ne$ pa#es $ill ta%e their place& All of this contrib"tes to a si#nificant increase in the SQL Server and system reso"rces "sed! $hich can res"lt in a si#nificant decrease in performance& Since any #iven table can have only one cl"stered index! care sho"ld be ta%en in choosin# $hich col"mn6s7 to index& Jenerally it is best to create a cl"stered index in cases $here data is one of the follo$in#D • *etrieved in sorted order

8

Microsoft SQL Server 2

<perations J"ide

• •

Jro"ped to#ether Accessed in a ran#e

A cl"stered index mi#ht also be considered on an a"to4incrementin# col"mn! s"ch as an identity col"mn! to minimi0e pa#e splittin# and to %eep the pa#e that is receivin# the inserts constantly in the b"ffer cache to improve performance& (e caref"l $hen choosin# m"ltiple col"mns for a cl"stered index& Statistics $ill only be created for the first col"mn of a composite 6m"lti4col"mn7 index& To provide the Q"ery <ptimi0er $ith more information abo"t the distrib"tion of the other col"mn6s7 val"es! consider creatin# statistics for the other col"mn6s7 by "sin# the C*+AT+ STAT'ST'CS Transact4SQL statement& Limit the n"mber of non4cl"stered indexes that are created in $rite4intensive prod"ction systems& The reason for this recommendation is that non4cl"stered indexes contain pointers to the data& 1or each insert or delete that is made on a table! SQL Server m"st not only perform and lo# that operation! it also has to chan#e each non4cl"stered index that is affected& This can have an adverse effect on performance&
o*)osite '(0 overi(- I(0e:es

The /(A sho"ld create indexes to match the search criteria of the "serIs reC"est& 'ndexes that are not "sed are not "sef"lH in fact! they red"ce performance by the load reC"ired to maintain them& Create composite 6m"lti4col"mn7 indexes $henever possible to cover m"ltiple reC"ests& The /(A can also consider the performance advanta#es of "sin# a coverin# index& A coverin# index is a non4cl"stered index that contains all the information reC"ested by the "ser in the indexIs leaf level 6incl"din# the %ey and the pointer7& /(As sho"ld not FrecreateG the table by addin# too many col"mns to the index %ey& Coverin# indexes can res"lt in a dramatic increase in performance& :on4cl"stered indexes are better s"ited to C"eries that are loo%in# for a specific record& Col"mns that are freC"ently a##re#ated sho"ld be indexed! as sho"ld any forei#n %ey col"mns! to increase performance $hen performin# Eoins& To speed the creation of an index in sit"ations $here the te%pdb database resides on a separate dis% $ith possibly a separate controller! "se the S<*TO':OT+M=/( ar#"ment& This ar#"ment tells SQL Server to store the intermediate sort res"lts in the te%pdb database& The operation separates the reads and $rites bet$een the te%pdb database and the destination file#ro"p! $hich increases performance! especially $hen te%pdb is on a faster drive& 't also improves the li%elihood that the index $ill "se conti#"o"s extents&
3ILL3A TOR Setti(-s for I(0e:es

.hen b"ildin# an index it is important to specify ho$ f"ll to ma%e the pa#es of the index& The f"llness can be controlled $ith the 1'LL1ACT<* and =A/O':/+K ar#"ments& The 1'LL1ACT<* ar#"ment sets the f"llness for the leaf level of the b4 tree index by specifyin# the percenta#e of empty space on each pa#e& 1or cl"stered indexes! the leaf4level pa#es are the act"al data pa#es& The defa"lt behavior is to

Chapter 4 System Administration ;

fill the leaf4level pa#es completely& Altho"#h a hi#her 1'LL1ACT<* is advanta#eo"s for read operations! it can be very detrimental to $rite operations& A hi#h 1'LL1ACT<* in a read4intensive environment $ill mean more records per pa#e and th"s fe$er pa#es and less 'A<& Conversely! the same settin# in a $rite4 intensive environment $ill ca"se massive pa#e splittin#! th"s fra#mentin# the data across the pa#es allocated to the table& 'n #eneral! it is best to choose an appropriate 1'LL1ACT<* settin# and to specify this val"e $hen creatin# the index& The percenta#e chosen $ill vary for each table in each database! dependin# on the environment& Thin#s to consider incl"de the follo$in#D • • • • =ercenta#e of reads and $rites for the table Modification activity Space "sed =erformance

The n"mber of read and $rite operations for a #iven table $ill be "sed to determine the 1'LL1ACT<* settin#& A hi#her 1'LL1ACT<* is appropriate in environments $here data $ill primarily be analy0ed& A lo$er 1'LL1ACT<* sho"ld be "sed in heavily modified environments& *emember that modification activity on a table $ith a hi#h 1'LL1ACT<* can red"ce performance& ("t $hen exactly do the b"l% of the modifications ta%e placeP 's it once a $ee%! once a day! thro"#ho"t a 244ho"r period! or perhaps $ithin a certain ran#e of ho"rsP A lo$er 1'LL1ACT<* reC"ires more pa#e 'A< and dis% space that can impair performance& So $hat sho"ld the 1'LL1ACT<* settin# beP The ans$er to this and many other optimi0ation C"estions is "nfort"natelyB F't depends&G The #eneral #"idelines have been presented above! and it is "p to the /(A to choose the appropriate settin# $hen creatin# the index! dependin# on the vario"s factors involved& The /(A can then "se the /(CC S5<.C<:T'J statement to monitor fra#mentation over time& 'f the ori#inal settin# $as too hi#h or too lo$! the index can easily be reb"ilt and testin# can contin"e& Note: The F#LLF$ T%& setting can 'e set server(wide for all &)$T) #*+), statements using sp-configure .F#LLF$ T%&. / 1or very heavily modified tables! the /(A may consider "sin# the =A/O':/+K option to apply the 1'LL1ACT<* percenta#e to the non4leaf or intermediate pa#es of the index&
I(0e: 3r'-*e(t'tio(

The 1'LL1ACT<* and =A/O':/+K settin#s are static! and over time indexes can become fra#mented beca"se of data modifications& Some pa#es $ill become f"ller than others& Some pa#es $ill split! and ne$ pa#es $ill have to be allocated! lin%ed into the chain and $ith half the data moved to the ne$ pa#e& This process can be expensive! and many times these ne$ pa#es are not conti#"o"s! nor even in the same extent! b"t are allocated from another extent on dis%& 1ra#mentation can be controlled in one of t$o $aysD by reb"ildin# the index or by defra#mentin# the index& *eb"ildin# the index sho"ld be done $ith the C*+AT+ ':/+K statement "sin# the /*<=O+K'ST':J ar#"ment& The advanta#e of this approach over the approach of

)

Microsoft SQL Server 2

<perations J"ide

droppin# and recreatin# the index is that! in the case of a cl"stered index! if the cl"stered index %eys remain the same! non4cl"stered indexes $ill not have to be reb"ilt! nor $ill the data have to be resorted& Note0 $ll inde1es can 'e re'uilt for a ta'le in a single operation using the +2 statement. +2&)#*+),

The /(CC ':/+K/+1*AJ statement can be "sed to defra#ment an indexIs leaf4 level pa#es& 't does this by performin# an in4place reorderin# of the leaf pa#es so that the lo#ical order of the pa#es matches the physical order of the pa#es& /(CC ':/+K/+1*AJ also attempts to apply the ori#inal 1'LL1ACT<* settin# to compact the records on the pa#es& The maEor advanta#e of "sin# this command! as compared to the other processes! is that this is an on4line operation! $hich allo$s "sers to contin"e to "se the index $hile the operation is ta%in# place&
St'tistics

Statistics store distrib"tion information abo"t the %ey val"es in a col"mn& The C"ery processor "ses this information $hen decidin# ho$ to process a #iven C"ery& (y defa"lt! statistics are created a"tomatically for the first col"mn of an index %ey $hen an index is created on a table that contains data& Statistics can also be created on other col"mns of the %ey and on col"mns not associated $ith an index& This process provides SQL Server $ith more information abo"t the distrib"tion of the dataBth"s res"ltin# in a more efficient exec"tion plan bein# chosen and #enerated& Statistics of this type can be created either a"tomatically by settin# the option $ith the ALT+* /ATA(AS+ statement or sp'dboption( or man"ally by "sin# the C*+AT+ STAT'ST'CS statement& Statistics can be fo"nd in the binary statblob col"mn of the s)sinde#es table and can be vie$ed "sin# the /(CC S5<.OSTAT'ST'CS statement& The defa"lt behavior is to have SQL Server create the statistics a"tomatically& Note0 Statistics that are automatically generated 'y SQL Server will appear in the sysinde1es ta'le using a value ranging from 2 to 2!0. The name of the statistic will 'egin with W$-Sys-. The attri'utes +pages" reserved" and used will all show the value 0 34ero5. The "sef"lness of statistics is dependent on their acc"racy& Statistics that are o"t of date can lead to an inefficient plan bein# #enerated! $hich $o"ld affect performance& To prevent this from happenin#! SQL Server 2 a"tomatically "pdates all statistics& WARNING: +2$s should thin6 carefully 'efore deciding to disa'le the automatic updating of statistics.
I(0e: '(0 St'tistics Reco**e(0'tio(s

'ndexes sho"ld be created to increase performance and to maintain "niC"eness of the records& <ver time! by analy0in# the operations for a database! /(As $ill be able to determine the best time to reb"ild or defra#ment indexes& These operations sho"ld be scripted and placed in Eobs that ta%e place on a rec"rrin# basis dependin# on the environment& These Eobs sho"ld be sched"led d"rin# non4pea% ho"rs the performance of the system is not affected& .hile allo$in# SQL Server to

Chapter 4 System Administration ))

a"tomatically "pdate statistics $or%s for most environments! it does not $or% for all environments& 'f the statistics for the environment are not "pdated as freC"ently as needed by the application! $hich may impact performance and potentially availability! a Eob sho"ld be created to man"ally "pdate the statistics! and the auto update stats parameter sho"ld be disabled for the database&

"'c;+) '(0 Restore
+very database environment sho"ld have an established bac%"p and restore plan for disaster recovery& This plan sho"ld be thoro"#hly tested and doc"mented in a sim"lated environment "sin# prod"ction bac%"ps& The plan sho"ld also address the entire system! incl"din# applications and the components of the operatin# system& All possible scenarios of fail"re sho"ld be considered and addressed& Tests sho"ld be carried o"t on a re#"lar rec"rrin# basis& The specifications of this plan $ill depend on the environment& The follo$in# are several factors the /(A sho"ld consider $hen creatin# this planD • • • • Availability reC"irements Cost 6both reso"rce cost and do$ntimeArecovery cost7 C"rrent and f"t"re reso"rces 6both hard$areAsoft$are and personnel7 The environment

The availability reC"irements are dictated by the service level a#reement 6SLA7 6see Chapter 87& Chec% the SLA to ens"re compliance $ith its #oals and directives& Cost and reso"rces play a %ey role& 5o$ lon# can the system be do$nP 5o$ m"ch data can be lostP /oes the company have a /(AP 's the /(A s"itably trainedP 's there a secondary /(A $ho has been trained to perform recovery operationsP 5o$ m"ch money does the /(A have to allocate for eC"ipment! soft$are and trainin#P The environment $ill dictate the people! the processes and protocols involved! incl"din# the type of bac%"ps performed! their sched"les! and the recovery models "sed& T*ink o+ t*e backup,restore plan as a co%ponent o+ a data insurance polic). SQL Server 2 provides the tools necessary to bac% "p and restore both system and "ser4defined databases& These tools incl"de +nterprise Mana#er! /atabase Maintenance =lan .i0ards! and the (AC@,= and *+ST<*+ Transact4SQL commands& To prevent accidental mista%es or to add an additional level of sec"rity to prevent "na"thori0ed access! /(As sho"ld consider "sin# a bac%"p4set pass$ord andAor a media4set pass$ord& The bac%"p4set pass$ord prevents "na"thori0ed restores of the bac%"p set& The media4set pass$ord prevents "na"thori0ed restores of any of the bac%"p sets contained on the media& The pass$ord also prevents "na"thori0ed bac%"ps to the media itself& Note: $dding a media(set password prevents other product 'ac6ups" such as Windows 2000

)2

Microsoft SQL Server 2

<perations J"ide

'ac6ups" from 'eing appended to the media.

T4)es of "'c;+)s
There are several types of bac%"ps availableBf"ll! differential! transaction lo#! and fileAfile#ro"p& 'n addition to the different types! there are several recovery models availableBsimple! b"l%4lo##ed! and f"ll&
3+,, "'c;+)s

1"ll database bac%"ps are the defa"lt and the startin# point for all other types of bac%"ps& A f"ll database bac%"p capt"res the entire database! incl"din# all entries in the transaction lo#Bexcl"din# any "nallocated extents in the file6s7& =a#es are read directly from dis% to increase the speed of the operation& 1"ll database bac%"ps sho"ld be performed on system and "ser4defined databases on a re#"lar basis 6see Administrative Sched"les later in this chapter7& The %aster and %sdb databases sho"ld be bac%ed "p any time a chan#e occ"rs that affects either database& .hen creatin#Aalterin# databases! lo#ins! lin%ed servers! confi#"ration chan#es! and so on! bac% "p the %aster database& .hen creatin#Aalterin# Eobs! alerts! operators! sched"les! and so on! bac% "p the %sdb database& The distribution database sho"ld be bac%ed "p as $ell if the server is performin# the distrib"tion role& The %odel database can also be bac%ed "p if si#nificant chan#es have been made to it& Note: To ma6e recovery faster" easier" and more complete" always have an up(to(date 'ac6up of the master and msdb data'ases. $lso" it is recommended that user(defined o'7ects not 'e created in either of these system data'ases. 1"ll database bac%"ps to "ser4defined databases sho"ld ta%e place follo$in# the creation of the database to #ive the recovery process a startin# point& A f"ll database bac%"p sho"ld also ta%e place on a re#"larly sched"led basis& The sched"le $ill depend on the circ"mstances 6a#ain see Administrative Sched"les later in this chapter7& Note: $ full data'ase 'ac6up does not clear the transaction log. $ process should 'e initiated to clear the log periodically to prevent the log from filling up. $ny transactions that were in progress" however" during the data'ase 'ac6up will 'e included in the 'ac6up.
Differe(ti', "'c;+)s

/ifferential bac%"ps capt"re all the data that has chan#ed since the last f"ll database bac%"p& /ifferential bac%"ps $ill increase the speed of the bac%"p operation as $ell as the restore& Since only the chan#ed or ne$ly allocated extents 6bitmap trac%in#7 are capt"red! differential bac%"ps are faster and smaller than f"ll database bac%"ps& Also! in a recovery process! the last differential bac%"p can be restored $itho"t applyin# a series of the individ"al transaction4lo# bac%"ps or differential bac%"ps that too% place bet$een the last f"ll database bac%"p and the last differential bac%"p 6all chan#ed data is capt"red in the last differential bac%"p7&

Chapter 4 System Administration )-

Note: +ifferential 'ac6ups do not allow point(in(time or mar6ed log recovery.
Tr'(s'ctio(6Lo- "'c;+)s

Transaction4lo# bac%"ps capt"re modifications to the database& The transaction lo# serially capt"res these modifications& (ac%"ps of the transaction lo# provide a history of the transactions that have ta%en place $ithin the database& The bac%"ps of the lo# are then "sed in the recovery process to restore the database f"lly! to a point in time 6ST<=AT7 or to a mar% in the lo# 6ST<=ATMA*@ or ST<=(+1<*+MA*@7& Transaction lo# bac%"ps are applied to recover a database by rollin# for$ard 6redo7 any committed chan#es not reflected in the database and rollin# bac% 6"ndo7 any "ncommitted transactions& Lo# bac%"ps are smaller and are ta%en more freC"ently than f"ll or differential bac%"ps&

D't'/'se Recover4
There are several $ays to brin# the database bac% to a partic"lar time to correct a "ser or application error& The database! differential or transaction4lo# bac%"p co"ld be restored .'T5 *+C<9+*L to brin# the database bac% to the state at the time of the bac%"p& .hen $or%in# $ith transaction lo# bac%"ps! the database can be restored to a point4in4time or to a mar%ed transaction&
Poi(t6I(6Ti*e Recover4

=oint4in4time recovery only $or%s $ith transaction4lo# bac%"ps& The /(A $ill "se the ST<=AT ar#"ment of the *+ST<*+ statement to specify a date and time to recover the database& .ith many prod"ction databases no$ $or%in# $ithin many different international time 0ones! it is imperative that the /(A calc"late the correct date and time from the "ser reportin# the error& The ST<=AT option cannot be combined $ith :<O*+C<9+*L to test for the incorrect dataBth"s the correct time is needed& Any transactions that have not been committed prior to the date and time specified in the *+ST<*+ command $ill be rolled bac%Bres"ltin# in a loss of $or%& Mar%ed transactions #ive the /(A #reater control in determinin# $hen an errant transaction too% place and ma%e the recovery process m"ch easier& The transaction is #iven a name $ith the (+J': T*A: statement and the name is stored in the lo# "sin# the .'T5 MA*@ ar#"ment& 'f the /(A needs to recover from an errant statement! the /(A can specify either ST<=(+1<*+MA*@ or ST<=A1T+*MA*@ to control $hether or not the statement is applied to the database& The ST<=(+1<*+MA*@ ar#"ment does not incl"de the mar%ed transaction in the restore& The ST<=A1T+*MA*@ $ill incl"de the mar%ed transaction in the restore& Any transactions that are not committed prior to or follo$in# the mar% 6dependin# on $hich option is chosen7 $ill not be reflected in the database& Note: When mar6 names are the same within the transaction log" use the $FT)& datetime argument to differentiate 'etween them. Lo# space sho"ld be set to #ro$ a"tomatically and the amo"nt of lo# space sho"ld be constantly monitored either thro"#h scripts and a"ditin# tables or thro"#h a performance condition alert on Ob-ect . SQL Server: Databases $ounter/

)4

Microsoft SQL Server 2

<perations J"ide

Pe3rcent Log Used. 'f the transaction lo# fills! all activity in the database is stopped "ntil the lo# is cleared or "ntil the lo# is increased in si0e& 'f the lo# fills! try to clear the lo# $ith the (AC@,= L<J statement or try to increase the si0e of the lo# file 6or add an additional lo# file7 $ith the ALT+* /ATA(AS+ commandBthe file can be shr"n% later if needed& 'f neither method $or%s! clear the lo# $ith the (AC@,= L<J statement "sin# :<OL<J or T*,:CAT+OL<J ar#"ments& A f"ll database bac%"p sho"ld immediately follo$ clearin# the lo# to minimi0e the chances of lost data! beca"se the lo# no lon#er contains the committed transactions& The transaction lo# sho"ld be placed on a fa"lt4tolerant set of drives that are separate from the act"al data& This $ill increase performance! since the $rites to the lo# file6s7 are $ritten seC"entially and the $rites to the data file6s7 are "s"ally $ritten randomly thro"#ho"t the pa#es of the file6s7& 1"rthermore! separatin# the lo# file6s7 from the data file6s7 also decreases data loss as the orphaned lo# can still be capt"red in the event that the data file6s7 become dama#ed& 1reC"ent transaction lo# bac%"ps can red"ce data loss& /ifferential bac%"ps sho"ld be implemented as $ell in this scenario to red"ce recovery time and to red"ce data loss& Note: When attempting to ma6e 'ac6ups of the transaction log when the data'ase is in a simple recovery mode or the truncate log on chec6point option is ena'led" the )nterprise Manager transaction log option will 'e grayed out and Query $naly4er will return the error num'er 8209. To perform transaction log 'ac6ups" these options must not 'e set. The first step in recoverin# a dama#ed database sho"ld be to attempt to capt"re the orphaned part of the transaction lo#& This is possible $hen the data file6s7 become dama#ed and the master and the database lo# are still intact& Altho"#h the database $ill sho$ "p as s"spect! the /(A can still bac% "p the entire transaction lo# from the time of the last transaction lo# bac%"p thro"#h the time $hen the database file6s7 became dama#ed& This can be accomplished "sin# the :<OT*,:CAT+ ar#"ment of the (AC@,= L<J statement& Note: $n un'ro6en se:uence of transaction log 'ac6ups is re:uired for a full recovery. #f any transaction log 'ac6up is damaged or missing" no other transaction logs that followed that log 'ac6up can 'e applied. The last bac%"p to be restored in a recovery process sho"ld be the orphaned transaction lo# 6if it co"ld be capt"red7 or the last available transaction lo# bac%"p& 1or all bac%"ps restored prior to the last one! the /(A sho"ld specify the :<O*+C<9+*L ar#"ment& 1or the last bac%"p restored! the /(A sho"ld accept the defa"lt of *+C<9+*L& The :<O*+C<9+*L ar#"ment prevents the bac%"p that $as restored from bein# recovered! th"s allo$in# f"t"re bac%"ps to be restored& So if a transaction had its (+J': T*A: capt"red as part of one transaction lo# bac%"p and its C<MM'T T*A: capt"red in another! the restore of the first $ith :<O*+C<9+*L follo$ed by the last $ith *+C<9+*L $o"ld allo$ the transaction to be rolled for$ard and reflected in the database follo$in# recovery&

Chapter 4 System Administration )?

Note: #f a transaction log 'ac6up is restored with &) %;)&<" no additional logs can 'e applied. #f additional logs e1ist" the restore process must 'e started over" 'eginning with the last full data'ase 'ac6up. Microsoft $or%s very closely $ith vario"s third4party providers of transaction4lo#4 based soft$are& These soft$are prod"cts ma%e it easier to vie$ and $or% $ith the transaction lo#& .ith these prod"cts! "sers can create "ndo statements that reverse the $or% of prior transactions in the lo# $itho"t restorin# the transaction lo#& To find lin%s to these vendorsI .eb sites! please see the 1or More 'nformation section at the end of this chapter& Note: areful consideration and precautions should 'e ta6en prior to wor6ing with individual entries in the transaction log.
3i,e '(0 3i,e-ro+) Str'te-ies

1ile and file#ro"p bac%"p strate#ies are "sef"l in environments $ith very lar#e databases 69L/(7& A database comprisin# m"ltiple files can be bac%ed "p one file at a time& The file bac%"ps can occ"r on a sta##ered sched"le! a strate#y $hich red"ces the bac%"p time si#nificantly& To bac%"p #ro"ps of files at the same time! file#ro"p bac%"ps can be initiated& $hen this is done! restore times are red"ced beca"se only a part of the database is act"ally restored . 1ile and file#ro"p bac%"ps re"uire havin# transaction4lo# bac%"ps as $ell to brin# the recovered file6s7 "p4to4 date $ith the remainin# database files at recovery time& CAUTION: Transaction(log 'ac6ups need to occur and must 'e availa'le to recover individual data'ase files. This includes the tail end or orphaned part of the log. #f these logs are not availa'le and the file cannot 'e restored to a state consistent with the remaining data'ase files" the data'ase will have to 'e recovered from the last full data'ase 'ac6up. 1ile differential bac%"ps can also be incl"ded as part of the file bac%"p strate#y& Similar to database4differential bac%"ps! file4differential bac%"ps capt"re only the modifications and allocations of extents that belon# to the file that is bein# bac%ed "p& This res"lts in smaller and faster bac%"ps and restores . A sin#le differential file bac%"p can be created for m"ltiple files that are bac%ed "p independently . .hen a sin#le file is restored! only the last differential4file bac%"p needs to be restoredBno prior differential4file bac%"ps need to be restored& Also! to increase efficiency! only the extents that apply to the dama#ed file are restored& Note: Transaction(log 'ac6ups still must 'e ta6en. The tail end of the log must 'e availa'le as well. =ence" the simple recovery mode is not availa'le to file>filegroup and file(differential 'ac6ups. A very common bac%"p process incl"des the follo$in#D • • • =erformin# a f"ll database bac%"p follo$in# the creation of the database =erformin# differential bac%"ps as needed =erformin# freC"ent transaction4lo# bac%"ps as needed

A very common restore process incl"des the follo$in#D

)2

Microsoft SQL Server 2

<perations J"ide

• • • • • •

Capt"rin# the orphaned lo# "sin# the :<OT*,:CAT+ ar#"ment 1ixin# the media problem *estorin# the last f"ll database bac%"p 6:<O*+C<9+*L7 *estorin# the last differential bac%"p 6:<O*+C<9+*L7 *estorin# all lo# bac%"ps in seC"ence follo$in# the last differential bac%"p 6all lo#s :<O*+C<9+*L7 *estorin# the orphaned lo# 6*+C<9+*L7

"'c;+) Str'te-ies

1"ll database bac%"ps sho"ld al$ays be performed& Transaction lo# bac%"ps are #enerally performed in most cases as $ell& The exception to this $o"ld be environments for $hich trac%in# chan#es is not desirable! that is! those in $hich there are infreC"ent data chan#es or testin# environments& These environments sho"ld "se the Simple *ecovery Model 6described later in this paper7& /ifferential bac%"ps sho"ld be "sed in environments that have many transactions and have either many lo# bac%"ps or lar#e lo# bac%"ps& 1ile and file#ro"p bac%"p strate#ies can be implemented in environments that contain extremely lar#e amo"nts of data& To vie$ information abo"t bac%"ps! "se +nterprise Mana#er! "se the vario"s informational *+ST<*+ statements! or C"ery the backupset system table& To vie$ information abo"t the restore history! "se +nterprise Mana#er or C"ery the restore*istor) system table& 1or sec"rity p"rposes! bac%"ps sho"ld be %ept offsite and be located in a safe or similar sec"re str"ct"re $hile onsite& Note: File 'ased 'ac6up devices should never reside on the same physical dis6s as the data'ase files.
Recover4 Mo0e,s

*ecovery models dictate $hat is capt"red in the transaction lo#& The recovery models incl"de f"ll! b"l%4lo##ed! and simple models& The defa"lt recovery model for the standard and enterprise editions of SQL Sever is f"ll& The defa"lt is determined by the settin# in the model database and can be chan#ed for the model or another database by "sin# the *+C<9+*L ar#"ment of the ALT+* /ATA(AS+ statement& Full Recovery Model The f"ll recovery model lo#s all operations f"lly& *ecovery can be to a specified point in time or to a mar% in the lo#& Most prod"ction systems $ill "se the f"ll recovery model $ith an occasional s$itch to the b"l%4lo##ed recovery model to minimi0e the amo"nt of lo##in# for certain operations& Note: The full recovery model is the recommended model to use. Bulk-logged Recovery Model The b"l%4lo##ed recovery model is similar to the f"ll recovery model in that all operations incl"din# b"l% operations are lo##ed& The difference lies in the fact that the b"l%4lo##ed recovery model lo#s and maintains the only the pa#e allocations for certain operations! as opposed to the individ"al ro$s& These operations incl"deD C*+AT+ ':/+K! S+L+CT ':T<! (C=&+K+! (,L@ ':S+*T and textAima#e

Chapter 4 System Administration )3

operations& This process res"lts in fe$er entries bein# lo##ed and 6a7 smaller lo# file6s7& 'f the data file is lost $hile b"l%4lo##ed recovery is in "se! all transactions in the c"rrent lo# are lost to recovery beca"se the lo# contains only pointers to the data pa#es that contain the dataBnot to the act"al data& This prevents the "se of point4in4time recovery "nder the b"l%4lo##ed recovery model& There are several conditions that need to be in place for the minimal lo##in# to ta%e place $ith b"l%4copy operations "nder the b"l%4lo##ed recovery mode& The tar#et table m"st meet the follo$in# conditionsD • • • • :ot be part of a p"blication :ot have any enabled tri##ers :ot have any indexes ,se the TA(L<C@ optimi0er hint

'n sit"ations $here excessively lar#e amo"nts of data are bein# b"l% inserted into the tar#et table $ith indexes! it may prove to be more efficient to drop the indexes prior to the insert& The indexes can then be recreated follo$in# the data load& This $ay the inserts into the indexes do not have to be lo##ed at the time of the data load& Simple Recovery Model The simple recovery model relies on f"ll database bac%"ps and optionally differential bac%"psBtransaction4lo# bac%"ps are not available& 5ence! point4in4 time recovery and lo#4mar% recovery are not available& /atabases can only be recovered to the time of the last f"ll or differential bac%"pB$hichever is available& The simple recovery model! ho$ever! is the easiest to administer and enhances the performance of certain b"l% and other operations by minimi0in# the amo"nt of lo##in# and a"tomatically re"sin# lo# space& This model is hi#hly appropriate for testin# environments $here the f"nctionality of an application is bein# tested and the data bein# "sed is "nimportant& Note: The simple recovery model has the same functionality as the prior SQL Server versions/ truncate log on chec6point option. This option should not 'e set for production systems" e1cept for read(only servers. Switching Between Recovery Models +nterprise Mana#er or the ALT+* /ATA(AS+ statement can be "sed to s$itch bet$een the different recovery models& S$itchin# from f"ll to b"l%4lo##ed and bac% to f"ll is the most common $ay& This s$itch does not reC"ire any chan#es in existin# sched"led bac%"ps& =rior to s$itchin# from f"ll or b"l%4lo##ed to simple! it is recommended that the /(A bac% "p the transaction lo#& This $ill allo$ the /(A to recover to at least this point if there is a f"t"re problem& 5o$ever! since the simple recovery model prevents transaction4lo# bac%"ps! the /(A sho"ld disable all lo# bac%"ps "ntil the recovery model has been chan#ed and a f"ll database or differential bac%"p has been ta%en& 1ollo$in# the s$itch from simple to f"ll or b"l%4 lo##ed! the /(A sho"ld ta%e a f"ll database or differential bac%"p and then re4 enable any disabled lo# bac%"ps& *efer to Table 4&2 for more information&

)8

Microsoft SQL Server 2

<perations J"ide

Table 4.2 0ackup Strategies 1*en Switc*ing 0etween 2ecover) 3odels rom
1"ll *ecovery

To
("l%4Lo##ed *ecovery

Action
:o action

Description
*eC"ires no chan#e in bac%"p strate#y& Contin"e to perform periodic database! lo#! and 6optionally7 differential bac%"ps& +xec"tin# a lo# bac%"p immediately before the chan#e permits recovery to that point& After s$itchin# to the simple model! stop exec"tin# lo# bac%"ps& *eC"ires no chan#e in bac%"p strate#y& *ecovery to any point in time is enabled after the next lo# bac%"p& 'f point4in4time recovery is important! exec"te a lo# bac%"p immediately after s$itchin#& +xec"tin# a lo# bac%"p immediately before the chan#e permits recovery to that point& After s$itchin# to the simple model! stop exec"tin# lo# bac%"ps& +xec"te a database or differential bac%"p after s$itchin# to the f"ll recovery model& (e#in exec"tin# periodic database! lo#! and 6optionally7 differential bac%"ps& +xec"te a database or differential bac%"p after s$itchin# to the b"l%4 lo##ed model& (e#in exec"tin# periodic database! lo#! and 6optionally7 differential bac%"ps&

1"ll *ecovery

Simple *ecovery

<ptionally bac% "p the transaction lo# prior to the chan#e

("l%4Lo##ed *ecovery

1"ll *ecovery

:o action

("l%4Lo##ed *ecovery

Simple *ecovery

<ptionally bac% "p the transaction lo# prior to the chan#e

Simple *ecovery

1"ll *ecovery

(ac% "p the database after the chan#e

Simple *ecovery

("l%4Lo##ed *ecovery

(ac% "p the database after the chan#e

"'c;+) Perfor*'(ce

There are certain $ays to increase the performance of the bac%"p and restore operation& Spread the database files evenly across m"ltiple dis%s to increase the parallel 'A<& Then "se m"ltiple bac%"p devices spread across m"ltiple drives or bac%"p tape drives to increase the speed of the bac%"p operation& .hen these striped bac%"p sets are created! the same media type m"st be "sed for all bac%"p devices& /is%

Chapter 4 System Administration );

drives are obvio"sly faster than tape! and tape bac%"ps reC"ire that the devices be physically attached to the server $here SQL Server resides& To increase the speed! many /(As $ill create the bac%"ps directly on dis%s and then have a third4party tool copy the bac%"p files to tape for offsite stora#e& :e$er tape drives have b"ilt4in hard$are data compression capabilities to minimi0e the si0e and timin# of the bac%"ps& Note: 2ac6ups to networ6 drives are allowed 'ut can severely degrade 'ac6up performance and increase networ6 congestion. /(As sho"ld r"n thro"#hp"t tests on vario"s hard$are confi#"rations to determine the best confi#"ration& .henever possible! it is best not to share dis% and tape drives on the same SCS' controller& Also! care sho"ld be ta%en not to exceed the capacity of the SCS' channel for the tape drive& Note: +2$s should chec6 the tape drive documentation as some high performance drives re:uire a separate S S# channel to operate at the highest level. Split4mirror and snapshot bac%"ps are another $ay of increasin# the speed of the bac%"p and restore operations& 1or a more detailed disc"ssion! see the Advanced Mana#ement section at the end of this chapter& Microsoft $or%s very closely $ith vario"s third4party providers of bac%"p and restore soft$are& Third4party tools enable the /(A to create a centrali0ed bac%"p plan for m"ltiple prod"cts and operatin# environments& 'n addition! the 9irt"al /evice 'nterface 69/'7 for (ac%"p allo$s data to be transferred to and from third4party bac%"p soft$are prod"cts "sin# shared memory architect"re to decrease the copy overhead and increase the speed of the operation& To find lin%s to some of these vendorsI .eb sites! please see the 1or More 'nformation section at the end of this chapter.
"'c;+) V',i0it4

There are several $ays to test the reliability of the bac%"p process and the data in the bac%"p itself& A common approach is to "se a standby server& (ac%"ps can be ta%en on the prod"ction server and then applied to the standby server& The standby server 6in standby mode7 allo$s for /(CC commands! s"ch as /(CC C5+C@/(! to be r"n a#ainst the data& 'n this scenario! the /(A $o"ld be ass"red that the bac%"p operation too% place correctly! the bac%"p media $as not dama#ed! and the data contained in the bac%"p $as not corr"pt& Note: #f corruption occurs in the original data'ase following the full data'ase 'ac6up and restore" log 'ac6ups will not detect the corruption on the production server 'ecause the log does not contain the actual data pages. /(As can r"n the *+ST<*+ 9+*'1L<:LL statement to test the bac%"p itself& The statement examines the bac%"p device6s7 to ens"re that all files are present and can be read&

2

Microsoft SQL Server 2

<perations J"ide

Note: This statement does not chec6 for data corruption.

A+to*'tio(
A"tomation of the SQL Server 2 environment allo$s the /(A to foc"s time and ener#y on b"siness needs and to inte#rate ne$ technolo#ies into the b"siness model! instead of $orryin# abo"t day4to4day maintenance activities& The primary component of the a"tomation process is the SQL Server A#ent& The a#ent is the sched"lin# component of SQL Server 2 & ,sin# the A#ent! /(As can create Eobs! alerts! and operators to b"ild an a"tomated and proactive environmentD • >obs are defined operations consistin# of tas%s that can be "sed for vario"s sit"ations& Those sit"ations may incl"de maintenance activities! monitorin# activities! and disaster recovery& Alerts are predefined responses to events #enerated by SQL Server or threshold reC"irements as dictated by the /(A& Alerts may notify operators via e4mail! pa#er! or the net send command& Alerts may also exec"te Eobs as part of their definition& <perators are the "sers or #ro"ps that are notified follo$in# Eob exec"tion or $hen an alter command has fired&





.hen "sed in conE"nction $ith the components of the SQL Server A#ent! scripts! stored proced"res! tri##ers! and tables provide the /(A $ith a po$erf"l set of tools for mana#in# the environment&
<o/s

>obs sho"ld be created and sched"led for all operations& :otifications sho"ld be part of the Eob process& To prevent the sendin# of too m"ch e4mail! notifications sho"ld be restricted to Eob fail"res& 'n addition to both e4mail and pa#er notifications! net send notifications sho"ld be implemented in anticipation of e4mail fail"res& .hen Eobs $ill be r"n at vario"s times! it is best to create one Eob and then create m"ltiple sched"les for that Eob& Note0 ?o's and schedules 'oth have to 'e ena'led to function properly. To trou'leshoot e1ecution of the 7o's" use )nterprise Manager or sys7o'history. To trou'leshoot notifications" use )nterprise Manager or sysoperators. 'n cases $here a /(A is responsible for m"ltiple SQL servers! the /(A sho"ld consider creatin# a m"lti4server administration model consistin# of a master server and m"ltiple tar#et servers& The master server is "sed to create and store Eob definitions& +nlisted tar#et servers periodically connect to the master server and do$nload Eobs that have been assi#ned to them& The tar#et server carries o"t the Eob based on the sched"le assi#ned and reports bac% the stat"s to the master server& >obs of this nat"re are termed m"lti4server Eobs and can be modified only on the master server& Tar#et servers can vie$ only the Eob definition and steps& This prevents other administrators from modifyin# the EobQs steps and sched"les or

Chapter 4 System Administration 2)

disablin# the Eob& Note0 The +2$ should consider placing target servers into server groups for the multi(server 7o's so that a 7o' assignment can 'e issued to 7ust one group of servers. I!"ORTANT: $ll single(server and multi(server 7o's should 'e thoroughly tested prior to introduction into the production environment.
A,erts

Alerts can be created to respond to events! or they can be set for thresholds in SQL Server& These alerts are "sed to handle events as they occ"r and are detected& Alerts are "s"ally desi#ned to initiate a corrective action and to notify a /(A that the event too% place and that the corrective action to handle the event has been tri##ered& There are t$o types of alerts availableBthose that are event driven and those that are defined for thresholds& The event4driven alerts reC"ire that an event be $ritten to the .indo$s 2 Application event lo#& Threshold alerts allo$ the /(A to define a threshold for a partic"lar System Monitor co"nter and instance& +vents that have a severity of ); to 2? are considered severe events and in some cases can sh"t do$n the SQL Server& Microsoft provides sample alerts for each of these event levels for all databases& 't is recommended that! at a minim"m! the /(A s"pply the necessary operator4notification information as part of the alert definition& All alerts sho"ld be standardi0ed in their formats and the messa#es that are ret"rned& .hen notifyin# operators! it is best to have SQL Server send a notification to a #ro"p of operators instead of E"st a sin#le operator& 't is also recommended that the /(A create a fail4safe operator to notify in case the other operators cannot be contacted& The /(A sho"ld set the appropriate r"les in the e4mail application to ens"re proper notification of hi#h4priority events& The /(A may also $ant to capt"re additional information into a table and then have a tri##er send an #p'send%ail to provide additional information to the notified operator or #ro"p& Note0 The alert must 'e ena'led for it to fire. $lso" dou'le(chec6 the settings such as error num'er" severity" data'ase3s5" and additional te1t when defining alerts to ensure that they function properly. To trou'leshoot firing" chec6 the history via )nterprise Manager or the sysalerts ta'le. 'n cases $here a /(A is responsible for m"ltiple servers r"nnin# SQL Server! the /(A sho"ld stron#ly consider creatin# a centrali0ed event4for$ardin# server to respond to all "nhandled events from the other servers r"nnin# SQL Server& 1or additional information abo"t set"p and preca"tions! see FMana#in# +ventsG in SQL Server (oo%s <nline&

D't' Move*e(t
This section explains the operational best practices for the vario"s methods of data movement&

22

Microsoft SQL Server 2

<perations J"ide

D't' Tr'(sfor*'tio( Services 8DTS9

/TS is a set of SQL Server 2 components that allo$s /(As to import! export! and transform both relational and non4relational so"rces of data& The t$o main components of /TS are the /TS /ata ="mp and <L+4/(& The /TS /ata ="mp is the en#ine that provides the interfaces and methods allo$in# connection to and transformation of the data& <L+4/( is MicrosoftIs ,niversal /ata Access component! $hich allo$s /(As to access and $or% $ith many different forms of data thro"#h the "se of <L+4/( providers& /TS provides a po$erf"l extract! transform! and load 6+TL7 toolset for transferrin# data bet$een systems& 't can be "sed for many /(A4related f"nctions from the simple transfer of data from a file into a table! to a more complex a"tomated data4 $areho"sin# transformation! $hich mi#ht incl"de importin# ne$ b"siness records! massa#in# data! "pdatin# the fact table! and performin# an incremental "pdate of an Analysis Services c"be& The /TS $i0ards sho"ld be "sed to create simple transformations and the /TS /esi#ner sho"ld be "sed for complex transformations& The end res"lt of a transformation process is a /TS pac%a#e& A /TS pac%a#e is a self4contained collection of connections! tas%s! transformations! and $or%flo$s& The pac%a#e itself can be saved in several formats& 1or transformations that reC"ire data linea#e 6an a"dit trail for the records7 or that share meta data $ith other applications! pac%a#es sho"ld be saved in Microsoft Meta /ata Services $ithin SQL Server 2 & 1or transformations that are r"n on m"ltiple servers! pac%a#es sho"ld be saved to a Component <bEect Model 6C<M7 str"ct"red stora#e file 6&dts7& =ac%a#es sho"ld be saved to a 9is"al (asic file 6&bas7 for developers $ho $ant to inte#rate /TS code into their applications&
DTS o((ectio(s '(0 T's;s

/TS provides /(As $ith an array of possible connections and tas%s& /(As can move and transform data from any </(C 6<pen /ata (ase Connectivity7 or <L+4 /( 6<bEect Lin%in# and +mbeddin# /ata (ase 7 so"rce& The more common /TS tas%s "sed by /(As incl"de the follo$in#D • • • • • • Transform /ata Tas% +xec"te SQL Tas% ("l% 'nsert Tas% Copy SQL Server <bEects Tas% Transfer /atabases Tas% Transfer Lo#ins Tas%

The Transform /ata Tas% is C"ite effective at movin# and manip"latin# data& The follo$in# are some of the advanta#esD • • • • Col"mn mappin#s can be altered /estination data types and n"ll4ability can altered ActiveK scripts and C<M components can be "sed for transformations Loo%4"p tables can be "sed to enhance the f"nctionality

Chapter 4 System Administration 2-



+xception files can be created $ith a max error co"nt

The +xec"te SQL Tas% allo$s /(As to incl"de Transact4SQL scripts in their pac%a#e lo#ic& 1or example! a /(A co"ld easily create a /ata Transformation Service 6/TS7 pac%a#e and sched"le it so that it $o"ld perform the process of removin# records older than a set n"mber of days from a b"siness table! insertin# those records into a history table and incl"din# the details abo"t the process in an a"dit table& To ens"re that all operations complete as a "nit! /(As sho"ld implement transaction lo#ic for the SQL tas%s $ithin the pac%a#e& The ("l% 'nsert Tas% allo$s /(As to C"ic%ly import massive amo"nts of data from a file 6&txt! &csv! etc&&7 into a SQL Server table& The tas% itself encaps"lates the Transact4SQL bulk insert statement& To increase the speed of the operation! /(As sho"ld copy the text file to a directory on the SQL Server prior to the operation& Note0 Transformations cannot 'e part of the 2ul6 #nsert Tas6. $lso" failed records are not captured. For this reason" ma6e sure that all records are correct and complete prior to using this tas6. The Copy SQL Server <bEects Tas% allo$s /(As to easily transfer obEects from one SQL Server database to another& Scripts are $ritten to dis% for the entire operation& /(As are enco"ra#ed to revie$ the &lo# files for the so"rce and destination servers to trac% do$n any errors& The Transfer /atabase Tas% allo$s /(As to easily transfer a database from one server to another& /atabases can be moved or copied and destination database file locations can be chan#ed as $ell. The Transfer Lo#ins Tas% allo$s /(As to easily transfer lo#ins from one SQL Server to another& *efer to SQL Server (oo%s <nline to verify so"rce and destination version reC"irements for the transfer tas%s&
Re),ic'tio(

*eplication is another techniC"e "sed to move data& T$o types of replication freC"ently "sed to distrib"te data are snapshot replication and transactional replication& The choice depends on the reC"irements and restrictions of the environment& Snapshot replication is a periodic b"l% refresh of data& All data that is part of the p"blication is transferred to the s"bscribersBnot E"st the chan#es! or the net4 chan#ed data& Snapshot replication is best "sed in the follo$in# sit"ationsD • • • A minimal amo"nt of data is "sed The data is infreC"ently chan#ed A hi#her de#ree of latency is acceptable

Transactional replication transfers the chan#es to the s"bscribers& A snapshot of the initial data is ta%en and applied to the s"bscribers& As the chan#es ta%e place on the p"blisher! they are mar%ed for replication! copied to a store and for$ard database 6by defa"lt! named Fdistrib"tionG7! and applied to the s"bscribers&

24

Microsoft SQL Server 2

<perations J"ide

Transactional replication is best "sed in environments $ith the follo$in# types of characteristicsD • • • • Lar#er amo"nts of data are "sed Transactional consistency is reC"ired Minimal latency is a m"st *eliable net$or% connectivity and hi#h band$idth are available

L'te(c4 's ' 3'ctor i( Re),ic'tio(

1or distrib"tin# an "p4to4date copy of data to other servers on a re#"lar basis! "se snapshot replication& 1or sit"ations that reC"ire the modifications to the data to be distrib"ted to other servers as the chan#es ta%e place 6some latency allo$ed7! "se transactional replication& 1or sit"ations that reC"ire that all of the so"rce chan#es be reflected immediately on the other servers 6no latency allo$ed7! "se distrib"ted transactions in combination $ith the distrib"ted transaction coordinator 6/TC7&
" P '(0 "UL= INSERT

The b"l% copy pro#ram 6(C=7 and the (,L@ ':S+*T T4SQL statement are "sed to transfer lar#e amo"nts of data to and from files and tables& (C= is a command4line "tility that can easily be inte#rated into &cmd and &bat files& Note: 2 @ switches are case sensitive. The (,L@ ':S+*T statement can easily be inte#rated into scripts and stored proced"res& The (,L@ ':S+*T statement is the faster of the t$o methods $ith one restrictionBit allo$s only one4$ay data transfers 6imports only7& To speed the transfer of data and to minimi0e server reso"rces! consider "sin# non4lo##ed operations $ith lar#e batch si0es& 1or more information! see FLo##ed and :onlo##ed ("l% Copy <perationsG and F<ptimi0in# ("l% Copy =erformanceG in SQL Server (oo%s <nline&
Li(;e0 Servers

Lin%ed servers provide the /(A $ith the ability to C"ery and manip"late data on disparate systems& (oth relational and non4relational so"rces of data can be "sed& ,sin# S+L+CT ':T<! ':S+*T S+L+CT! and ':S+*T +K+C! the /(A can very easily Eoin and move data from m"ltiple so"rces into a destination SQL Server table& Note0 For situations where ad(hoc access is infre:uent" the +2$ may use %@)*&%WS)T or %@)*+$T$S%A& ). #n 'oth cases" the +2$ should 'e sure the .s:l files are placed in a secured *TFS folder for security reasons 'ecause the login and passwords will 'e visi'le in the statements.
Lo- S5i))i(-

1or a more detailed disc"ssion! see the Advanced Mana#ement section at the end of this chapter&

Chapter 4 System Administration 2?

Usi(- "'c;+) '(0 Restore to Move D't'

The SQL Server bac%"p and restore process can be "sed to move data bet$een servers& A bac%"p of a database from one SQL Server can be restored to another SQL Server&
Det'c5i(- '(0 Att'c5i(- D't'/'ses

Another method of copyin# or movin# a database from one SQL Server to another is to "se the detachAattach process& ,sin# either +nterprise Mana#erIs Copy /atabase .i0ard! the /TS Transfer /atabase tas%! or the stored proced"res sp'detac*'db and sp'attac*'db( /(As can very easily and C"ic%ly transfer databases bet$een servers&

o*)'riso( of D't' Movi(- Str'te-ies
.hen choosin# amon# the many techniC"es of movin# data in SQL Server 2 ! the /(A sho"ld %eep both the operational reC"irements and the environment in mind&
Movi(- D't'/'ses

1or movin# an entire database! it is recommended that the /(A do a f"ll bac%"p and restore! b"t in some cases it may be faster and more appropriate to do a detachAattach& +nterprise Mana#er provides an easy4to4"se J,' interface for the detachAattach process or yo" can "se the Copy /atabase .i0ard! $hich transfers the lo#ins alon# $ith the data and str"ct"re&
=ee)i(- Lo-i(s S4(c5ro(i1e0

After the databases are moved! lo#ins sho"ld be transferred from the so"rce server to the destination server& Lo#ins can be scripted o"t or the /TS Transfer Lo#in tas% can be "sed& ,se sp'c*ange'users'login andAor sp'resolve'logins on the destination server to fix o"t4of4synch server lo#ins and database "ser acco"nts& 1or more information! please see the section on lo#ins and "sers restored to another SQL Server in Chapter - of this #"ide&
Movi(->I*)orti(->E:)orti(- D't'?L'r-e or S*',, A*o+(ts

1or importin# lar#e amo"nts of data from a text file! "se the T4SQL 0ulk 4nsert statement or the /TS ("l% 'nsert tas%& 1or freC"ent Eoinin# and importin# of small amo"nts of data from m"ltiple so"rces! "se lin%ed servers and the appropriate T4 SQL statement& 1or exportin# lar#e amo"nts of data from a table! "se the bcp&exe $%d&#ec "tility& 'n sit"ations that reC"ire a small4to4moderate amo"nt of data to be massa#ed! scr"bbed! or transformed! "se the /TS Transform /ata tas%&

St'rti(- '(0 Sto))i(- Services
,nder .indo$s 2 ! SQL Server and several other related components r"n as services& The vario"s services incl"de the follo$in#D • • SQL Server 6incl"din# named instances7 SQL A#ent 6incl"din# named instances7

22

Microsoft SQL Server 2

<perations J"ide

• • • •

SQL 1"ll4Text MS/TC Microsoft Search Microsoft Messa#e Q"e"in#

/ependin# on the service! these services can be started and stopped "sin# vario"s tools& The vario"s tools incl"de the follo$in#D • • • • • • +nterprise Mana#er Services Mana#er Services applet Service Control Mana#er 6SCM7 "tility The net start and net stop commands! $hich can be done thro"#h a command line Tas% Mana#er

Startin# the SQL Server service allo$s "sers to s"bmit C"eries to the database server& =a"sin# the SQL Server service prevents ne$ connections to the server b"t it does allo$ existin# connections to finish their existin# statements and exit& Stoppin# the SQL Server service disables lo#ins! lets c"rrently r"nnin# transactions finish! and performs a chec%point in all databases to sync the cache $ith the hard drive 6this minimi0es the amo"nt of activity and time reC"ired to recover a database at start"p7& Startin#! pa"sin#! and stoppin# the SQL Server service sho"ld be done thro"#h +nterprise Mana#er $henever possible& 'n some cases! s"ch as $hen +nterprise Mana#er is not respondin# or a domain pass$ord or acco"nt has been chan#ed for the service acco"nt! the service information sho"ld be modified and started $ith the Services applet and then also chan#ed in +nterprise Mana#er& Note0 Ma6ing the second change 3in )nterprise Manager5 is only needed where the server is running the Search service and using full(te1t inde1es. To determine connections that are preventin# the server from sh"ttin# do$n! "se sp'w*o or C"rrent Activity in +nterprise Mana#er& 1or "sers $ho cannot be connected or in a very b"sy system $ith bloc%in# ta%in# place! the /(A may choose to disconnect the bloc%in# "ser connection "sin# the @'LL statement& All statements that have not been committed $ill be cancelled and rolled bac%& The /(A may consider capt"rin# the /(CC ':=,T(,11+* and related connection information to a table! prior to eliminatin# the service process '/ 6S='/7 of the "ser connection& This $ill allo$ the /(A to learn more abo"t the statement that is bein# cancelled in case the operation needs to be redone& Note: To stop SQL Server immediately" with no chec6points" use the T(SQL S=AT+%W* statement with the BW#T= *%W$#TC argument. This option should 'e used with caution as active transactions will 'e rolled 'ac6 at startup and changes will 'e lost. &ecovery time will generally 'e longer as well.

Chapter 4 System Administration 23

O)er'tio(s T5't Re@+ire ' SQL Server Rest'rt
The follo$in# administrative f"nctions reC"ire a restart of the SQL Server 2 service before they can ta%e effectD • • • • • • • • • • • • • • • • • Applyin# a service pac% Chan#in# a server name 6$hich is not possible on a failover cl"ster7 Chan#in# the service6s7 acco"nt or pass$ord Chan#in# mail profiles *esettin# the s"spect stat"s Chan#in# the affinity4mas% option Chan#in# the a$e4enabled option Chan#in# the C2 a"ditin# mode option Chan#in# the defa"lt fillfactor settin# for the server Chan#in# the li#ht$ei#ht poolin# option Chan#in# the loc%s option Chan#in# the open4obEects option Chan#in# the priority4boost option Chan#in# the remote4access option Chan#in# the scan for start"p procs option Chan#in# the "ser connections option Chan#in# the $or%in# set si0e option

D"
/atabase Console Commands 6/(CC7 are statements that allo$ /(As to perform vario"s maintenance and related activities to ens"re a smoothly r"nnin# SQL Server 2 operatin# environment& The o"tp"t of the /(CC statements sho"ld be saved for analysis& A nice approach is to save the o"tp"t to a text file! modify the o"tp"tIs content to remove "nnecessary data! and then enter the data into a c"stom table& Tri##ers! scripts! alerts! Eobs! and e4mail can be combined to create a proactive environment& Common /(CC statements r"n by /(As incl"de the follo$in#D • • • • • /(CC C5+C@/( /(CC S5<.C<:T'J /(CC /(*+':/+K /(CC ':/+K/+1*AJ /(CC S5*':@/ATA(AS+

/(CC C5+C@/( is "sed to chec% the allocation and str"ct"ral inte#rity of all the obEects contained $ithin the database& 't is "sed to detect! and in some cases correct! any corr"ption in the database& Note: To increase performance" consider using the noinde#$ p%&sical'onl&$ or no'in(omsgs options. For read intensive environments" consider using the ta'loc6 option to speed the operation. /(CC S5<.C<:T'J is "sed to detect fra#mentation in indexes& 1ra#mentation can severely affect performance as pa#es become f"ll and then split 6ca"sin#

28

Microsoft SQL Server 2

<perations J"ide

ADMINISTRATIVE S !EDULES
inefficient 'A< scans7 and as modifications leave other pa#es less f"ll 6ca"sin# more 'A<7& /(CC /(*+':/+K is often "sed to reb"ild all indexes for a table $ith a sin#le statement& This statement also reb"ilds indexes "sed by primary %ey and "niC"e constraints& /(CC ':/+K/+1*AJ is "sed to de4fra#ment the leaf level of an index& This statement is C"ite "sef"l $hen an index becomes fra#mented& This is an online operation and can be more efficient than recreatin# an index& Ca)tion: +e(fragmenting multiple large inde1es at one time can fill the transaction log or dis6 while the operation logs the moving of the records. To minimi4e this" defragment fewer inde1es at a time" or 7ust a few smaller inde1es at one time. $lso" ensure that there is ade:uate log and dis6 space prior to the operation. /(CC S5*':@/ATA(AS+ is "sed to red"ce the si0e of a database& This statement can be beneficial $hen a database has been allocated m"ch more space than is reC"ired& An associated /(CC S5*':@1'L+ statement can be "sed to red"ce the si0e of an individ"al fileBincl"din# the transaction lo#&

F't depends!G is the freC"ent ans$er to C"estions abo"t administerin# an enterprise data environment& .hich tools sho"ld be "sedP .hich administrative tas%s sho"ld ta%e placeP 5o$ often sho"ld these tas%s occ"rP These and other administrative C"estions cannot al$ays be ans$ered "niformly& Many factors m"st be considered& 5o$ many servers are involvedP 5o$ many applicationsP 5o$ many databasesP 5o$ many "sersP 5o$ many transactions ta%e place in a #iven period of timeP .hat is the ratio of reads to $rites for a #iven systemP T*e 0A needs to +ull) understand t*e entire data center and 4T environ%ent( all %aintenance activities( and t*e ra%i+ications o+ an) c*ange on t*e per+or%ance and availabilit) o+ t*e servers and t*e supported applications. .henever possible! maintenance activities sho"ld be standardi0ed! scripted! a"tomated! and doc"mented& Maintenance activities and /(CC operations sho"ld be r"n $ith a minimal impact on the performance of the prod"ction system& <ptions and ar#"ments for the vario"s commands sho"ld be eval"ated and considered& These tas%s! $henever possible! sho"ld ta%e place d"rin# non4pea% lo$4load times& Tas%s can #enerally #ro"ped into daily! $ee%ly and monthly sched"les& epending on t*e circu%stances( additional ad%inistrative tasks %a) need to be i%ple%ented( and so%e tasks %a) occur %ore or less o+ten or not at all.

Chapter 4 System Administration 2;

D'i,4 T's;s
The follo$in# tas%s sho"ld all be carried o"t on a daily basisD • • • • • • • • • • • • • +ns"re that all services are "p and r"nnin#& +ns"re net$or% connectivity to the server& Chec% the .indo$s :T +vent 9ie$er for error messa#es& Chec% for adeC"ate dis% space for #ro$in# database files and lo# files& Chec% SQL Server Eobs 6loo% for fail"res7& Chec% the SQL Server lo#s for error messa#es& (ac% "p the SQL Server transaction lo#& =erform a f"ll database bac%"p of the master database after ma%in# chan#es to the system catalo#& =erform a f"ll database bac%"p of the msdb database after ma%in# chan#es to the database catalo#& Monitor .indo$s 2 and SQL Server co"nters in System Monitor to ens"re optimal performance& (ac% "p the database $ith a differential bac%"p after performin# non4lo##ed operations! if the recovery model is not set to f"ll recovery& Trac% loc%in#! bloc%in#! deadloc%s! lon#4r"nnin# C"eries! and hi#h4reso"rce C"eries& Trac%! at a minim"m! in System MonitorD processor! memory! dis% 6'A<7! and net$or%& <ther system and application obEects and co"nters can be introd"ced for performance trend analysis and for tro"bleshootin# performance iss"es as they occ"r& *esolve all tro"ble tic%ets and doc"ment the process&



.ee;,4 T's;s
These tas%s sho"ld be carried o"t every $ee%D • • • =erform f"llAdifferential database bac%"ps of all system and prod"ction databases& 'f a"to4"pdate statistics is disabled! exec"te the ,=/AT+ STAT'ST'CS statement& *emove physical and lo#ical fra#mentation from indexes "sin# C*+AT+ ':/+K .'T5 /*<=O+K'ST':J! or lo#ical fra#mentation "sin# /(CC ':/+K/+1*AJ! or reb"ild all indexes "sin# /(CC *+':/+K& *emove extra "n"sed space from data and lo# files& +val"ate possible approaches to increasin# application and server performance! based on the %no$led#e obtained from daily operational activities&

• •

Mo(t5,4 T's;s
Ta%e care of these tas%s once a monthD • • =erform a complete bac%"p of the entire operatin# system& =erform f"llAdifferential database bac%"ps of all system and prod"ction databases&

-

Microsoft SQL Server 2

<perations J"ide

ADVAN ED ADMINISTRATIVE TOPI S
• • • • • =erform a restore of the operatin# system 6optional7& =erform a complete restore of all monthly system and prod"ction database bac%"ps on test machine& =erform /(CC C5+C@/( on all restored system and prod"ction databases& +xec"te sCldia#&exe and store the contents into a sec"re appropriately labeled folder& Compare #athered performance statistics $ith baseline statistics to improve performance and to forecast f"t"re soft$areAhard$are acC"isitions&

Note: Maintain a running log of all maintenance activities. The +ata'ase Maintenance @lan Wi4ard can 'e set to log activities automatically.

D't'/'se M'i(te('(ce P,'( .i1'r0
*e#"lar maintenance activities can easily be accomplished "sin# the SQL Server Maintenance =lan .i0ard& The Maintenance =lan .i0ard allo$s /(As to C"ic%ly create plans and associated sched"led Eobs for performin# the most common administrative tas%s for a database& A plan can be created for m"ltiple databases or a sin#le database& The list of tas%s that can be accomplished incl"de the follo$in#D • • • • • *eor#ani0in# the data and index pa#esBremovin# fra#mentation ,pdatin# statisticsBcreatin# the most optimi0ed plans *emovin# "n"sed spaceBdis% space mana#ement =erformin# /(CC C5+C@/(Bens"rin# allocation and str"ct"ral inte#rity (ac%in# "p the databaseBdisaster recovery • (ac%in# "p the transaction lo#Bpoint4in4time disaster recovery • +4mail or $rite a maintenance reportBplan reportin# • .ritin# history information local or remoteBad4hoc a"ditin# capability

Av'i,'/i,it4 '(0 Perfor*'(ce
Availability often means different thin#s to different people& 1reC"ently! the definition depends on $here the "ser sits in the b"siness or#ani0ation& To some it means ;;&;;; percent "ptime $ith performance as dictated by the SLA! $hile for others it means that the server! altho"#h it may be slo$! is available most of the time and "sers are able to perform their Eob f"nctions $itho"t lar#e disr"ptions& =erformance has vario"s interpretations as $ell& All applications sho"ld be optimi0ed to $or% $ith SQL Server prior to bein# deployed in a prod"ction environment! incl"din# SQL Server parameter settin#s! memory settin#s! server hard$are confi#"ration! and correct indexes& 5o$ $ell an application performs $hen it accesses SQL Server depends on the a#reements $ith the "ser comm"nity! and lar#ely stems from the application desi#n& 1or example! allo$in# ad hoc C"eries

Chapter 4 System Administration -)

in an application is not recommended! beca"se consistent performance may never be achieved! and C"eries may never "se the indexes! ho$ever they are t"ned& SQL Server is only as #ood as the C"eries that are sent to it! and ho$ it is optimi0ed to handle the specific $or%load of the application& To achieve the desired availability and performance of SQL Server! the /(A needs to establish availability and performance reC"irements $ith C"antified n"mbers and percenta#es for each database! server! application! and environment& This doc"mentation $ill help provide the information necessary to create an achievable SLA from $hich the /(A can $or% to improve all maintenance operations and proactively foresee potential problems& The /(A needs to ma%e s"re that all databases are availableBthis is in accordance $ith the SLA for the application& Availability is a combination of people! processes! proper database maintenance! red"ndant hard$are! and technolo#y& The main technolo#ies in SQL Server 2 that need hi#h availability are lo# shippin# and failover cl"sterin#&

!i-5 Av'i,'/i,it4 Tec5(i@+es
This section disc"sses methods for achievin# hi#h availability&
Lo- S5i))i(-

Lo# shippin# is a hi#h4availability feat"re of SQL Server 2 +nterprise +dition& 't enables /(As to a"tomate the process of maintainin# a standby server that is a small delta of time behind the primary server& The process is confi#"red "sin# the SQL Server /atabase Maintenance =lan .i0ard& The res"lt of creatin# a standby server is that transaction lo#s are bac%ed "p on the primary server! then a"tomatically shipped 6copied7 to the standby server and restored& The /(A has control over ho$ often the bac%"ps ta%e place and the time delta bet$een bac%"ps and restores& The lo#ins m"st also be transferred to the secondary server! other$ise the database cannot be bro"#ht online& 'n the event of the prod"ction server fail"re! the standby server can be bro"#ht online man"ally to serve application reC"ests& There sho"ld be no need to s$itch bac% to the primary after it is fixed if the secondary machine can handle the $or%load! as this s$itch $ill ca"se more do$ntime& The time reC"ired to chan#e roles to the standby server $ill vary dependin# on the environment& To red"ce the n"mber of lost transactions! the /(A sho"ld attempt to bac%"p! copy! and apply the orphaned lo# 6:<OT*,:CAT+7 if there is still connectivity to the primary server& Setting Up Log Shipping The initial set"p for the databaseAserver combination is done thro"#h the /atabase Maintenance =lan .i0ard& Note: To enable log s%ipping$ a single database m)st be c%osen. Table 4&- sho$s the possible parameters and tradeoffs to consider $hen

-2

Microsoft SQL Server 2

<perations J"ide

confi#"rin# lo# shippin#& Table 4.5 Log S*ipping $on+iguration "arameter
(ac%"p database as part of the maintenance plan

*erver A((ected
=rimary

+al)e
(y defa"lt! this is selected on the Specify the /atabase (ac%"p =lan dialo# box& 't $ill create a SQL Server A#ent Eob named F/( (ac%"p >ob for /( Maintenance =lan RConfi#"red =lan :ameI G& Selectin# this option may not be necessary if a bac%"p plan already exists for the database& :ame of the primary server& :ames of the secondary server6s7 to lo# ship&

=rimary server name Secondary server name6s7 /atabase to lo# ship 6on primary7 /irectory to store the bac%"p file 6sho"ld be a valid ,:C name7 Create a s"bdirectory "nder the ,:C for each database =rimary server

The database that the transaction lo# files $ill be #enerated from&

<ne accessible by primary and secondary :AAB,:C file path Set this to LesH it $ill avoid conf"sion and it $ill be easier to find files that have been confi#"red for lo# shippin# $hen "sin# more than one database&

/elete transaction lo# files that are older than a certain time period (ac%"p file extension 6defa"lt is T*:7 :et$or% share name for bac%"p directory Transaction lo# destination directory 6sho"ld be valid ,:C on secondary server7 Create and initiali0e ne$ database /atabase load state

:AAB,:C file path

:AA <ne accessible by primary and secondary Secondary server

Leave as T*:& Same as F/irectory to Store (ac%"p 1ile!G other$ise lo# shippin# $ill not $or% properly&

Secondary server

Choose F:o!G and do the initial bac%"p! copy! and restore man"ally& Set to F:o recoveryG if E"st

Secondary server

Chapter 4 System Administration --

"arameter

*erver A((ected

+al)e
applyin# transaction lo#s for hi#h availability! or to FStandbyG if ma%in# it a read4only reportin# server&

Terminate "ser connections in database

Secondary server

Set to FLes&G 'f F:oG is selected! a Eob $ill need to be set "p to terminate the connections! other$ise the lo#s $ill never be applied& The syntax isD ALT+* /ATA(AS+ databasename S+T S':JL+O,S+* .'T5 T+*M':AT+ 'f the lo#4shipped database is "sed for reportin#! reset it $ith the follo$in# to allo$ "sers to have access after the transaction lo# is appliedD ALT+* /ATA(AS+ databasename S+T M,LT'O,S+*

Allo$ database to ass"me primary role

Secondary server

Set this to FLesG to allo$ the secondary to be the primary& Set the FTransaction lo# bac%"p directoryG to the same one as Fdirectory to store bac%"p file&G :o

=erform a f"ll bac%"p 6if not "sin# an existin# /(7 ,se most recent bac%"p file 6if not "sin# an existin# /(7 Transaction lo# bac%"p sched"le 6defa"lt is every )? min"tes7

=rimary

=rimary

/o not select this& Man"ally restore the bac%"p file& This sho"ld be set to a lo$er n"mber for hi#her vol"me sites and smaller files& 'f this is set to a lar#er n"mber! the files $ill be lar#er and the standby server $ill not be as in synch $ith the primary& The smaller the n"mber! the closer the data on the lo# shippin# pair $ill be& 'f the secondary is "sed as a reportin# server! "se a hi#her val"e&

=rimary

CopyAload freC"ency 6defa"lt is )? min"tes7

=rimaryA Secondary

-4

Microsoft SQL Server 2

<perations J"ide

"arameter
Load delay 6defa"lt is min"tes7

*erver A((ected
Secondary

+al)e
The smaller the n"mber! the closer the data on the lo# shippin# pair $ill be& 5o$ever! if the transaction lo# files are lar#e! an adE"stment may need to be made to allo$ time for the file to copy& 'f the secondary server is "sed as a reportin# server! consider settin# this hi#her! to stac% the lo# files and allo$ "sers to do reportin#&

1ile retention period 6defa"lt is 24 ho"rs7 (ac%"p alert threshold

Confi#"re this to match the corporate archival scheme& 'f the bac%"ps are lar#e! adE"st this n"mber to accommodate that so that false errors do not appear& Same #"ideline as aboveBif the file ta%es )? min"tes to copy 6beca"se it is - #i#abytes SJ(T7 and 4? min"tes to apply! set this n"mber accordin#ly& :AA This sho"ld be on a completely separate server than either the primary or secondary server! beca"se if either server is lost! the history of $hat has occ"rred $ill be lost& Set to F.indo$sG if possible! b"t if the pass$ord for the acco"nt that the SQL Server r"ns "nder is chan#ed! the chan#e m"st be made on all servers defined in lo# shippin#& 'f SQL Server is chosen! it $ill create the lo#Oshippin#O monitorOprobe "ser! for $hich a pass$ord m"st be entered&

<"t of sync alert threshold

Lo# shippin# monitor server

A"thentication mode for Monitor Server

Monitor server

Jenerate a report

=rimary

This is optional! and the /(A $o"ld need to confi#"re a directory to place the reports in! and confi#"re ho$ lon# to retain the reports or e4mail them "sin# SQL Mail&

Chapter 4 System Administration -?

"arameter
Limit n"mber of history entries in the sysdbmaintplanOhistor y table

*erver A((ected

+al)e
Lo# shippin# is verbose& This can increase the si0e of yo"r table C"ic%ly if freC"ent transaction lo#s are #enerated& AdE"st accordin#ly& Also ens"re that $hen allo$in# "nlimited #ro$th that msdb is set to a"to#ro$ as $ell& To clear o"t the entries! exec"te the stored proced"re spOdeleteObac%"phistory& Also! lo# shippin# p"ts entries into the Application +vent 9ie$er! so that may need to be bac%ed "p and cleared o"t from time to time as $ell&

Note: The +2$ can configure only one data'ase per maintenance plan for log shipping. 1or more information on role chan#in# and synchroni0in# lo#ins! see (oo%s <nline for F5o$ to set "p and perform a lo# shippin# role chan#e&G
3'i,over ,+steri(-

1ailover cl"sterin# is the leadin# hi#h4availability feat"re of SQL Server 2 +nterprise +dition& 't allo$s SQL Server to "tili0e an existin# .indo$s cl"ster 6$hich creates red"ndancy7 to install "p to )2 SQL Server virt"al servers& A virt"al server is a cl"stered instance of SQL Server 2 & 'n the event of a fail"re! the node hostin# the virt"al server $ill relinC"ish control! and another node $ill then r"n the virt"al server& The failover is a"tomatic! no man"al intervention is reC"ired! and the server $ill be transactionally c"rrent& 'f clients are not cl"ster a$are! they may need to reconnect to SQL Server as it #oes thro"#h a normal start"p proced"re& The start"p time on the other node $ill depend on ho$ many transactions need to be rolled for$ard or rolled bac%& 1rom a /(A standpoint! a cl"stered SQL Server sho"ld! for the most part! be treated li%e a normal SQL Server instance& 5o$ever! %eep in mind that since this is for hi#h availability! servers m"st be treated $ith #reater care so that availability is not affected& +xcept in rare cases! yo" sho"ld "se the tools that ship $ith SQL Server to mana#e the server& ,se +nterprise Mana#er $hen chan#in# any pass$ords! especially the one that stops and starts the virt"al server!& The Cl"ster Administrator m"st be "sed to do certain tas%s! for example! movin# the reso"rces to another node or chan#in# elements s"ch as drive dependencies& The most important aspect of a s"ccessf"l failover cl"sterin# implementation is the "nderlyin# .indo$s Cl"sterin#! the confi#"ration of the hard$are! and ens"rin# that all databases and applications ta%e availability into acco"nt $hen plannin# for maintenance&

-2

Microsoft SQL Server 2

<perations J"ide

1or more in4depth information on failover cl"sterin#! from confi#"ration to implementation! administrations! and tro"bleshootin#! see the ("ildin# a 5i#hly Available /atabase Cl"ster $hite paper at httpDAAmsdn&microsoft&comAlibraryAdefa"lt&aspP,*LUAlibraryAtechartAd?cl"sterin#&htm&
"'c;i(- U) '(0 Restori(-

Lo" sho"ld %no$ abo"t and "nderstand some special bac%"p considerations for a cl"ster& Altho"#h bac%in# "p the databases in a cl"stered environment is not completely "nli%e bac%in# "p a normal server! it definitely is more complex& So ho$ is s"ch a sit"ation handledP Cl"ster systems are "sed for lar#e and mission4critical databases& (ac%in# "p and restorin# databases in the terabyte ran#e cannot be handled as a ) M( database $o"ld be! altho"#h many try to treat them in the same $ay& The follo$in# #eneral best practices applyD • • • Ma%e freC"ent bac%"ps 5ave offline stora#e rotation for bac%"p files p"t onto tape or any other media Test and time restores on all bac%"ps so that in the event of an emer#ency! the bac%"p $ill be %no$n to be #ood! and the time to restore $ill be %no$n as $ell& @no$in# the time to restore is cr"cial $hen a server is do$n

Important0 +o not use the :uorum drive to store 'ac6ups.
"'c;i(- U) to Dis; '(0 T')e

More often than not! it is easiest to first bac% "p to dis%& Create a cl"ster dis% share so that all nodes $ill have access to the bac%"p share in the event of a failover& /o not attempt to bac% "p to any local drives& After the database is bac%ed "p! it sho"ld be copied to another location! bac%ed "p to another medi"m s"ch as tape! and then archived in a sec"re offsite location after it is tested and verified& The #oal of bac%"ps in a hi#h4availability environment is to remove a sin#le point of fail"re& 'f a bac%"p is made and %ept on a drive some$here! even if *A'/ is "sed! $hat happens if the array failsP .hile this is "nli%ely! the $orst4case scenario m"st al$ays be considered& Another method that yo" can "se! is to provide t$o steps in the bac%"p Eob& Set "p t$o bac%"p methods 6for example! tape drive and a shared cl"ster dis%7& Set "p the maintenance plan! and then alter the bac%"p tas%& 'f the bac%"p s"cceeds in step one! exit $ith s"ccess! b"t if it fails 6for any reason7! invo%e the second method& This $o"ld ens"re that there is not a sin#le point of fail"re in the bac%"p strate#y& Snapshot Backups <ne $ay to bac% "p and restore a cl"stered SQL Server is to "se a snapshot bac%"p& SQL Server 2 s"pports snapshot bac%"ps! in $hich the dis%s are mirrored! a complete set of dis%s is bro%en off the mirror! and that set is then "sed as a bac%"p& Snapshot bac%"ps reC"ire speciali0ed hard$are and are f"lly s"pported by SQL Server 2 & 1or example! TerraServer 6at $$$&terraserver&com7 is a .eb site that delivers aerial photo#raphs and maps provided by the ,nited States Jeolo#ical S"rvey& The

Chapter 4 System Administration -3

database is c"rrently nearin# t$o terabytes of data! and it "ses .indo$s 2 /atacenter Server $ith SQL Server 2 failover cl"sterin# in the :V) scenario& (ac%in# "p this very lar#e database 69L/(7 had to be caref"lly planned& TerraServer employs a snapshot bac%"p& They have three dis% mirrors in addition to *A'/ 6thin% of them as three col"mns lined "p next to each other7H that is! three copies of the data that are %ept in synchroni0ation by hard$are& Therefore! in the event of a dis% fail"re! t$o sets of bac%"ps are available& At some point! ho$ever! one of the mirror sets is bro%en off! and it essentially becomes a live spinnin# bac%"p of the database& At the time it is bro%en off! ho$ever! it $ill no lon#er be %ept synchroni0ed! nor $ill SQL Server see it& SQL Server 2 reco#ni0es this! and handles its memory b"ffers appropriately& A tape sol"tion is then "sed to bac% this live vol"me "p! and at some point! spin the dis% set bac% in! so there are three mirrors once a#ain& This process happens on a cyclical basis& Backing Up an Entire Clustered System 't is not eno"#h to bac% "p the SQL Server 2 databases& A bac%"p of the complete system m"st be performed as $ell& 't is also important to bac% "p the system state of a .indo$s cl"ster! and if it needs to be restored! restore the system state after the operatin# system is p"t on the machine& This reC"ires a cl"ster4 a$are bac%"p pro#ram& Some third4party vendors can provide this service& The follo$in# is a list of native tools that can be "sed to effectively mana#e bac%"pArestore operations of a cl"sterin# environment& • 6tbackup.e#e bac%s "p and restores cl"ster confi#"ration! $hich incl"des the C"or"m dis% and system state& The tool does not $or% $ith remote servers& 'f the server is r"nnin# the cl"ster service! the system4state data $ill also incl"de any reso"rce4re#istry chec%points and the C"or"m reso"rce recovery lo#! $hich contains the most recent cl"ster database information& • $lusrest.e#e restores the contents of bac%"p C"or"m lo# to the live C"or"m& • $lustool.e#e bac%s "p and restores certain parts of the cl"ster confi#"ration& 't also incl"des a mi#ration tool for portin# stand4alone file and printer shares to a cl"ster& Core reso"rces s"ch as the cl"ster '= address! cl"ster names! and C"or"m dis%s are not restored& This tool is available from the .indo$s 2 Server *eso"rce @it and replaces cl"sconb&exe& • u%pc+g.e#e bac%s "p and restores dis% si#nat"res& 't is available as part of the .indo$s 2 Server *eso"rce @it& • $luster Auto%ation Server is a series of ActiveK controls for $or%in# $ith cl"ster service and is part of .indo$s 2 6mscl"s&dll7& 'f yo" are r"nnin# .indo$s :T 4& ! yo" $ill find it on the .indo$s 2 S/@ C/ 6*edistNCl"sterN:T4Ni-827& The previo"s considerations for bac%in# "p to dis% and tape still apply& +ns"re that there are no sin#le points of fail"re and all nodes have access to the same devices in the same $ay&
Lo- S5i))i(- '(0 ,+steri(-

Combinin# lo# shippin# $ith failover cl"sterin# provides a #reat secondary

-8

Microsoft SQL Server 2

<perations J"ide

availability sol"tion if failover cl"sterin# is the primary method deployed& 't also removes a sin#le point of fail"re& Lo# shippin# allo$s for compensation for the distance problem that is most associated $ith failover cl"sterin#& The lo#4shipped secondary sho"ld be placed in a different #eo#raphical location to ma%e s"re that somethin# li%e a po$er fail"re $ill not eliminate both the primary and secondary servers&

Me*or4 M'('-e*e(t
SQL Server 2 dynamically maintains the memory pool by defa"lt& 'f SQL Server needs more memory as the reso"rce load increases! it $ill reC"est additional memory from .indo$s 2 & 'f another application starts and needs some of the memory allocated to SQL Server 2 ! the SQL Server memory pool $ill shrin% and relinC"ish memory to the other application& 't is strongl) recommended! ho$ever! that other applications and services not be installed on the SQL Server prod"ction system& This approach $ill limit iss"es stemmin# from reso"rce contention that can contrib"te to both a lac% of performance and availability of the system& The maxim"m memory settin# of SQL Server 2 specifies the maxim"m amo"nt of memory that SQL Server 2 $ill obtain& This memory is not f"lly allocated at the start"p of SQL ServerH rather! it #ro$s over time! as needed! "ntil the maxim"m is reached& The minim"m memory settin# specifies that SQL Server 2 $ill not relinC"ish any memory belo$ the minim"m val"e once this amo"nt of memory has been obtained& Li%e the maxim"m settin#! SQL Server 2 does not f"lly acC"ire this val"e at start"p! b"t contin"o"sly receives additional memory as needed "ntil this val"e is reached& To maximi0e SQL Server performance! set a s"fficient minim"m memory val"e b"t do not ma%e it so hi#h that it starves the operatin# system or other processes! $hich $o"ld ca"se .indo$s 2 to pa#e to dis%& To decrease the time necessary for SQL Server to free memory to the operation system! th"s decreasin# the start"p time for other applications on the system! consider red"cin# the maxim"m memory val"e for SQL Server 2 & The precedin# para#raphs noted the defa"lt dynamic memory behavior of SQL Server 2 & .hen the .indo$s 2 Address .indo$in# +xtensions 6A.+7 are enabled! ho$ever! memory is not dynamically mana#ed and all memory set for SQL Server 2 is acC"ired at start"p and not released bac% to the .indo$s 2 environment "ntil SQL Server 2 is stopped& The reason for this behavior lies in the fact that SQL Server 2 is allocated memory from the .indo$s 2 nonpa#eable poolBth"s! the pa#es $ill not be s$apped o"t& To prevent potential iss"es! the maxim"m memory settin# sho"ld be "sed&

A0v'(ce0 Me*or4 M'('-e*e(t
Me*or4 A,,oc'tio( 7it5 A00ress .i(0o7i(- E:te(sio(s '(0 P54sic', A00ressi(- E:te(sio(s

The SQL Server 2

+nterprise edition incl"des s"pport for the .indo$s 2

Chapter 4 System Administration -;

Address .indo$in# +xtensions 6A.+7 A=' "nder .indo$s 2 Advanced Server or .indo$s 2 /atacenter Server& These extensions allo$ SQL Server 2 to access "p to 8 J( of physical memory "nder .indo$s 2 Advanced Server and 24 J( of physical memory "nder .indo$s 2 /atacenter Server& The ability of SQL Server 2 to access "p to 24 J( of physical memory can! if confi#"red properly! si#nificantly increase performance& Allocation pa#es are more li%ely to be in the b"ffer cache and stay there! enablin# SQL Server 2 to C"ic%ly locate the data for reads and $rites& /ata and index pa#es are more li%ely to be in and stay in the b"ffer cache! red"cin# the amo"nt of contin"o"s physical 'A<& Ad4 hoc and proced"re plans are more li%ely to be in and stay in the proced"re cache! red"cin# the need for the optimi0er to freC"ently #enerate ne$ exec"tion plans& .ith A.+! a memory4intensive application can no$ r"n m"ch more efficiently "nder SQL Server 2 to increase performance& .indo$s 2 Advanced Server and .indo$s 2 /atacenter Server introd"ced the enhanced A.+ A='& A.+ allo$s applications to access lar#e amo"nts of physical memory& /"e to limitations of -24 bit memory addressin#! only "p to 4 J( of physical memory can be "sed by .indo$s :T 4& and .indo$s 2 $itho"t havin# A.+ enabled& (y defa"lt! 2 J( of memory is dedicated to the operatin# system and 2 J( of memory to the application& .ith a ,-J( s$itch in the (oot&ini "sed by the operatin# system! an application s"ch as SQL Server can access "p to - J( of memory! and the operatin# system is red"ced to )J( of memory& As a res"lt! even if a server $ere confi#"red $ith 8 J( of memory! anythin# beyond 4 J( $o"ld be virt"ally "n"sable& A.+ is the s"pport b"ilt into the operatin# system as a $ay of exposin# extended memory to .in-2®4based applications& A.+ reC"ires an application! s"ch as SQL Server 2 ! to be coded specifically for A.+& A.+ s"pport $ithin SQL Server 2 m"st be confi#"red "sin# the awe enabled option in sp'con+igure& sp'con+igure 7 awe enabled 7( 1 This is set per instance& (y defa"lt! awe enabled is set to ! or off& +nablin# A.+ s"pport in SQL Server 2 also reC"ires some additional operatin#4system confi#"ration& 1or more information! see (oo%s <nlineBWMana#in# A.+ Memory&G Another option that can be "sed to ta%e advanta#e of lar#er amo"nts of memory is =hysical Addressin# +xtension 6=A+7& =A+ enables a -24bit operatin# system to address memory above 4 J(& 1or more information abo"t =A+ and ho$ to set it "p! see the @no$led#e (ase article 4 Q228-2- 4 'ntel =hysical Addressin# +xtensions 6=A+7 in .indo$s 2 & Note: #f @$) is ena'led" 'ac6up and restore errors with Windows 2000 or SQL Server 2000 'ac6ups may 'e encountered. For more information" see the Dnowledge 2ase article0 Q28 3;- X SQL Server 2 or .indo$s 2 (ac%"p :ot 9ie$able .hile *"nnin# in =A+ Mode .hen choosin# hard$are for a sol"tion 6cl"stered or not7 and plannin# on "sin# lar#e memory! ma%e s"re that the confi#"ration incl"des hard$are that s"pports

4

Microsoft SQL Server 2

<perations J"ide

lar#e memory& To chec%! search all cate#ories for the term Wlar#e memoryW on the 5ard$are Compatibility List 65CL7& Table 4&4 s"mmari0es ho$ extended memory settin#s sho"ld be confi#"red based on the amo"nt of lar#e memory bein# set "p& Table 4.4 &#tended 3e%or) $on+iguration , G- or less
A-J( s$itch

, G- to ./ GA-J( enabled A.+ enabled =A+ enabled 6(oot&ini7

!ore t%an ./GA-J( disabled A.+ enabled =A+ enabled 6(oot&ini7

*ote0 When ena'ling $W) or @$) memory" it is highly recommended that the configuration 'e
tested prior to 'ringing the server3s5 online in a production capacity. Altho"#h A.+ memory can si#nificantly improve the performance of SQL Server 2 ! /(As sho"ld be a$are of the ramifications of enablin# this optionD • • The instance of SQL Server does not dynamically mana#e the si0e of the memory address4space "sed& 'f the %a# server %e%or) confi#"ration option is not set $hen A.+ is enabled $ith SQL Server 2 ! SQL Server #rabs the total memory available 6except )28 M( to allo$ the base operatin# system to f"nction7! potentially deprivin# the operatin# system and any other processes that $o"ld be r"nnin# on the same server& After it has been initiali0ed! A.+ memory holds all the memory acC"ired at start"p "ntil the server is sh"t do$n& 'f A.+ is enabled and is ta%in# too m"ch memory! SQL Server m"st be sh"t do$n to reconfi#"re it! ca"sin# do$ntime 6$hich ma%es a hi#h4availability option s"ch as failover cl"sterin# less available7& (eca"se the memory pa#es "sed by the instance of SQL Server are ta%en from the non4pa#eable pool of .indo$s memory! none of the memory can be exchan#ed& This means that if the physical memory is filled "p! SQL Server cannot "se the pa#e file set "p on a physical dis% to acco"nt for the s"rpl"s in memory "sa#e& <nce the %a# server %e%or) option is confi#"red! set the $or%in# set si0e to &

• •



Me*or4 '(0 Processor M'('-e*e(t .it5 M+,ti),e I(st'(ces

SQL Server 2 c"rrently s"pports "p to )2 instances 6one defa"lt and )? named! or )2 named7 on one server or "nder .indo$s Cl"sterin#& A sin#le instance is easier to mana#e! and if both server nodes are eC"al in a cl"stered environment! there $ill be no iss"es in the event of a failover& .hen more than one instance exists in a failover cl"ster or on a server! ho$ever! dynamic memory sho"ld not be confi#"red! beca"se each SQL Server instance $ill be fi#htin# for the same memory pool& Confi#"re only $hat is needed for that partic"lar instance& /o not for#et to ta%e into acco"nt the needs of the operatin# system and any other

Chapter 4 System Administration 4)

SUMMAR&
processes or applications that are r"nnin# on the server& 1or example! thin% of a t$o4node failover cl"ster as #lasses of $ater& (oth #lasses have a maxim"m capacity of 8 o"nces 6$hich $o"ld be 8 J( of memory7& Jlass A and Jlass ( contain - o"nces of $ater each& 'f yo" po"r the contents of Jlass ( into Jlass A! Jlass A can handle the entire amo"nt of liC"id $ith no overflo$& 1rom a SQL Server perspective! for this example to $or%! A.+ memory m"st be enabled! and each instance m"st "se the sp'con+igure stored proced"re %a# server %e%or) option to cap memory on each instance at - J(& 'n the event of the failover! there are still 2 J( of memory left for the operatin# system and any other processes r"nnin#& M"ltiple SQL Server instances have the same problem $ith processor po$erD $ith each additional instance! more po$er co"ld be ta%en a$ay from other processes and instances& (efore placin# m"ltiple instances of SQL Server onto a server or .indo$s cl"ster! not only benchmar% memory reC"irements! b"t also processor reC"irements! beca"se starvin# an instance! another process or application! or the operatin# system can adversely affect performance of the sol"tion& Note0 +ynamic or static memory allocations can 'e set for each instance of SQL Server 2000. The +2$ should 6eep this in mind when allocating memory so that too much memory is *%T allocated to all of the instances restricting other applications 3SQL Server 2000 will leave appro1imately E29M2 free for Windows 2000 when $W) is ena'led5. When clustering" the +2$ should ensure that the fail( over server has ade:uate physical memory to handle the memory re:uirements of the fail(over instances. This chapter explained the best database administration practices! and the reasonin# behind choosin# one option over another& Areas covered incl"de index mana#ement! bac%"ps and restores! data movement! and the advanced topics of lar#e memory mana#ement! lo# shippin#! and cl"sterin#& /aily! $ee%ly! and monthly tas%s $ere listed& /(As sho"ld no$ be able to determine $hich tas%s to perform! ho$ often! and $hich tools and technolo#ies are appropriate for their sit"ation&

More I(for*'tio(
1or more information! please see the follo$in# technical reso"rces&
.e/ Sites

Microsoft SQL Server 5omeD httpDAA$$$&microsoft&comAsCl SQL Server Ma#a0ineD httpDAA$$$&sClma#&comA Microsoft .eb Sol"tion =latformD httpDAA$$$&microsoft&comAb"sinessAprod"ctsA$ebplatformA Tech:et

42

Microsoft SQL Server 2

<perations J"ide

httpDAA$$$&microsoft&comAtechnetA MS/: <nlineD httpDAAmsdn&microsoft&com
P')ers

S"pportin# =A+ Memory ,nder .indo$s 2 httpDAA$$$&microsoft&comAh$devApae Address .indo$in# +xtensions and .indo$s 2 /atacenter Server httpDAA$$$&microsoft&comAh$devAntdriversAa$e&htm ("ildin# a 5i#hly Available /atabase Cl"ster httpDAAmsdn&microsoft&comAlibraryAdefa"lt&aspP,*LUAlibraryAtechartAd?cl"sterin#&htm
"oo;s

/elaney! @aren& nside Microsoft "6+ "erver 3444& Microsoft =ress& 2 httpDAAmspress&microsoft&comAprodAboo%sA42;3&htm Jarcia! Marcelina! ed&H >ames *edin#! +d$ard .halen! and Steve Adrien /eL"ca& Microsoft "6+ "erver 3444 $dministrator:s Companion. Microsoft =ress& 2 & httpDAAmspress&microsoft&comAprodAboo%sA4?);&htm Microsoft Corporation& Microsoft "6+ "erver 3444 !esource %it & Microsoft =ress& 2 )& httpDAAmspress&microsoft&comAprodAboo%sA4;-;&htm
Pro0+cts

Microsoft Application Center httpDAA$$$&microsoft&comAapplicationcenterA Microsoft 5ost 'nte#ration Server httpDAA$$$&microsoft&comAhiserverAdefa"lt&asp Microsoft <perations Mana#er httpDAA$$$&microsoft&comAmomA :et'Q httpDAA$$$&netiC&comA Lo# +xplorer for SQL Server httpDAA$$$&l"mi#ent&comA Note: Third(party products are listed to enhance enterprise solutions. Microsoft does not directly endorse or support the relia'ility of these products.

Chapter 4 System Administration 4-

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close