This is why the Policy-Based Management feature has been intro-duced in SQL Server 2008.. Policy-Based Management allows you to view and configure settings on multiple instances of SQL S
Trang 1The configuration of maintenance plans is stored in MSDB also Again, you must back
up MSDB to avoid the risk of losing your maintenance plan configuration
To configure Maintenance Plans, expand Management, right-click
Maintenance Plans, and then click Maintenance Plan Wizard To view the
execution history of a particular maintenance plan, right-click on it in the Object
Browser, then click View History.
Policy-Based Management
Many database administrators work for large organizations that keep many SQL
Servers—for example, a customer organization that maintains over 50 SQL Servers
in different locations As you can imagine, it is difficult to report on and apply
configuration changes to that many servers individually Keeping the configuration
standardized becomes a laborious task, and, with individual management, mistakes
are inevitable This is why the Policy-Based Management feature has been
intro-duced in SQL Server 2008 Policy-Based Management allows you to view and
configure settings on multiple instances of SQL Server 2008 Using Policy-Based
Management you can apply a configuration change to a group of servers with one
administrative action Furthermore, Policy-Based Management allows you to
enforce standards on your SQL Server, for example, object naming standards This is
known as Explicit Administration SQL Server Management Studio provides
Policy-Based Management wizards These are accessible from the Object Browser under
Management | Policy Management.
Let’s examine the key components of Policy-Based Management and how they
relate to each other:
■
■ Managed targets are the objects you will be managing with Policy-Based
Management Instances of SQL Server, databases, tables, indexes, and other
database objects can be targeted for Policy-Based Management Targets
are presented in a logical hierarchy You can create target sets by filtering
all managed targets using a filter criterion; for example, all database names
starting with ‘MOSS_’ or all non system tables in a database named
‘HR_Database’
Facets are essentially a logical group of properties that apply to a particular
■
■
target For example, the facet Server Information applies to targets of type
Server This facet contains many properties including Collation, IsClustered, and IsSingleUser All these represent SQL Server properties Another
example is the Index facet Not surprisingly, this facet applies to Index
targets and contains properties like PadIndex, FillFactor, and SpaceUsed
Trang 2Conditions are expressions that represent what states are allowed for
■
■
a particular target or target set The expression is generally represented by
a formula such as facet property <comparison operator> value
An example is Table facet, Name LIKE ‘tbl_’ This condition states that table names must start with ‘tbl_’ Figure 7.4 shows a policy condition that checks that all views in user databases are prefixed with vw_
Policies are a unit of management that can be enabled or disabled A policy
■
■
links a condition with an applicable evaluation mode, filter, schedule, and target set One policy represents one condition only Policies can be grouped into categories for ease or administration Databases and servers are subscribed to policy categories, and policies from those categories apply
to the database subscribed You can also subscribe a server to a policy cate-gory In this case, the policies from this category apply to every database on that server Policies can be evaluated to examine all targets that are not compliant, or, in some cases, they can be applied to reconfigure the targets
to be in compliance
Any of the four
■
■ evaluation modes can be linked to the policy: “on demand,”
“on change: prevent,” “on change: log only,” and “on schedule.” These modes are
Figure 7.4 Policy Condition
Trang 3used to check whether the target complies with the policy The “on
change: prevent” and “on change: log only” policies are enforced using
recursive DDL triggers The “on schedule” evaluation is performed using
SQL Server Agent Not all policies support “on change: prevent” and “on
change: log only” evaluation modes When the policy is evaluated
automat-ically by “on change: prevent” and “on change: log only” or “on schedule”
evaluation modes, an event is written to the event log You can subscribe to these events if you wish and create a SQL Server agent alert that notifies
you automatically
You can create and apply policies using SQL Server Management Studio by
performing the following high-level steps:
1 Choose a facet that contains the properties you wish to use in your policy
2 Create a policy condition on this facet
3 Create a new policy and link it to the condition you have just defined
4 Specify the filter criteria that define which target sets this policy will
apply to
5 Specify the policy evaluation mode: “on demand,” “on change: prevent,”
“on change: log only,” or “on schedule.”
6 Evaluate the policy to identify if any targets are not compliant with the
policy
7 Apply the policy to reconfigure the noncompliant targets so that they are
compliant This may not be possible for all types of properties, for example,
you cannot reconfigure the ServerVersion property, but you can change the LoginMode property
8 If a policy has failed, the noncompliant target will be marked with a red
warning icon in Object Explorer This icon will also be displayed next to
all the parent nodes of this target, so you can easily find it
Examples of Using Policy-Based Management
Why would you want to use Policy-Based Management? When you must examine
the configuration of several SQL Servers or several databases, Policy-Based
Management makes this task a lot easier than doing this individually or creating
elaborate scripts Policy-Based Management also allows you to apply the change to
multiple servers or databases at once, saving a great deal of administrative effort
Finally, the automatic evaluation modes can enforce compliance by either not
Trang 4allowing people to make configuration changes that would violate policies or by raising an administrative alert when a violation takes place
Let’s examine some examples of how organizations have implemented Policy-Based Management
For security reasons, your organization prohibits SQL Server Authentication
■
■
mode on any of its 27 SQL Servers You create a policy with a condition for the Server Security facet, LoginMode = Integrated You create a policy linking this condition with a policy and identify servers that don’t comply with it Unfortunately, you cannot use Policy-Based Management
to apply this policy
Your organization is a software development company, and it creates many
■
■
databases for customers You are tired of junior developers not applying
a naming convention to stored procedures and wish to stop it You create
a policy with a condition on Stored Procedure facet, Name LIKE sp_% You apply the policy in “on change: prevent” mode to ensure that developers must follow the naming convention for stored procedures or they will not
be able to create them
You wish to quickly check which SQL Servers have a certain service pack
■
■
applied You create a policy condition Server Information facet, VersionNumber >= <your required version> You apply the policy on demand and quickly identify all servers that have not had the required service pack applied
Exam Warning
Policy-Based Management is a new and exciting feature of SQL Server
2008 Ensure that you understand the concepts behind it and have
practiced creating verifying policies Learn the four policy evaluation modes and practice manually enforcing a policy You are likely to be asked about Policy-Based Management in the exam.
Using the Data Collector
to Collect Performance Data
SQL Server 2008 includes a Data Collector feature: a powerful set of scheduled SQL Agent jobs, data structures, and tools designed for collecting and analyzing data
Trang 5from various sources The Data Collector is often used to collect and consolidate
performance data, but this is not the only use of this feature Data collected by the
Data Collector is stored in a relational database referred to as the management data
warehouse You can define how long data should remain in the management data
warehouse SQL Server Reporting Services can be used to create reports, then view
and analyze the collected data Default reports are available for the most common
data analysis tasks
The Data Collector comprises the following components:
■
■ Data Providers These are compliant sources of data that the Data
Collector can connect to and retrieve data from Common data providers
are SQL Server Trace, Performance Monitor (Perfmon), and custom query
results
■
■ Collection Items A collection item defines the pieces of data you wish
to collect and retain For example, you may wish to only retain one or two
columns from a query or only a specific performance counter When you
define a collection item, you also specify how often the item should be
collected Collection items are grouped logically into collection sets
■
■ Management Data Warehouse This relational database stores diagnostic
information and data collected by the data collector
■
■ Data Collector Reports These SQL Server Reporting Services reports
display the collected data Some commonly used reports are installed by
default, or you can create your own custom reports Figure 7.5 shows
one example of the many default Data Collector reports included with
SQL Server 2008
■
■ Proxy Accounts These accounts are used to access data sources and must
have sufficient permissions to collect data from these sources