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

Microsoft SQL Server 2008 R2 Unleashed- P156 ppt

10 103 0

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

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Table of Contents

  • Introduction

  • Part I: Welcome to Microsoft SQL Server

    • 1 SQL Server 2008 Overview

      • SQL Server Components and Features

      • SQL Server 2008 R2 Editions

      • SQL Server Licensing Models

      • Summary

    • 2 What’s New in SQL Server 2008

      • New SQL Server 2008 Features

      • SQL Server 2008 Enhancements

      • Summary

    • 3 Examples of SQL Server Implementations

      • Application Terms

      • OLTP Application Examples

      • DSS Application Examples

      • Summary

  • Part II: SQL Server Tools and Utilities

    • 4 SQL Server Management Studio

      • What’s New in SSMS

      • The Integrated Environment

      • Administration Tools

      • Development Tools

      • Summary

    • 5 SQL Server Command-Line Utilities

      • What’s New in SQL Server Command-Line Utilities

      • The sqlcmd Command-Line Utility

      • The dta Command-Line Utility

      • The tablediff Command-Line Utility

      • The bcp Command-Line Utility

      • The sqldiag Command-Line Utility

      • The sqlservr Command-Line Utility

      • Summary

    • 6 SQL Server Profiler

      • What’s New with SQL Server Profiler

      • SQL Server Profiler Architecture

      • Creating Traces

      • Executing Traces and Working with Trace Output

      • Saving and Exporting Traces

      • Replaying Trace Data

      • Defining Server-Side Traces

      • Profiler Usage Scenarios

      • Summary

  • Part III: SQL Server Administration

    • 7 SQL Server System and Database Administration

      • What’s New in SQL Server System and Database Administration

      • System Administrator Responsibilities

      • System Databases

      • System Tables

      • System Views

      • System Stored Procedures

      • Summary

    • 8 Installing SQL Server 2008

      • What’s New in Installing SQL Server 2008

      • Installation Requirements

      • Installation Walkthrough

      • Installing SQL Server Using a Configuration File

      • Installing Service Packs and Cumulative Updates

      • Slipstream Installations

      • Summary

    • 9 Upgrading to SQL Server 2008

      • What’s New in Upgrading SQL Server

      • Using the SQL Server Upgrade Advisor (UA)

      • Destination: SQL Server 2008 or SQL Server 2008 R2

      • Upgrading Using a Configuration File

      • Slipstreaming Upgrades

      • Upgrading Other SQL Server Components

      • Summary

    • 10 Client Installation and Configuration

      • What’s New in Client Installation and Configuration

      • Client/Server Networking Considerations

      • Client Installation

      • Client Configuration

      • Client Data Access Technologies

      • Summary

    • 11 Security and User Administration

      • What’s New in Security and User Administration

      • An Overview of SQL Server Security

      • Authentication Methods

      • Managing Principals

      • Managing Securables

      • Managing Permissions

      • Managing SQL Server Logins

      • Managing SQL Server Users

      • Managing Database Roles

      • Managing SQL Server Permissions

      • The Execution Context

      • Summary

    • 12 Data Encryption

      • What’s New in Data Encryption

      • An Overview of Data Security

      • An Overview of Data Encryption

      • SQL Server Key Management

      • Column-Level Encryption

      • Transparent Data Encryption

      • Column-Level Encryption Versus Transparent Data Encryption

      • Summary

    • 13 Security and Compliance

      • Exposure and Risk

      • Across the Life Cycle

      • The Security Big Picture

      • Identity Access Management Components

      • Compliance and SQL Server

      • SQL Server Auditing

      • Setting Up Auditing via T-SQL

      • SQL Injection Is Easy to Do

      • Summary

    • 14 Database Backup and Restore

      • What’s New in Database Backup and Restore

      • Developing a Backup and Restore Plan

      • Types of Backups

      • Recovery Models

      • Backup Devices

      • Backing Up a Database

      • Backing Up the Transaction Log

      • Backup Scenarios

      • Restoring Databases and Transaction Logs

      • Restore Scenarios

      • Additional Backup Considerations

      • Summary

    • 15 Database Mail

      • What’s New in Database Mail

      • Setting Up Database Mail

      • Sending and Receiving with Database Mail

      • Using SQL Server Agent Mail

      • Related Views and Procedures

      • Summary

    • 16 SQL Server Scheduling and Notification

      • What’s New in Scheduling and Notification

      • Configuring the SQL Server Agent

      • Viewing the SQL Server Agent Error Log

      • SQL Server Agent Security

      • Managing Operators

      • Managing Jobs

      • Managing Alerts

      • Scripting Jobs and Alerts

      • Multiserver Job Management

      • Event Forwarding

      • Summary

    • 17 Administering SQL Server 2008 with PowerShell

      • What’s New with PowerShell

      • Overview of PowerShell

      • PowerShell Scripting Basics

      • PowerShell in SQL Server 2008

      • Step-By-Step Examples

      • Summary

    • 18 SQL Server High Availability

      • What’s New in High Availability

      • What Is High Availability?

      • The Fundamentals of HA

      • Building Solutions with One or More HA Options

      • Other HA Techniques That Yield Great Results

      • High Availability from the Windows Server Family Side

      • Summary

    • 19 Replication

      • What’s New in Data Replication

      • What Is Replication?

      • The Publisher, Distributor, and Subscriber Magazine Metaphor

      • Replication Scenarios

      • Subscriptions

      • Replication Agents

      • Planning for SQL Server Data Replication

      • SQL Server Replication Types

      • Basing the Replication Design on User Requirements

      • Setting Up Replication

      • Scripting Replication

      • Monitoring Replication

      • Summary

    • 20 Database Mirroring

      • What’s New in Database Mirroring

      • What Is Database Mirroring?

      • Roles of the Database Mirroring Configuration

      • Setting Up and Configuring Database Mirroring

      • Testing Failover from the Principal to the Mirror

      • Client Setup and Configuration for Database Mirroring

      • Migrate to Database Mirroring 2008 as Fast as You Can

      • Using Replication and Database Mirroring Together

      • Using Database Snapshots from a Mirror for Reporting

      • Summary

    • 21 SQL Server Clustering

      • What’s New in SQL Server Clustering

      • How Microsoft SQL Server Clustering Works

      • Installing SQL Server Clustering

      • Summary

    • 22 Administering Policy-Based Management

      • Introduction to Policy-Based Management

      • Policy-Based Management Concepts

      • Implementing Policy-Based Management

      • Sample Templates and Real-World Examples

      • Policy-Based Management Best Practices

      • Summary

  • Part IV: Database Administration

    • 23 Creating and Managing Databases

      • What’s New in Creating and Managing Databases

      • Data Storage in SQL Server

      • Database Files

      • Creating Databases

      • Setting Database Options

      • Managing Databases

      • Summary

    • 24 Creating and Managing Tables

      • What’s New in SQL Server 2008

      • Creating Tables

      • Defining Columns

      • Defining Table Location

      • Defining Table Constraints

      • Modifying Tables

      • Dropping Tables

      • Using Partitioned Tables

      • Creating Temporary Tables

      • Summary

    • 25 Creating and Managing Indexes

      • What’s New in Creating and Managing Indexes

      • Types of Indexes

      • Creating Indexes

      • Managing Indexes

      • Dropping Indexes

      • Online Indexing Operations

      • Indexes on Views

      • Summary

    • 26 Implementing Data Integrity

      • What’s New in Data Integrity

      • Types of Data Integrity

      • Enforcing Data Integrity

      • Using Constraints

      • Rules

      • Defaults

      • Summary

    • 27 Creating and Managing Views in SQL Server

      • What’s New in Creating and Managing Views

      • Definition of Views

      • Using Views

      • Creating Views

      • Managing Views

      • Data Modifications and Views

      • Partitioned Views

      • Indexed Views

      • Summary

    • 28 Creating and Managing Stored Procedures

      • What’s New in Creating and Managing Stored Procedures

      • Advantages of Stored Procedures

      • Creating Stored Procedures

      • Executing Stored Procedures

      • Deferred Name Resolution

      • Viewing Stored Procedures

      • Modifying Stored Procedures

      • Using Input Parameters

      • Using Output Parameters

      • Returning Procedure Status

      • Debugging Stored Procedures Using SQL Server Management Studio

      • Using System Stored Procedures

      • Startup Procedures

      • Summary

    • 29 Creating and Managing User-Defined Functions

      • What’s New in SQL Server 2008

      • Why Use User-Defined Functions?

      • Types of User-Defined Functions

      • Creating and Managing User-Defined Functions

      • Rewriting Stored Procedures as Functions

      • Creating and Using CLR Functions

      • Summary

    • 30 Creating and Managing Triggers

      • What’s New in Creating and Managing Triggers

      • Using DML Triggers

      • Using DDL Triggers

      • Using CLR Triggers

      • Using Nested Triggers

      • Using Recursive Triggers

      • Summary

    • 31 Transaction Management and the Transaction Log

      • What’s New in Transaction Management

      • What Is a Transaction?

      • How SQL Server Manages Transactions

      • Defining Transactions

      • Transactions and Batches

      • Transactions and Stored Procedures

      • Transactions and Triggers

      • Transactions and Locking

      • Coding Effective Transactions

      • Transaction Logging and the Recovery Process

      • Long-Running Transactions

      • Bound Connections

      • Distributed Transactions

      • Summary

    • 32 Database Snapshots

      • What’s New with Database Snapshots

      • What Are Database Snapshots?

      • Limitations and Restrictions of Database Snapshots

      • Copy-on-Write Technology

      • When to Use Database Snapshots

      • Setup and Breakdown of a Database Snapshot

      • Reverting to a Database Snapshot for Recovery

      • Setting Up Snapshots Against a Database Mirror

      • Database Snapshots Maintenance and Security Considerations

      • Summary

    • 33 Database Maintenance

      • What’s New in Database Maintenance

      • The Maintenance Plan Wizard

      • Managing Maintenance Plans Without the Wizard

      • Executing a Maintenance Plan

      • Maintenance Without a Maintenance Plan

      • Database Maintenance Policies

      • Summary

  • Part V: SQL Server Performance and Optimization

    • 34 Data Structures, Indexes, and Performance

      • What’s New for Data Structures, Indexes, and Performance

      • Understanding Data Structures

      • Database Files and Filegroups

      • Database Pages

      • Space Allocation Structures

      • Data Compression

      • Understanding Table Structures

      • Understanding Index Structures

      • Data Modification and Performance

      • Index Utilization

      • Index Selection

      • Evaluating Index Usefulness

      • Index Statistics

      • SQL Server Index Maintenance

      • Index Design Guidelines

      • Indexed Views

      • Indexes on Computed Columns

      • Filtered Indexes and Statistics

      • Choosing Indexes: Query Versus Update Performance

      • Identifying Missing Indexes

      • Identifying Unused Indexes

      • Summary

    • 35 Understanding Query Optimization

      • What’s New in Query Optimization

      • What Is the Query Optimizer?

      • Query Compilation and Optimization

      • Query Analysis

      • Row Estimation and Index Selection

      • Join Selection

      • Execution Plan Selection

      • Query Plan Caching

      • Other Query Processing Strategies

      • Parallel Query Processing

      • Common Query Optimization Problems

      • Managing the Optimizer

      • Summary

    • 36 Query Analysis

      • What’s New in Query Analysis

      • Query Analysis in SSMS

      • SSMS Client Statistics

      • Using the SET SHOWPLAN Options

      • Using sys.dm_exec_query_plan

      • Query Statistics

      • Query Analysis with SQL Server Profiler

      • Summary

    • 37 Locking and Performance

      • What’s New in Locking and Performance

      • The Need for Locking

      • Transaction Isolation Levels in SQL Server

      • The Lock Manager

      • Monitoring Lock Activity in SQL Server

      • SQL Server Lock Types

      • SQL Server Lock Granularity

      • Lock Compatibility

      • Locking Contention and Deadlocks

      • Table Hints for Locking

      • Optimistic Locking

      • Summary

    • 38 Database Design and Performance

      • What’s New in Database Design and Performance

      • Basic Tenets of Designing for Performance

      • Logical Database Design Issues

      • Denormalizing a Database

      • Database Filegroups and Performance

      • RAID Technology

      • SQL Server and SAN Technology

      • Summary

    • 39 Monitoring SQL Server Performance

      • What’s New in Monitoring SQL Server Performance

      • Performance Monitoring Tools

      • A Performance Monitoring Approach

      • Summary

    • 40 Managing Workloads with the Resource Governor

      • Overview of Resource Governor

      • Resource Governor Components

      • Configuring Resource Governor

      • Monitoring Resource Usage

      • Modifying Your Resource Governor Configuration

      • Summary

    • 41 A Performance and Tuning Methodology

      • The Full Architectural Landscape

      • Primary Performance and Tuning Handles

      • A Performance and Tuning Methodology

      • Performance and Tuning Design Guidelines

      • Tools of the Performance and Tuning Trade

      • Summary

  • Part VI: SQL Server Application Development

    • 42 What’s New for Transact-SQL in SQL Server 2008

      • MERGE Statement

      • Insert over DML

      • GROUP BY Clause Enhancements

      • Variable Assignment in DECLARE Statement

      • Compound Assignment Operators

      • Row Constructors

      • New date and time Data Types and Functions

      • Table-Valued Parameters

      • Hierarchyid Data Type

      • Using FILESTREAM Storage

      • Sparse Columns

      • Spatial Data Types

      • Change Data Capture

      • Change Tracking

      • Summary

    • 43 Transact-SQL Programming Guidelines, Tips, and Tricks

      • General T-SQL Coding Recommendations

      • General T-SQL Performance Recommendations

      • T-SQL Tips and Tricks

      • In Case You Missed It: New Transact-SQL Features in SQL Server 2005

      • The xml Data Type

      • The max Specifier

      • TOP Enhancements

      • The OUTPUT Clause

      • Common Table Expressions

      • Ranking Functions

      • PIVOT and UNPIVOT

      • The APPLY Operator

      • TRY...CATCH Logic for Error Handling

      • The TABLESAMPLE Clause

      • Summary

    • 44 Advanced Stored Procedure Programming and Optimization

      • T-SQL Stored Procedure Coding Guidelines

      • Using Cursors in Stored Procedures

      • Nested Stored Procedures

      • Using Temporary Tables in Stored Procedures

      • Using Remote Stored Procedures

      • Stored Procedure Performance

      • Using Dynamic SQL in Stored Procedures

      • Installing and Using .NET CLR Stored Procedures

      • Using Extended Stored Procedures

      • Summary

    • 45 SQL Server and the .NET Framework

      • What’s New in SQL Server 2008 and the .NET Framework

      • Getting Comfortable with ADO.NET 3.5 and SQL Server 2008

      • Developing with LINQ to SQL

      • Using ADO.NET Data Services

      • Leveraging the Microsoft Sync Framework

      • Summary

    • 46 SQLCLR: Developing SQL Server Objects in .NET

      • What’s New for SQLCLR in SQL Server 2008

      • Developing Custom Managed Database Objects

      • Summary

    • 47 Using XML in SQL Server 2008

      • What’s New in Using XML in SQL Server 2008

      • Understanding XML

      • Relational Data As XML: The FOR XML Modes

      • XML As Relational Data: Using OPENXML

      • Using the xml Data Type

      • Indexing and Full-Text Indexing of xml Columns

      • Summary

    • 48 SQL Server Web Services

      • What’s New in SQL Server Web Services

      • Web Services Migration Path

      • Web Services History and Overview

      • Building Web Services

      • Examples: A C# Client Application

      • Using Catalog Views and System Stored Procedures

      • Controlling Access Permissions

      • Summary

    • 49 SQL Server Service Broker

      • What’s New in Service Broker

      • Understanding Distributed Messaging

      • Designing a Sample System

      • Understanding Service Broker Constructs

      • Service Broker Routing and Security

      • Troubleshooting SSB Applications with ssbdiagnose.exe

      • Related System Catalogs

      • Summary

    • 50 SQL Server Full-Text Search

      • What’s New in SQL Server 2008 Full-Text Search

      • Upgrade Options in SQL Server 2008

      • How SQL Server FTS Works

      • Implementing SQL Server 2008 Full-Text Catalogs

      • Setting Up a Full-Text Index

      • Full-Text Searches

      • Full-Text Search Maintenance

      • Full-Text Search Performance

      • Full-Text Search Troubleshooting

      • Summary

  • Part VII: SQL Server Business Intelligence Features

    • 51 SQL Server 2008 Analysis Services

      • What’s New in SSAS

      • Understanding SSAS and OLAP

      • Understanding the SSAS Environment Wizards

      • An Analytics Design Methodology

      • An OLAP Requirements Example: CompSales International

      • Summary

    • 52 SQL Server Integration Services

      • What’s New with SSIS

      • SSIS Basics

      • SSIS Architecture and Concepts

      • SSIS Tools and Utilities

      • A Data Transformation Requirement

      • Running the SSIS Wizard

      • The SSIS Designer

      • The Package Execution Utility

      • Connection Projects in Visual Studio

      • Change Data Capture Addition with R2

      • Using bcp

      • Logged and Nonlogged Operations

      • Summary

    • 53 SQL Server 2008 Reporting Services

      • What’s New in SSRS 2008

      • Reporting Services Architecture

      • Installing and Configuring SSRS

      • Developing Reports

      • Management and Security

      • Performance and Monitoring

      • Summary

  • Part VIII: Bonus Chapters

    • 54 Managing Linked and Remote Servers

      • What’s New in Managing Linked and Remote Servers

      • Managing Remote Servers

      • Linked Servers

      • Adding, Dropping, and Configuring Linked Servers

      • Mapping Local Logins to Logins on Linked Servers

      • Obtaining General Information About Linked Servers

      • Executing a Stored Procedure via a Linked Server

      • Setting Up Linked Servers Using SQL Server Management Studio

      • Summary

    • 55 Configuring, Tuning, and Optimizing SQL Server Options

      • What’s New in Configuring, Tuning, and Optimizing SQL Server Options

      • SQL Server Instance Architecture

      • Configuration Options

      • Fixing an Incorrect Option Setting

      • Setting Configuration Options with SSMS

      • Obsolete Configuration Options

      • Configuration Options and Performance

      • Database Engine Tuning Advisor

      • Data Collection Sets

      • Summary

    • 56 SQL Server Disaster Recovery Planning

      • What’s New in SQL Server Disaster Recovery Planning

      • How to Approach Disaster Recovery

      • Microsoft SQL Server Options for Disaster Recovery

      • The Overall Disaster Recovery Process

      • Have You Detached a Database Recently?

      • Third-Party Disaster Recovery Alternatives

      • Summary

  • Index

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    • H

    • I

    • J

    • K

    • L

    • M

    • N

    • O

    • P

    • Q

    • R

    • S

    • T

    • U

    • V

    • W

    • X

    • Y-Z

Nội dung

ptg 1494 CHAPTER 40 Managing Workloads with the Resource Governor Reporting Sessions OLTP Sessions Classification (Classifier Function) Internal Group Internal Pool Group 1 Default Group Default Pool Pool 1 Group 2 Pool 2 Group 3 Group 4 Query Optimizer FIGURE 40.1 Overview of the Resource Governor. NOTE Resource Governor is available only in the Enterprise, Datacenter, and Developer Editions of SQL Server 2008 and SQL Server 2008 R2. Overview of Resource Governor Resource Governor works by controlling the allocation of resources according to work- loads. When a connection request is submitted to the Database Engine, the request is clas- sified based on a classification function. The classification function is a scalar function that you define via T-SQL. The classification function evaluates information about the connection (for example, login ID, application name, hostname, server role) to determine how it should be classified. After the connection request is classified, it is routed to a workload group defined for that classification (or if the connection cannot be classified, it is routed to the default workload group). Each workload group is associated with a resource pool. A resource pool represents the physical resources of SQL Server (currently in SQL Server 2008, the only physical resources available for configuration are CPU and memory) and specifies the maximum amount of CPU and/or memory resources that are to be allocated to a specific type of workload. When a connection is classified and put into the correct workload group, the connection is allocated the CPU and memory resources assigned to it, and then the query is passed on to the query optimizer for execution. This process is illustrated in Figure 40.1. ptg 1495 Resource Governor Components Resource Governor is designed to address the following types of resource issues, which are commonly found in a database environment: . Runaway queries—These resource-intensive queries can take up most or all of the server resources. . Unpredictable workload execution—This situation occurs when you have concurrent applications on the same server that are not isolated from each other, and the resulting resource contention causes unpredictable performance. . Workload prioritization—You might want to ensure that a critical workload is given priority to the system resources so it can process faster than other workloads or is guaranteed to complete if there is resource contention. In addition to enabling you to classify incoming connections and route their workloads to a specific group, Resource Governor also enables you to do the following: . Monitor resource usage for each workload in a group . Pool resources and set pool-specific limits on CPU usage and memory allocation, which can prevent or minimize the probability of runaway queries . Associate grouped workloads with a specific pool of resources . Identify and set priorities for workloads The current release of Resource Governor has the following limitations: . Resource allocation is only for CPU and memory usage. There is no support for managing network and disk I/O resource utilization. . Resource Governor manages only resource consumption of the Database Engine. You cannot use Resource Governor to manage workloads within SSAS, SSIS, or SSRS. In the following sections, you learn how to set up and configure Resource Governor for use, how Resource Governor works under the hood, and how you can use Resource Governor to better prioritize and manage a SQL Server’s workload. Resource Governor Components Resource Governor consists of three main components: classification, workload groups, and resource pools. Understanding these three components and how they interact is important to understanding and using Resource Governor. Classification Classification is the process of evaluating incoming user connections and assigning them to a workload group. Classification is performed by logic contained in a user-defined func- tion. The function returns the workload group name, which Resource Governor uses to route the sessions into the appropriate workload groups. 40 ptg 1496 CHAPTER 40 Managing Workloads with the Resource Governor When Resource Governor is configured, the login process for a session consists of the following steps: 1. Login authentication 2. LOGON trigger execution 3. Classification Workload Groups Workload groups are the containers for similar connections, which are grouped together as similar according to the classification criteria applied to each connection. A workload group also provides the mechanism for aggregate monitoring of resource consumption. Resource Governor has two predefined workload groups: the internal group and default group. The internal workload group is used solely by internal Database Engine processes. You cannot change the classification criteria for the internal group, and you also cannot classify any user requests for assignment to the internal group. You can, however, monitor the internal group. Connection requests are automatically classified into the default group when the follow- ing conditions exist: . There are no criteria to classify a request. . There is an attempt to classify the request into a nonexistent group. . There is a general classification failure. Resource governor supports a total of 20 workload groups. Because two of them are reserved for the internal and default workload groups, a total of 18 user-defined workload groups can be defined. Resource Pools A resource pool, or pool, represents the allocation of physical resources of the SQL Server. A resource pool has two parts: . The first part specifies the minimum resource reservation. This part of the resource pool does not overlap with other pools. . The other part specifies the maximum possible resource reservation for the pool. The resource allocation is shared with other pools. In SQL Server 2008 and SQL Server 2008 R2, the pool resources are set by specifying a MIN or MAX allocation for CPU and a MIN or MAX allocation for memory. The MIN setting specifies the minimum guaranteed resource availability of the pool. The MAX setting sets the maximum size of the pool for each of the resources. Because there cannot be any overlap in the minimum resource reservation, the sum of the MIN values across all pools cannot exceed 100% of the total server resources. The ensures that each pool is guaranteed the specified resource allocation. ptg 1497 Resource Governor Components The MAX value can be set anywhere in the range between the MIN value and 100% inclu- sive. The MAX setting represents the maximum amount of resources a session can consume, as long as the resources are available and not in use by another pool that is configured with a nonzero MIN value. When a pool has a nonzero MIN percentage defined, the effec- tive MAX value of other pools is readjusted down, as necessary, to the existing MAX value minus the sum total of the MIN values of other pools. For example, consider you have two user-defined pools. One pool, Pool1, is defined with a MIN setting of 20% and a MAX setting of 100%. The other pool, Pool2, is defined with a MIN setting of 50% and a MAX setting of 70%. The resulting effective MAX setting for Pool1 is 50% (100% minus the MIN 50% of Pool2). The effective MAX setting of Pool2, however, remains at 70% rather than 80% because 70% is the configured MAX value of Pool2. The shared part of the pool (the amount between the MIN and effective MAX values) is used to determine the amount of resources that can be consumed by the pool if the resources are available and not being consumed by another pool. When resources are consumed by a pool, they are assigned to the specified pool and are not shared until processing completes in that pool. To illustrate this further, consider a scenario in which there are three user-defined resource pools: . PoolA is defined with a MIN % of 10 and MAX % of 100. . PoolB is defined with a MIN % of 35 and a MAX % of 90. . PoolC is defined with a MIN % of 30 and a MAX % of 80. The effective MAX of PoolA would be calculated as follows: MAX % of PoolA 100 minus MIN % of PoolB 35 minus MIN % of PoolC 30 equals EFF MAX of PoolA 35 The total Shared % of resources of PoolA would then be calculated as follows: Effective MAX % of PoolA 35 minus MIN % of PoolA 10 equals Shared % of PoolA 25 Table 40.1 illustrates the calculated effective MAX and Shared % values for all pools in this configuration. 40 ptg 1498 CHAPTER 40 Managing Workloads with the Resource Governor To coincide with the predefined workload groups, Resource Governor also has two prede- fined resource pools: the internal pool and default pool. The internal pool represents the resources consumed by the internal processes of the Database Engine. This pool always contains only the internal group, and the pool is not alterable in any way. The Internal Pool has a fixed MIN % of 0 and a MAX % of 100, and resource consumption by the internal pool is not restricted or reduced by any settings in other pools. In other words, the effective MAX of the Internal Pool is always 100%. Any workloads in the internal pool are considered critical for server function, and Resource Governor allows the internal pool to consume 100% of available resources if necessary, even if it means the violation of the resource requirements of the other pools. The default pool is the first predefined user pool. Prior to any configuration, the default pool contains only the default group. The default pool cannot be created or dropped, but it can be altered. The default pool can contain user-defined groups in addition to the default group. Now that you have an understanding of the Resource Governor components, let’s put them into use by enabling and setting up some resource groups. Configuring Resource Governor To begin using Resource Governor for managing the resources of your workloads, follow these steps: 1. Enable Resource Governor. 2. Create your user-defined resource pools. 3. Define your workload groups and assign them to pools. 4. Create the classifier function. 5. Register the classifier function with the Resource Governor. NOTE Resource Governor can be set up and managed using either SQL Server Management Studio (SSMS) or via T-SQL commands. In the following sections, we first show you how to perform the tasks in SSMS and how the same actions can be implemented using T-SQL. TABLE 40-1 Effective MAX and Shared % Values for Multiple Pools ResourcePool MIN % MAX % Effective MAX % Shared % Internal 0 100 100 100 Default 0 100 25 25 PoolA 10 100 35 25 PoolB 35 90 50 15 PoolC 30 80 35 5 ptg 1499 Configuring Resource Governor FIGURE 40.2 Enabling Resource Governor in SSMS. Enabling Resource Governor Before you can begin creating your resource pools, you need to enable the Resource Governor first. To enable Resource Governor in SSMS, in Object Explorer, expand the Management node, right-click on the Resource Governor node, and select Enable (see Figure 40.2). 40 Alternatively, you can also enable Resource Governor by using the ALTER RESOURCE GOVERNOR command in T-SQL: ALTER RESOURCE GOVERNOR RECONFIGURE When Resource Governor is not enabled, the RECONFIGURE option enables Resource Governor. Enabling Resource Governor has the following results: . The classifier function, if defined, is executed for new connections so that their workload can be assigned to workload groups. . The resource limits specified in the Resource Governor configuration are honored and enforced. . Any connections that existed before Resource Governor was enabled are now affect- ed by any configuration changes made when Resource Governor was disabled. When Resource Governor is already enabled, the RECONFIGURE option must be executed to apply any configuration changes made using the CREATE|ALTER|DROP WORKLOAD GROUP or CREATE|ALTER|DROP RESOURCE POOL statements. ptg 1500 CHAPTER 40 Managing Workloads with the Resource Governor To determine whether Resource Governor is currently enabled, you can run a SELECT state- ment against the sys.resource_governor_configuration system catalog table to view the is_enabled column: select is_enabled from sys.resource_governor_configuration go is_enabled 1 To determine whether any RESOURCE GOVERNOR configuration changes are pending, you can use the sys.dm_resource_governor_configuration dynamic management view (DMV): select is_reconfiguration_pending from sys.dm_resource_governor_configuration go is_reconfiguration_pending 0 To disable Resource Governor, right-click on the Resource Governor node and select Disable or execute the following command in T-SQL: ALTER RESOURCE GOVERNOR DISABLE Defining Resource Pools When setting up a Resource Pool, you have to specify a name for the pool and set its properties. The properties available for a resource pool are . Name—The name used to refer to the resource pool . Minimum CPU %—The guaranteed average CPU bandwidth for all requests to the resource pool when there is CPU contention . Maximum CPU %—The maximum average CPU bandwidth for all requests to the resource pool when there is CPU contention . Min Memory %—The guaranteed minimum amount of memory reserved for the resource pool that cannot be shared with other resource pools . Max Memory %—The total server memory that can be used by requests to the resource pool Creating a Resource Pool in SSMS The following steps walk you through using SSMS to create a resource pool named ReportPool that you’ll configure for handling report query workloads: ptg 1501 Configuring Resource Governor 40 FIGURE 40.3 Creating a resource pool in SSMS. 1. In Object Explorer, expand the Management node for a SQL Server Instance and expand the Resource Governor node. 2. Right-click on Resource Pools and select New Resource Pool to open the Resource Governor Properties page (see Figure 40.3). 3. In the Resource Pools grid, click the first column in the empty row. This row is labeled with an asterisk (*). NOTE If the Resource Pools grid does not have a row labeled with an asterisk, Resource Governor has not been enabled yet. You can enable Resource Governor without leaving the Resource Governor Properties page by putting a check mark in the Enable Resource Governor check box. 4. Double-click the empty cell in the Name column. Type in the name that you want to use for the resource pool. For this example, use the name ReportPool. 5. Set the CPU and Memory resource values. In this example, leave the Min CPU % and Min Memory % values at 0 and configure the Max CPU % and Max Memory % values at 20 and 30, respectively. 6. To create the pool and exit the dialog, click OK. To verify that the new pool was created, you expand the Resource Pools folder under the Resource Governor node and look for a node named ReportPool. Alternatively, you can ptg 1502 CHAPTER 40 Managing Workloads with the Resource Governor run a query against the sys.resource_governor_resource_pools dynamic management view, similar to the following, which also displays the resource pool configuration: select name, min_cpu_percent as MinCPU, max_cpu_percent as MaxCPU, min_memory_percent as ‘MinMEM%’ , max_memory_percent as ‘MaxMEM%’ from sys.resource_governor_resource_pools go name MinCPU MaxCPU MinMEM% MaxMEM% internal 0 100 0 100 default 0 100 0 100 ReportPool 0 20 0 30 Creating a Resource Pool in T-SQL Now that you’ve set up the ReportPool resource pool in SSMS, you are able to set up a second resource pool, OLTPPool, using T-SQL. The command to create a resource pool, CREATE RESOURCE POOL, takes four arguments: MIN_CPU_PERCENT, MAX_CPU_PERCENT, MIN_MEMORY_PERCENT, and MAX_MEMORY_PERCENT. After creating the resource pool, you need to run ALTER RESOURCE GOVERNOR RECONFIGURE to apply the new resource pool: CREATE RESOURCE POOL OLTPPool WITH (min_cpu_percent=80, max_cpu_percent=100, min_memory_percent=75, max_memory_percent=100) GO ALTER RESOURCE GOVERNOR RECONFIGURE; GO Now that you’ve defined the resource pools needed, the next step is to define your work- load groups and associate them with a resource pool. Defining Workload Groups After you define your resource pools, the next step is to create the workload groups and associate them with the appropriate resource pools. Multiple workgroups can be assigned to that same pool, but a workgroup cannot be assigned to multiple resource pools. ptg 1503 Configuring Resource Governor 40 Creating Workload Groups in SSMS To create a workload group in SSMS, perform the following steps:. 1. In Object Explorer, expand the Management node, right-click the Resource Governor node, and then click Properties to bring up the Resource Governor Properties page. 2. In the Resource Pools grid, click the row for the resource pool you want to create a workload group for (in this example, the ReportPool resource pool). This creates a new empty row in the Workload Groups for Resource Pool grid for that pool. 3. Double-click the empty cell in the Name column for the empty workload group row and type in the name you want to use for the workload group (for this example, ReportWG1) and any other properties you want to specify (see Figure 40.4) 4. Click OK to exit the Properties page and create the workload group. The additional, optional properties available for workload groups let you set a finer level of control over the execution of queries within a workload group. The options available are . Importance—Specifies the relative importance ( LOW, MEDIUM, or HIGH) of the work- load group within the resource pool. If you define multiple workload groups in a FIGURE 40.4 Creating a Workload Group in SSMS. . Governor is available only in the Enterprise, Datacenter, and Developer Editions of SQL Server 2008 and SQL Server 2008 R2. Overview of Resource Governor Resource Governor works by controlling the allocation. reservation for the pool. The resource allocation is shared with other pools. In SQL Server 2008 and SQL Server 2008 R2, the pool resources are set by specifying a MIN or MAX allocation for CPU. associated with a resource pool. A resource pool represents the physical resources of SQL Server (currently in SQL Server 2008, the only physical resources available for configuration are CPU and memory)

Ngày đăng: 05/07/2014, 02:20

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN