Tải bản đầy đủ (.pdf) (912 trang)

microsoft sql server 2008 management and administration

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (21.53 MB, 912 trang )

ptg
www.it-ebooks.info
ptg
Ross Mistry
with Hilary Cotter
SQL Server
2008
Management and Administration
800 East 96th Street, Indianapolis, Indiana 46240 USA
Microsoft
®
www.it-ebooks.info
ptg
Microsoft® SQL Server 2008 Management and Administration
Copyright © 2009 by Sams Publishing
All rights reserved. No part of this book shall be reproduced, stored
in a retrieval system, or transmitted by any means, electronic,
mechanical, photocopying, recording, or otherwise, without written
permission from the publisher. No patent liability is assumed with
respect to the use of the information contained herein. Although
every precaution has been taken in the preparation of this book, the
publisher and author assume no responsibility for errors or omis-
sions. Nor is any liability assumed for damages resulting from the
use of the information contained herein.
This material may be distributed only subject to the terms and
conditions set forth in the Open Publication License, v1.0 or later
(the latest version is presently available at n
content.org/openpub/).
ISBN-13: 978-0-672-33044-5
ISBN-10: 0-672-33044-X
Library of Congress Cataloging-in-Publication Data


Mistry, Ross.
Microsoft SQL server 2008 management and administration /
Ross Mistry.
1st ed.
p. cm.
ISBN 978-0-672-33044-5
1. SQL server. 2. Database management. I. Title.
QA76.9.D3M57886 2008
005.4'476 dc22
2008048922
Printed in the United States of America
First Printing December 2009
Trademarks
All terms mentioned in this book that are known to be trademarks
or service marks have been appropriately capitalized. Sams
Publishing cannot attest to the accuracy of this information. Use of
a term in this book should not be regarded as affecting the validity
of any trademark or service mark.
Warning and Disclaimer
Every effort has been made to make this book as complete and as
accurate as possible, but no warranty or fitness is implied. The
information provided is on an “as is” basis. The author and the
publisher shall have neither liability nor responsibility to any person
or entity with respect to any loss or damages arising from the infor-
mation contained in this book.
Bulk Sales
Sams Publishing offers excellent discounts on this book when
ordered in quantity for bulk purchases or special sales. For more
information, please contact
U.S. Corporate and Government Sales

1-800-382-3419

For sales outside of the U.S., please contact
International Sales

Editor-in-Chief
Karen Gettman
Executive Editor
Neil Rowe
Development
Editor
Mark Renfrow
Managing Editor
Patrick Kanouse
Project Editor
Mandie Frank
Copy Editor
Margaret Berson
Indexer
Ken Johnson
Proofreader
Matt Purcell
Technical Editor
Tod d Ro bi nso n,
MCITP
Publishing
Coordinator
Cindy Teeters
Designer
Gary Adair

Compositor
TnT Design, Inc.
Contributing
Writers
Hilary Cotter,
MVP;
Shirmattie
Seenarine;
John Welch,
MVP;
Marco Shaw,
MVP;
Maciej Pilecki,
MVP
www.it-ebooks.info
ptg
Contents at a Glance
Introduction 1
Part I: Installing, Administering and Managing the Database Engine
1 Installing or Upgrading to the SQL Server 2008 Database Engine
. 11
2 Administering the SQL Server 2008 Database Engine. 51
3 Creating Packages and Transferring Data with Integration Services. 113
4 Managing and Optimizing SQL Server 2008 Indexes . 161
5 Administering SQL Server 2008 Full-Text Search . 203
6 SQL Server 2008 Maintenance Practices. 247
7 Backing Up and Restoring the SQL Server 2008 Database Engine . 273
Part II: SQL Server 2008 Security Practices
8 Hardening a SQL Server Implementation
. 315

9 Administering SQL Server Security and Authorization. 349
10 Administering Policy Based Management . 383
11 Encrypting SQL Server Data and Communications 405
Part III: SQL Server 2008 High Availability Alternatives
12 Implementing and Managing Failover Clustering
. 453
13 Implementing and Managing Database Mirroring 501
14 Implementing and Managing Log Shipping. 531
15 Implementing and Managing Replication 561
Part IV: Monitoring and Troubleshooting SQL Server 2008
16 Managing Workloads and Consumption with Resource Governor
. 605
17 Monitoring SQL Server 2008 with Native Tools 627
18 Proactively Monitoring SQL Server 2008 with Systems Center
Operations Manager 2007
. 681
19 Performance Tuning and Troubleshooting SQL Server 2008. 707
Part V: SQL Server 2008 Bonus Content
20 Administering SQL Server 2008 with PowerShell
. 745
21 Consolidating and Virtualizing SQL Server 2008 with Hyper-V 791
Index. 821
www.it-ebooks.info
ptg
This page intentionally left blank
www.it-ebooks.info
ptg
Table of Contents
Introduction 1
Part I: Installing, Administering, and Managing the Database Engine

1 Installing or Upgrading to the SQL Server 2008
Database Engine 11
What’s New for Installation with SQL Server 2008?. 12
Deprecated SQL Server 2008 Database Engine
Elements
13
Preplanning and Preparing a SQL Server 2008 Server
Database Engine Installation
. 14
Verifying Minimum Hardware Requirements 14
Examining SQL Server 2008 Software Prerequisites. 16
Choosing the Appropriate SQL Server Edition. 17
Choosing the Appropriate Windows Operating
System Version and Edition to Support the
SQL Server Installation
. 18
New Installation, Upgrade, or Transition? . 21
Gathering Additional Information Necessary to Proceed. 23
New SQL Server 2008 Installation or In-place Upgrade 24
New SQL Server 2008 Stand-alone Installation or
Failover Cluster
. 24
Single-Instance or Multiple-Instance Installation 24
Side-by-Side Installations with Previous Versions
of SQL Server
25
Determine Which SQL Server 2008 Features to Install 25
Installing a Clean Version of SQL Server 2008 . 28
Upgrading the Database Engine to SQL Server 2008 34
Creating a SQL Server Feature Discovery Report. 35

Backing Up the Server 35
Verifying System Compatibility. 35
Running the SQL Server Upgrade Advisor . 35
Additional Considerations Before Upgrading the
Database Engine to SQL Server 2008
39
Performing the SQL Server 2008 Upgrade . 40
www.it-ebooks.info
ptg
Finalizing the SQL Server 2008 Installation or Upgrade . 44
Reviewing SQL Server 2008 Logs . 44
Downloading and Installing Updates 44
Hardening the SQL Server Installation . 44
Items to Consider After an Upgrade 45
Managing SQL Server 2008 Installations . 46
Employing Additional SQL Server 2008 Instances 46
Adding Features to an Existing SQL Server 2008
Installation
47
Changing SQL Server 2008 Editions 48
Summary . 48
Best Practices 48
2 Administering the SQL Server 2008 Database Engine 51
What’s New for DBAs When Administering the
Database Engine on SQL Server 2008. 51
Administering SQL Server 2008 Server Properties . 53
Administering the General Page . 54
Administering the Memory Page 55
Administering the Processors Page . 57
Administering the Security Page . 60

Administering the Connections Page 62
Administering the Database Settings Page 64
Administering the Advanced Page. 66
Administering the Permissions Page 69
Administering the SQL Server Database Engine Folders. 70
Administering the Databases Folder 71
Administering the Security Folder 73
Administering the Server Objects Folder . 74
Administering the Replication Folder 77
Administering the Management Folder. 77
Administering Database Properties 79
Administering the Database Properties General Page 80
Administering the Database Properties Files Page 81
Administering the Database Properties Filegroups Page 85
Administering the Database Properties Options Page 86
Understanding and Effectively Using Recovery Models 87
vi
Microsoft®SQL Server 2008 Management and Administration
www.it-ebooks.info
ptg
vii
Contents
Compatibility Level 89
Other Options (Automatic) 89
Other Options (Cursor) 90
Other Options (Miscellaneous) . 90
Other Options (Recovery). 92
Other Options (Service Broker). 92
Other Options (State) . 92
Administering the Change Tracking Page 93

Administering the Database Properties
Permissions Page
93
Administering the Database Properties Extended
Permissions Page
94
Administering the Database Properties Mirroring Page 94
Administering the Database Properties Transaction
Log Shipping Page
. 94
SQL Server Database Engine Management Tasks 94
Changing SQL Server Configuration Settings. 95
Managing Database Engine Informational Reports 95
Detaching and Attaching Databases 97
Scripting Database Objects . 99
Managing SQL Server with PowerShell 100
Backing Up and Restoring the Database. 100
Tra n s f e r ring SQ L Se r ver Data . 100
Tak i n g a SQL Ser ver Da t a b a se Offline 101
Shrinking a Database. 101
Data Compression in SQL Server 2008 . 102
Partitioning Tables and Indexes in SQL Server 2008 104
Enabling FILESTREAM Data for a SQL Server Instance 106
Renaming a Database. 107
Administering the SQL Server Agent. 107
Administering the SQL Server Agent Properties. 108
Administering SQL Server Agent Jobs 109
Administering SQL Server Alerts and Operators 111
Administering SQL Server Proxies 111
Administering SQL Server Error Logs . 111

Summary 111
Best Practices . 112
www.it-ebooks.info
ptg
3 Creating Packages and Transferring Data with
Integration Services 113
What’s New in Integration Services for SQL Server 2008. 114
Options for Creating Packages 115
Import and Export Wizard . 115
Copy Database Wizard . 116
Business Intelligence Development Studio 116
Packages 116
Projects and Solutions . 117
Control Flow . 118
Tas k s . 118
Data Flow 119
Connections . 121
Event Handlers . 122
Variables . 122
Log Providers and Logging . 122
Developing Packages 123
Creating a Project 123
Creating a Package . 124
Walkthrough of a Package . 125
Walkthrough of the Control Flow 126
Walkthrough of the Data Flow . 127
Walkthrough of the Connection Managers 130
Running a Package . 130
Enhancing Packages 134
Tra n s f o r ming Da t a 134

Adding Logging . 140
Using Expressions 140
Sending Email 141
Adding Error Handling. 142
Adding Configurations 143
Adding Maintenance Tasks . 147
Deploying and Running Integration Services Packages. 147
Storing Packages 148
Deploying Packages . 149
Securing SSIS Packages 151
Running Packages 153
viii
Microsoft®SQL Server 2008 Management and Administration
www.it-ebooks.info
ptg
Tra n s f e r ring Da t a wi t h Integration Se r vices . 156
Using the Copy Database Wizard . 156
Using the Bulk Insert Task. 158
Summary 159
Best Practices . 159
4 Managing and Optimizing SQL Server 2008 Indexes 161
What’s New for Indexes with SQL Server 2008 161
The Importance of Indexes 162
How Indexes Work 162
General Index Characteristics . 166
How Column Constraints Affect Indexes . 167
How Computed Columns Affect Indexes. 167
Clustered Index Characteristics 168
Nonclustered Index Characteristics 168
Nonclustered Index Include Columns. 168

XML Index Characteristics . 169
Filtered Index Characteristics. 169
Spatial Index Characteristics . 169
Index Design and Strategy. 170
Using Clustered Indexes 170
Using Nonclustered Indexes 171
Using Unique Indexes and the Uniqueifier Column. 171
Calculating Disk Space Requirements 172
Administering Indexes . 174
Tra n s a c t - SQL Index Syntaxe s . 174
Creating Indexes with SQL Server Management Studio 180
Creating Clustered Indexes 184
Creating Nonclustered Indexes 186
Disabling and Deleting Indexes 186
Enabling and Rebuilding Indexes. 187
Implementing Index Maintenance and Maintenance
Plans 188
Configuring Indexes for Maximum Performance . 189
Configuring Index Statistics 189
Examining Fragmentation Considerations. 190
Implementing Fill Factor Administration 192
Determining When to Rebuild or Reorganize an Index 193
Sorting Indexes in the tempdb . 194
ix
Contents
www.it-ebooks.info
ptg
Using the Database Engine Tuning Advisor. 194
Examining Additional Indexing Options 197
Enterprise Indexing Features 198

Summary 200
Best Practices . 200
5 Administering SQL Server 2008 Full-Text Search 203
New Features of SQL 2008 Full-Text Search. 204
Architecture . 205
Implementing SQL Server 2008 Full-Text Catalogs. 217
Creating a Full-Text Catalog Using the Wizard . 217
Using SQL Server Management Studio 217
Creating a Full-Text Catalog Using TSQL. 219
Creating a Full-Text Index Using the Full-Text Wizard 219
Population Types 228
Creating a Full-Text Index Using TSQL . 230
Maintaining Full-Text Indexes 234
Creating Stop Lists . 236
Using Full-Text Search . 239
Tro u b l e s h ooting Full-Text I n d e x i n g . 241
Best Practices . 244
Summary 245
6 SQL Server 2008 Maintenance Practices 247
What’s New for Maintenance with SQL Server 2008? . 247
Establishing a SQL Server Maintenance Plan. 248
Check Database Integrity Task 248
Shrink Database Task . 249
Reorganize Index Task. 250
Rebuild Index Task . 251
Update Statistics Task . 252
History Cleanup Task 253
Execute SQL Server Agent Job 254
Back Up Database Task 254
Maintenance Cleanup Task 256

Creating a Maintenance Plan . 257
Creating a Maintenance Plan with the Wizard 257
Creating a Maintenance Plan Manually . 264
Viewing Maintenance Plans 267
Creating Multiserver Maintenance Plans. 268
x
Microsoft®SQL Server 2008 Management and Administration
www.it-ebooks.info
ptg
Establishing Maintenance Schedules for SQL Server. 269
Daily Routine Maintenance Tasks. 270
Weekly Routine Maintenance Tasks 270
Monthly or Quarterly Maintenance Tasks . 271
Summary 271
Best Practices . 272
7 Backing Up and Restoring the SQL Server 2008
Database Engine 273
What’s New for Backup and Recovery with SQL
Server 2008?. 273
Backup Compression 274
The Importance of Backups 275
Items to Consider When Creating a Backup
and Recovery Plan
276
Backing Up and Recovering the Database Engine. 277
The Storage Architecture 277
Using Recovery Models Effectively 279
SQL Server Backup Methods . 282
Backing Up and Recovering Examples 290
Backing Up and Recovering Full-Text Catalogs . 307

Backing Up Full-Text Catalogs. 307
Understanding and Creating Database Snapshots. 308
Creating a Database Snapshot with TSQL 309
Viewing a Database Snapshot with SSMS 309
Reverting to a Database Snapshot with TSQL . 310
Dropping a Database Snapshot 310
Summary 310
Best Practices . 311
Part II: SQL Server 2008 Security Practices 313
8 Hardening a SQL Server Implementation 315
What’s New for Hardening a SQL Server 2008
Implementation? . 315
Windows and SQL Server Authentication 316
Windows Authentication Mode 317
SQL Server and Windows Authentication
(Mixed) Mode . 317
xi
Contents
www.it-ebooks.info
ptg
Which Mode Should Be Used to Harden
Authentication? 317
Configuring SQL Server 2008 Authentication Modes 318
Security Ramifications of the SA Account 319
Enforcing or Changing a Strong Password 320
Disabling and Renaming the SA Account . 321
Using Configuration Tools to Harden the Installation 322
Reducing the SQL Server 2008 Surface Area 322
Using the SQL Server Configuration Manager
Too l to Ha rden an Installat i o n 322

Hardening a Server with the Security Configuration
Wizard in Windows Server 2008 . 326
Verifying Security Using the Microsoft Baseline
Security Analyzer (MBSA). 328
Using the SQL Server 2008 Best Practice Analyzer
(BPA) Tool to Harden an Installation . 330
Hardening SQL Server Service Accounts. 331
The Principle of Least Privilege 332
Service Account Isolation . 332
The Types of Service Accounts Available. 333
Determining Which Type of Account to Use for SQL
Server Services 333
Changing a SQL Server Service Account with SQL
Server Configuration Manager 334
Installing Service Packs and Critical Fixes . 335
Updating and Patching SQL Server and the
Operating System . 336
Understanding How SQL Server Security Logs Play a
Part in Security 336
Configuring SQL Server Security Logs for Auditing . 337
Enhanced Auditing Functionality included with
SQL Server 2008 . 338
Additional SQL Server Hardening Recommendations . 338
Removing the BUILTIN\Administrators Windows Group 338
Removing the BUILTIN\Administrators Windows Group
with Transact-SQL . 339
Using a Firewall to Filter Out Unwanted Traffic 339
Summary 346
Best Practices . 346
xii

Microsoft®SQL Server 2008 Management and Administration
www.it-ebooks.info
ptg
9 Administering SQL Server Security and Authorization 349
What’s New for Security and Authorization with SQL
Server 2008?. 349
SQL Server Security 350
Endpoints and Communication 352
Server Logins and Database Users 354
Role-Based Access . 355
Database Schema . 358
Password Policies 359
Logon Triggers . 362
Security Management DDL 362
Managing Logins with DDL. 362
Managing Users with DDL . 364
Managing Roles with DDL. 365
Managing Schemas with DDL . 366
Managing Permissions with DDL . 366
Administering SQL Server Security 367
Server Login Administration 368
Database User Administration . 374
Database Role Administration. 375
Security Schema Administration. 377
Managing Application Roles 377
Server Endpoint Administration 378
Summary 381
Best Practices . 381
10 Administering Policy Based Management 383
Introduction to Policy Based Management

. 383
Policy Based Management Concepts 385
Facets 385
Conditions 388
Policies . 389
Categories 389
Tar g e t s 389
Execution Modes 390
Central Management Servers . 391
xiii
Contents
www.it-ebooks.info
ptg
Implementing Policy Based Management 393
Creating a Condition Based on a Facet 394
Creating a Policy 395
Creating a Category 397
Evaluating Policies . 399
Importing and Exporting Policies . 401
Sample Templates and Real-World Examples 401
Sample Policy Templates 401
Recovery Models 402
Surface Area Configuration . 402
SQL Server Health Checks . 403
Object Naming conventions 403
Best Practices 403
Summary 403
Best Practices . 404
11 Encrypting SQL Server Data and Communications 405
What’s New for Encryption with SQL Server 2008?

. 406
Encryption in SQL . 406
Column Encryption. 407
Encryption Hierarchy 408
Service Master Key . 408
Database Master Key 408
Keys and Certificates 408
Encryption Algorithms 409
Securing the Data Storage 410
Creating a Database for Testing . 410
Setting Up for Encryption. 411
Creating the Encryption Certificate 411
Encrypting the Data. 412
Using Encrypted Data. 413
Attacking the Encryption 413
Using an Authenticator . 416
Backing Up the Keys 418
Extensible Key Management 418
Enabling EKM 419
Creating the Cryptographic Provider. 419
Creating the Credential to Access the HSM . 420
xiv
Microsoft®SQL Server 2008 Management and Administration
www.it-ebooks.info
ptg
Creating the Encryption Key with EKM 420
Advantages of EKM. 421
Tra n s p a r e nt Data Encr yp t i on 421
Mode of Operation 421
Encryption Hierarchy. 422

Enabling Transparent Data Encryption. 422
Creating a Database Master Key in the Master
Database
423
Creating Server Certificate in the Master Database. 423
Creating a Database Encryption Key. 423
Enabling Transparent Database Encryption for
the Database
. 424
Disabling Transparent Database Encryption for the
Database
425
Securing Connections . 426
Hacking the Transmission. 426
Configuring Server-Initiated Encryption 427
Hacking the Transmission: The Sequel 428
Using Certificates . 429
Setting Up the Certificate Server. 430
Provisioning a Server Certificate . 432
SQL Server Certificate Configuration . 434
Client Certificate Configuration 435
Client-Initiated Encryption . 436
SQL Server Management Studio . 437
SQL Server and BitLocker Drive Encryption . 437
Examining BitLocker’s Drive Encryption Components and
Windows Server 2008 Enhancements
. 438
Comprehending BitLocker’s Drive Encryption Hardware
Requirements
. 440

Configuring BitLocker Drive Encryption on a SQL
Server System
. 440
Configuring the System Partitions for BitLocker. 440
Installing BitLocker Drive Encryption . 442
Enabling BitLocker Drive Encryption. 443
Utilizing the BitLocker Recovery Password 449
Removing BitLocker Drive Encryption . 449
Summary 450
Best Practices . 450
xv
Contents
www.it-ebooks.info
ptg
Part III: SQL Server 2008 High Availability Alternatives 451
12 Implementing and Managing Failover Clustering 453
SQL Server 2008 Failover Clustering Overview. 453
What’s New for SQL Server 2008 Failover Clustering
When Running on Windows Server 2008?
. 454
Determining When to Implement a SQL Server 2008
Failover Cluster
455
Failover Clustering Terminology 456
SQL Server Failover Clustering Prerequisites . 458
Failover Clustering Alternatives 459
SQL Server 2008 Failover Clustering Scalability Metrics 461
SQL Server 2008 Cluster-Aware Features 461
Combining Failover Clustering with Other SQL Server
High-Availability Alternatives

. 461
Additional Elements of Failover Clustering. 462
Windows Server 2008 Failover Cluster Quorum Models 462
Shared Storage for Failover Clusters . 464
Typ e s of Shared Storage 466
Implementing a Single-Instance SQL Server 2008
Failover Cluster
469
Preparing the Windows Server 2008 Operating
System for Each Node
471
Configuring the Shared Storage for the Windows
Server 2008 Failover Cluster
472
Preparing the Windows Server 2008 Failover Cluster 473
Creating the Windows Server 2008 Failover Cluster 475
Installing DTC as a SQL Server Failover Clustering
Prerequisite
. 478
Installing the First Node in the Single-Instance SQL
Server 2008 Failover Cluster
478
Installing Additional Nodes in the Single-Instance SQL
Server 2008 Failover Cluster
485
Implement a Multiple-Instance SQL Server 2008 Failover
Cluster
. 487
Installing the First Node in the Multiple-Instance
SQL Server 2008 Failover Cluster

488
Installing Additional Nodes in the Multiple-Instance
SQL Server 2008 Failover Cluster
490
xvi
Microsoft®SQL Server 2008 Management and Administration
www.it-ebooks.info
ptg
Managing Failover Clusters from a SQL Server 2008
Perspective 491
Verifying the Status of Clustered Ser vice and
Applications, Nodes, Storage, and Networks
491
Initiating Manual Service or Application Failovers 491
Managing SQL Server Failover Service Accounts 492
Managing Preferred Owners of a Cluster Node and
Group
492
Managing Failover Clustering Failover Policies 493
Managing Failover Clustering Failback Policies . 494
Removing SQL Server 2008 Nodes from an Existing
SQL Server Failover Cluster
. 494
Removing SQL Server Failover Clustering 495
Managing Failover Clusters from a Windows Server
2008 Perspective
. 495
Administering Patch Management on a SQL Server
2008 Failover Cluster
. 496

Pausing and Resuming a SQL Server Cluster Node . 496
Adding Additional Windows Nodes to the Cluster 496
Adding Storage to the Cluster . 497
Managing Cluster Drive Dependencies 497
Cluster Quorum Configuration . 498
Summary 499
Best Practices . 499
13 Administering and Managing Database Mirroring 501
What’s New for Database Mirroring with SQL Server 2008?
502
SQL Server 2008 Database Mirroring Overview. 503
Database Mirroring Terminology 505
Database Mirroring Configuration/Operating Modes 507
SQL Server Database Mirroring Prerequisites 508
When SQL Server 2008 Database Mirroring
Is Desirable
509
Witness Server Placement. 509
Combining Database Mirroring with Other SQL Server 2008
Tec h n o l o g ies
. 510
Database Mirroring and Other High-Availability
Alternatives
510
Database Mirroring and SQL Server 2008 Database
Snapshots
. 511
xvii
Contents
www.it-ebooks.info

ptg
Administering a Database Mirroring Session 512
Configuring Database Mirroring Prerequisites 512
Configuring Database Mirroring with High Safety
and Automatic Failover
513
Managing a Database Mirroring Session 520
Pausing and Resuming a Database Mirroring Session 520
Manually Failing Over a Database Mirroring Session 521
Changing the Database Mirroring Configuration/
Operating Mode
521
Removing a Database Mirroring Session . 522
Managing Database Mirroring Client Connections
and Redirect
523
Monitoring and Troubleshooting a Database Mirroring Session 525
Using the Database Mirroring Monitoring Tool to
Manage Database Mirroring
. 525
Monitoring Database Mirroring Performance. 527
Using the System Catalogs to Monitor Database
Mirroring
528
Monitoring Database Mirroring with Operations
Manager 2007
. 529
Summary 529
Best Practices . 529
14 Implementing and Managing Log Shipping 531

What’s New for Log Shipping in SQL Server 2008?
531
SQL Server 2008 Log Shipping Overview 531
Understanding Log Shipping Terminology 533
Considering Environmental Factors 534
Deciding When to Use Log Shipping 535
Considering Design Factors 536
Combining Log Shipping with Other SQL Technologies 537
Administering Log Shipping 538
Configuring the Log Shipping Storage Locations . 538
Configuring the Database Recovery Model 539
Implementing Log Shipping 540
Managing Log Shipping 549
Recovering from Log Shipping Interruptions . 549
Managing Log Shipping Jobs 550
xviii
Microsoft®SQL Server 2008 Management and Administration
www.it-ebooks.info
ptg
Failing Over to a Secondary Server 551
Failing Back to the Primary Server 553
Managing Log Shipping from the Command Line 554
Monitoring and Troubleshooting Log Shipping 555
Viewing Log Shipping Reports. 555
Querying Log Shipping Tables for Status. 556
Using Log Shipping Stored Procedures 557
Summary 558
Best Practices . 558
15 Implementing and Administering SQL Server Replication 561
What’s New in SQL Server 2008 Replication?

. 562
SQL Server 2008 Replication Essentials 562
SQL Server 2008 Replication Roles . 563
Typ e s of Replication Alter natives Available . 564
Additional Replication Components 569
SQL Server 2008 Replication Topologies 570
SQL Server 2008 Replication Prerequisites . 573
SQL Server 2008 Edition Limitations. 574
Knowing When to Implement SQL Server 2008
Replication
. 574
Combining Replication with Other SQL Server
High-Availability Alternatives
. 576
Administering SQL Server Replication 578
Creating the Distributor 578
Configuring Snapshot and Transactional Replication 581
Configuring Peer-to-Peer Transactional Replication . 590
Configuring Merge Replication. 593
Managing the Distributor’s Properties. 596
Disabling Publishing and Distribution. 598
Deleting Local Subscriptions 598
Deleting Local Publications 598
Managing Replication Passwords . 598
Generating Replication Scripts 599
Monitoring and Troubleshooting SQL Server Replication 599
Summary 601
Best Practices . 601
xix
Contents

www.it-ebooks.info
ptg
Part IV: Monitoring and Troubleshooting SQL Server 2008 603
16 Managing Workloads and Consumption with
Resource Governor 605
Resource Governor Concepts. 606
Resource Governor Scenarios. 608
Enabling Resource Governor . 609
Creating a Classifier function. 610
Tro u b l e s h ooting Your Classi f i e r Function . 612
Creating a Resource Pool . 613
Creating a Workload Group 615
Managing Resource Governor 618
Monitoring Resource Governor 619
Performance Monitor 619
Profiler 622
DMVs. 622
Summary 625
Best Practices . 625
17 Monitoring SQL Server 2008 with Native Tools 627
What’s New for Monitoring in SQL Server 2008?
628
Gaining Quick Insight into a SQL Server System 628
Leveraging Activity Monitor’s New Performance
Dashboard
. 628
Leveraging Windows Server 2008 Task Manager 630
Obtaining Monitoring Metrics with Dynamic
Management Views
634

Using Predefined SQL Server 2008 Standard
Reports for Monitoring
636
Monitoring Job Activity. 637
Monitoring SQL Logs 638
Monitoring Events with SQL Server Audit 640
SQL Server 2008 Audit Components. 641
SQL Server Audit Failed Logon Attempt Example 643
Creating SQL Server Audits with SQL Server
Management Studio
645
Enabling a SQL Server Audit with SQL Server
Management Studio
647
xx
Microsoft®SQL Server 2008 Management and Administration
www.it-ebooks.info
ptg
Create Server Audit Specification with SQL Server
Management Studio. 648
Viewing an Audit Log 648
Create a Database Audit Specification with
Tra n s a c t - SQL
649
Managing Audits and Audit Specifications 651
Data Collection with Performance Studio 653
Performance Studio Components and Architecture . 653
Configuring the Management Data Warehouse . 654
Set Up a Data Collection . 657
Examining the System Data Collection Sets Included

with Performance Studio
. 658
Managing Data Collection Set Properties. 661
Viewing Collection Set Logs 663
Capturing Performance Counters from Multiple SQL
Server 2008 Instances
664
Running Data Collection Reports. 665
Creating Operators and Sending Email Alerts 666
Configuring Database Mail. 666
Adding Operators 669
Defining Alerts. 670
Using the Windows Server 2008 Performance and
Reliability Monitoring Tools
. 670
Additional Tools to Monitor SQL Server 2008 . 678
Using the SQL Server Profiler. 678
Using the Database Engine Tuning Advisor. 679
Summary 679
Best Practices . 679
18 Proactively Monitoring SQL Server 2008 with System
Center Operations Manager 2007 681
Overview of System Center Operations Manager 682
Processing Operational Data. 684
Generating Alerts and Responses . 684
Outlining OpsMgr Architecture. 684
Understanding How OpsMgr Stores Captured Data. 686
Determining the Role of Agents in System Monitoring 686
Defining Management Groups 686
xxi

Contents
www.it-ebooks.info
ptg
Understanding How to Use OpsMgr. 687
Managing and Monitoring with OpsMgr . 687
Reporting from OpsMgr 688
Using Performance Monitoring 688
Using Active Directory Integration. 688
Integrating OpsMgr with Non-Windows Devices. 689
Integrating OpsMgr with Legacy Management Software 689
Exploring Third-Party Management Packs . 689
Understanding OpsMgr Component Requirements. 690
Exploring Hardware Requirements . 690
Determining Software Requirements. 691
OpsMgr Backup Considerations 691
Deploying OpsMgr Agents . 691
Understanding Advanced OpsMgr Concepts . 692
Understanding OpsMgr Deployment Scenarios 692
Multiple Configuration Groups. 693
Deploying Geographic-Based Configuration Groups . 693
Deploying Political or Security-Based Configuration
Groups
. 694
Sizing the OpsMgr Database 694
Defining Capacity Limits 695
Defining System Redundancy. 695
Securing OpsMgr . 696
Securing OpsMgr Agents 696
Understanding Firewall Requirements . 697
Outlining Service Account Security 697

Exploring the SQL Server Management Pack 698
Downloading and Extracting the SQL Server 2008
Management Pack
701
Importing the SQL Server 2008 Management Pack
File into OpsMgr 2007
701
Installing the OpsMgr Agent on the SQL Server. 702
Monitoring SQL Functionality and Performance with
OpsMgr
. 704
Summary 705
Best Practices . 706
xxii
Microsoft®SQL Server 2008 Management and Administration
www.it-ebooks.info
ptg
19 Performance Tuning and Troubleshooting SQL Server 2008 707
Platform Troubleshooting and Optimization . 709
Platform Performance Measures . 709
Database Engine and Integration Services
Performance Measures
712
The Database Engine 713
Integration Services . 715
SQL Server Logs 717
Database Troubleshooting and Optimization. 718
SQL Server Profiler. 718
Profiler Trace Templates 719
Database Engine Tuning Advisor 721

Capturing a Workload . 722
Analyzing the Workload. 725
Reviewing the Results 726
Applying the Recommendations 729
Monitoring Processes with the Activity Monitor. 730
Application Optimization and Troubleshooting 731
Query Analysis with Execution Plan 731
Query Analysis with the Tuning Advisor . 733
Cursors and the Lazy Developer. 734
Locking and Deadlock Detection . 734
Introducing Extended Events to Troubleshoot SQL Server. 736
Event-Related Components and Terminology 736
Creating an Extended Event with DDL Statements. 738
Leveraging the Extended Events Catalog Views . 740
Leveraging the Extended Events Dynamic
Management Views
740
Summary 741
Best Practices . 741
Part V: SQL Server 2008 Bonus Content 743
20 Administering SQL Server 2008 with PowerShell 745
Overview of PowerShell
745
Start Using PowerShell Now 747
Common Terminology 747
Object Based 748
xxiii
Contents
www.it-ebooks.info
ptg

SQL Server Management Objects (SMO). 748
WMI 748
Installing PowerShell 748
PowerShell Console. 749
Scriptable and Interactive . 749
Default Security . 750
Execution Policy . 750
Profiles 751
Built-in Help Features . 751
PowerShell Scripting Basics 754
A Few Basic Cmdlets 754
Creating a PowerShell Script 755
Adding Comments 756
Variables . 756
Escaping Characters 757
Special Variable $_ . 758
Joining Variables and Strings 758
Passing Arguments . 759
Using Param. 759
Arrays 760
Operators 761
Conditional Statements. 761
Functions 762
Looping Statements. 763
Filtering Cmdlets 765
Formatting Cmdlets. 766
Dealing with CSV Files . 767
Dealing with Dates and Times . 768
-WhatIf/-Confirm Parameters 768
PowerShell in SQL Server 2008 . 769

Adding PowerShell Support 769
Accessing PowerShell 770
SQL Server PowerShell. 772
SQL Provider. 773
SQL Cmdlets 774
SQL Server Agent support . 775
Step-By-Step Examples. 775
General Tasks 775
xxiv
Microsoft®SQL Server 2008 Management and Administration
www.it-ebooks.info

×