Evaluate your Daily Checklist
against 100+ instances of SQL
Server while you get a cup of
coffee
http://johnsterrett.com/go/dailychecklist
     John Sterrett
     Senior DBA
     Remote DBA Experts




                                   October 11-14, Seattle, WA
What we will cover…
• What should be included in your daily
  checklist
• Build Policy Based Management Policies
• Import Policy Based Management Policies
• Automate execution of daily checklist
• Providing reporting solution for daily
  checklist


                    DBA-216| Evaluate Daily Checklist with PBM and CMS   2
About Me….
• I am a Remote DBA Expert
    • Responsible 100+ Instances of SQL Server
    • Senior DBA on Integration Team
•    Founder of WVPASS (SQL User Group)
•    Mid-Atlantic Regional Mentor
•    Host SQL Saturday #36 & #80
•    I reside in Wheeling, WV (Pittsburgh, PA)



                               DBA-216| Evaluate Daily Checklist with PBM and CMS   3
My Story….
                                              Backups / Restores
              Failed Jobs                     Corruption
 Urgency      Low Disk Space                  Failed mission critical SQL
                                              Jobs


                                              Process improvements
             Pittsburgh Steelers              Continuing education
             winning the Super Bowl           Projects
                                              Index Management
             Everything else…                 Performance Tuning


                                                Importance
Comes from The 7 Habits of Highly Effective People by Stephen R. Covey
                                DBA-216| Evaluate Daily Checklist with PBM and CMS   4
Daily Checklist Questions
Do you have a daily checklist?
What is your daily checklist?
•   Full backups
•   Transactional Log backups
•   Free space
•   SQL Agents are enabled
•   SQL Agent jobs succeeded
How do you evaluate your daily checklist?
• Central Management Server (CMS)
• Policy Based Management (PBM)
                         DBA-216| Evaluate Daily Checklist with PBM and CMS   5
Do you have a daily checklist?



                             46%

                                                                     Yes
                                                                     No
         54%




                DBA-216| Evaluate Daily Checklist with PBM and CMS        6
What's in your daily checklist?
                 0%
                5%                                        Full Backups
           8%              20%                            succeeded
                                                          Transactional log
                                                          backups succeeded
    12%                                                   SQL Services are
                                                          running
                                                           SQL Agent jobs
                                 19%                      succeeded
                                                          Disks have free space
     19%
                                                          Data and Log files
                     17%                                  have free space
                                                          Other


                                 DBA-216| Evaluate Daily Checklist with PBM and CMS   7
How do you evaluate your checklist?
 25
                       21
 20
 15
 10       9
              7   7
 5    3                          3         2
 0


                                               How do you evaluate
                                               your daily checklist?




                      DBA-216| Evaluate Daily Checklist with PBM and CMS   8
Job Notifications…..




                 DBA-216| Evaluate Daily Checklist with PBM and CMS   9
Trust but verify…..




 •   Is the SQL Agent enabled for all servers?
 •   Does email operator exist for all jobs?
 •   Is the operator the same across all servers?
 •   Is Database Mail enabled for all servers?
                              DBA-216| Evaluate Daily Checklist with PBM and CMS   10
I prefer notifications




                   DBA-216| Evaluate Daily Checklist with PBM and CMS   11
Policy Based Management
• Policy-Based Management is a system for
  managing one or more instances of SQL
  Server 2008 (* BOL).
• Some facets allow you to enforce
  standards with “On-Change – Prevent”
• Can import and export policies
• Apply changes when evaluation fails
• Policies can run against SQL 2000 & 2005

                    DBA-216| Evaluate Daily Checklist with PBM and CMS   12
I use PBM to do two things…
Prevent things from happening Apply changes
Automate validation of checklists
• Checklists are prone to human error.
• Server configurations can change over time.

Daily checklist items we will validate
•   SQL Agent is enabled
•   SQL Agent Jobs
•   Full backups
•   Transactional Log backups
•   Free Space

                           DBA-216| Evaluate Daily Checklist with PBM and CMS   13
PBM Concepts and Terms
•   Targets
•   facets
•   conditions
•   policy
•   categories
•   server restrictions



                          DBA-216| Evaluate Daily Checklist with PBM and CMS   14
PBM Example – Page Verify
PageVerify
Page Verify                     Policy
Database                        Target
Database Performance            Facet
@PageVerify = true              Condition
SQL Server 2005 or newer        Server Restriction
On Schedule                     Evaluation Mode



  http://www.littlekendra.com/2011/01/25/pageverify/




                            DBA-216| Evaluate Daily Checklist with PBM and CMS   15
Evaluation Modes
On Demand
• Executed by user or powershell scripts
On Schedule
• Uses SQL Agent (Runs via powershell script)
On Change – Prevent
• Uses DDL Triggers
• * Nested Triggers should be enabled
On Change – Log Only
• uses event notification
For More: http://msdn.microsoft.com/en-
us/library/bb510667%28SQL.100%29.aspx



                           DBA-216| Evaluate Daily Checklist with PBM and CMS   16
On-Change Evaluation….
Not all facets support On-change.
• On Change – Log (17)
• On Change – Prevent (12)
 •   Application Role                 •   Resource Pool
 •   Asymmetric Key                   •   Schema
 •   Database Role                    •   Stored Procedure
                                      •   Table Options
 •   Endpoint
                                      •   User Defined Function
 •   Login Options                    •   User Options
 •   Multipart Name                   •   View Options
                                      •   Workload Group


                        DBA-216| Evaluate Daily Checklist with PBM and CMS   17
Where can I find policies?
Best Practices
• SQL Server 2008 Feature Packs
• C:Program FilesMicrosoft SQL
  Server100ToolsPoliciesDatabaseEngine1033
Interwebs
• http://www.mssqltips.com/category.asp?catid=89
• Blogs
• Bing or Google



                       DBA-216| Evaluate Daily Checklist with PBM and CMS   18
Policy Alerts
Message Number         Evaluation Mode
34050                  On change – prevent when
                       policies are enabled for automatic
                       evaluation.
34051                  On change – prevent when the
                       policy is on demand
30452                  On Schedule
34053                  On change – Log


* On demand cannot be enabled so there
are no alerts.

                   DBA-216| Evaluate Daily Checklist with PBM and CMS   19
PBM Views
Views in MSDB database and dbo schema
•   syspolicy_policies
•   syspolicy_conditions
•   syspolicy_system_health_state
•   syspolicy_categories
•   syspolicy_policy_category_subscriptions
•   syspolicy_policy_execution_history
•   syspolicy_policy_execution_history_details
•   syspolicy_object_sets
•   syspolicy_target_sets

    For more: http://msdn.microsoft.com/en-us/library/bb510742.aspx

                                   DBA-216| Evaluate Daily Checklist with PBM and CMS   20
PBM - ExecuteSQL
The ExecuteSql() function can be used against
any facet and it'll be executed once for each
target in the target set.

The proxy account is called
##MS_PolicyTsqlExecutionLogin## used for
scheduled jobs

http://blogs.msdn.com/b/sqlpbm/archive/2008/0
7/03/executesql.aspx

                      DBA-216| Evaluate Daily Checklist with PBM and CMS   21
PBM Gotchas!
• Cannot modify or create facets
• Policies fail to read mount points as
  separate locations
• ExecuteSQL only supports @ObjectName
  and @SchemaName
• Reporting is very limited out of the box
• On Change-Prevent is limited
• Best Practice Policies may not be best
  practice for your shop.

                     DBA-216| Evaluate Daily Checklist with PBM and CMS   22
PBM Demo
Import Policies
Create a Category
Export Policies
Create Policy
Evaluate Policy
•   On-Demand
•   Scheduled
•   Apply Policy Change
View Policy History




                          DBA-216| Evaluate Daily Checklist with PBM and CMS   23
Central Management Server (CMS)
Similar to local server group except it’s a
repository for your team.
Group database servers
• Environment
• Version
• Location
Apply scripts or policies against all servers in a
group
Not all checklist items can be validated with PBM
Can use SQL Server 2008 R2 Express

                         DBA-216| Evaluate Daily Checklist with PBM and CMS   24
CMS Internals
MSDB is used to store servers and groups
Servers –
msdb.dbo.sysmanagement_shared_registered_servers_internal

Groups –
msdb.dbo.sysmanagement_shared_server_groups_internal




                               DBA-216| Evaluate Daily Checklist with PBM and CMS   26
CMS Security
•   ServerGroupAdministratorRole role can manage the central management
    server.
•   ServerGroupReaderRole role is required to connect to a central
    management server.
•   Windows Authentication of the individual servers is used to execute t-sql and
    policies.




                                       DBA-216| Evaluate Daily Checklist with PBM and CMS   27
First look at CMS




                    DBA-216| Evaluate Daily Checklist with PBM and CMS   28
DEMO!
Create Configuration Management Server
Create Groups
Register Servers
Execute scripts against a group
Execute policy against a group




                   DBA-216| Evaluate Daily Checklist with PBM and CMS   29
CMS Gotchas!
• CMS itself cannot automate query or policy
  execution.
• CMS only supports windows authentication
• Query results are ordered by server name
• Cannot include host server (Unless you use
  127.0.0.1 or add port number)
• Query executes for all listed servers.
  (Includes duplicates)

                    DBA-216| Evaluate Daily Checklist with PBM and CMS   30
Reporting - EPM Framework
http://epmframework.codeplex.com/
EPMF leverages
•   Central Management Server
•   Policy-Based Management
•   PowerShell
•   XML
•   SQL Server Reporting Services




                          DBA-216| Evaluate Daily Checklist with PBM and CMS   31
DBA-216| Evaluate Daily Checklist with PBM and CMS   32
Leverage PowerShell to automate CMS




Aaron Nelson – SQL University PowerShell Week

                     DBA-216| Evaluate Daily Checklist with PBM and CMS   33
DEMO!
Automate CMS with PowerShell




                   DBA-216| Evaluate Daily Checklist with PBM and CMS   34
Where to go from here?
Automate a daily checklist!

Go to
http://johnsterrett.com/go/dailychecklist for
reference material and sample code.




                                Session Code | Session Title   35
Complete the Evaluation Form
to Win!
Win a Dell Mini Netbook – every day – just for
submitting your completed form. Each session
evaluation form represents a chance to win.

Pick up your evaluation form:
• In each presentation room                         Sponsored by Dell
• Online on the PASS Summit website
Drop off your completed form:
• Near the exit of each presentation room
• At the Registration desk
• Online on the PASS Summit website

                                            Session Code | Session Title   36
Thank you
for attending this session and the
2011 PASS Summit in Seattle




                                     October 11-14, Seattle, WA
Microsoft SQL                Microsoft               Ask The Experts             Hands-on Labs
  Server Clinic             Product Pavilion            @ Dev Pods
   Work through your         Talk with Microsoft SQL    Meet Microsoft SQL       Get experienced through
technical issues with SQL     Server & BI experts to    Server Engineering        self-paced & instructor-
    Server CSS & get          learn about the next       team members &             led labs on our cloud
 architectural guidance       version of SQL Server         SQL MVPs                 based lab platform -
      from SQLCAT           and check out the new                                bring your laptop or use
                            Database Consolidation                                 HP provided hardware
                                   Appliance


     Room 611                    Expo Hall             6th Floor Lobby              Room 618-620

                                                                    Session Code | Session Title   38

Evaluating Daily Checklist Against 1000 Servers using Policy Based Management

  • 1.
    Evaluate your DailyChecklist against 100+ instances of SQL Server while you get a cup of coffee http://johnsterrett.com/go/dailychecklist John Sterrett Senior DBA Remote DBA Experts October 11-14, Seattle, WA
  • 2.
    What we willcover… • What should be included in your daily checklist • Build Policy Based Management Policies • Import Policy Based Management Policies • Automate execution of daily checklist • Providing reporting solution for daily checklist DBA-216| Evaluate Daily Checklist with PBM and CMS 2
  • 3.
    About Me…. • Iam a Remote DBA Expert • Responsible 100+ Instances of SQL Server • Senior DBA on Integration Team • Founder of WVPASS (SQL User Group) • Mid-Atlantic Regional Mentor • Host SQL Saturday #36 & #80 • I reside in Wheeling, WV (Pittsburgh, PA) DBA-216| Evaluate Daily Checklist with PBM and CMS 3
  • 4.
    My Story…. Backups / Restores Failed Jobs Corruption Urgency Low Disk Space Failed mission critical SQL Jobs Process improvements Pittsburgh Steelers Continuing education winning the Super Bowl Projects Index Management Everything else… Performance Tuning Importance Comes from The 7 Habits of Highly Effective People by Stephen R. Covey DBA-216| Evaluate Daily Checklist with PBM and CMS 4
  • 5.
    Daily Checklist Questions Doyou have a daily checklist? What is your daily checklist? • Full backups • Transactional Log backups • Free space • SQL Agents are enabled • SQL Agent jobs succeeded How do you evaluate your daily checklist? • Central Management Server (CMS) • Policy Based Management (PBM) DBA-216| Evaluate Daily Checklist with PBM and CMS 5
  • 6.
    Do you havea daily checklist? 46% Yes No 54% DBA-216| Evaluate Daily Checklist with PBM and CMS 6
  • 7.
    What's in yourdaily checklist? 0% 5% Full Backups 8% 20% succeeded Transactional log backups succeeded 12% SQL Services are running SQL Agent jobs 19% succeeded Disks have free space 19% Data and Log files 17% have free space Other DBA-216| Evaluate Daily Checklist with PBM and CMS 7
  • 8.
    How do youevaluate your checklist? 25 21 20 15 10 9 7 7 5 3 3 2 0 How do you evaluate your daily checklist? DBA-216| Evaluate Daily Checklist with PBM and CMS 8
  • 9.
    Job Notifications….. DBA-216| Evaluate Daily Checklist with PBM and CMS 9
  • 10.
    Trust but verify….. • Is the SQL Agent enabled for all servers? • Does email operator exist for all jobs? • Is the operator the same across all servers? • Is Database Mail enabled for all servers? DBA-216| Evaluate Daily Checklist with PBM and CMS 10
  • 11.
    I prefer notifications DBA-216| Evaluate Daily Checklist with PBM and CMS 11
  • 12.
    Policy Based Management •Policy-Based Management is a system for managing one or more instances of SQL Server 2008 (* BOL). • Some facets allow you to enforce standards with “On-Change – Prevent” • Can import and export policies • Apply changes when evaluation fails • Policies can run against SQL 2000 & 2005 DBA-216| Evaluate Daily Checklist with PBM and CMS 12
  • 13.
    I use PBMto do two things… Prevent things from happening Apply changes Automate validation of checklists • Checklists are prone to human error. • Server configurations can change over time. Daily checklist items we will validate • SQL Agent is enabled • SQL Agent Jobs • Full backups • Transactional Log backups • Free Space DBA-216| Evaluate Daily Checklist with PBM and CMS 13
  • 14.
    PBM Concepts andTerms • Targets • facets • conditions • policy • categories • server restrictions DBA-216| Evaluate Daily Checklist with PBM and CMS 14
  • 15.
    PBM Example –Page Verify PageVerify Page Verify Policy Database Target Database Performance Facet @PageVerify = true Condition SQL Server 2005 or newer Server Restriction On Schedule Evaluation Mode http://www.littlekendra.com/2011/01/25/pageverify/ DBA-216| Evaluate Daily Checklist with PBM and CMS 15
  • 16.
    Evaluation Modes On Demand •Executed by user or powershell scripts On Schedule • Uses SQL Agent (Runs via powershell script) On Change – Prevent • Uses DDL Triggers • * Nested Triggers should be enabled On Change – Log Only • uses event notification For More: http://msdn.microsoft.com/en- us/library/bb510667%28SQL.100%29.aspx DBA-216| Evaluate Daily Checklist with PBM and CMS 16
  • 17.
    On-Change Evaluation…. Not allfacets support On-change. • On Change – Log (17) • On Change – Prevent (12) • Application Role • Resource Pool • Asymmetric Key • Schema • Database Role • Stored Procedure • Table Options • Endpoint • User Defined Function • Login Options • User Options • Multipart Name • View Options • Workload Group DBA-216| Evaluate Daily Checklist with PBM and CMS 17
  • 18.
    Where can Ifind policies? Best Practices • SQL Server 2008 Feature Packs • C:Program FilesMicrosoft SQL Server100ToolsPoliciesDatabaseEngine1033 Interwebs • http://www.mssqltips.com/category.asp?catid=89 • Blogs • Bing or Google DBA-216| Evaluate Daily Checklist with PBM and CMS 18
  • 19.
    Policy Alerts Message Number Evaluation Mode 34050 On change – prevent when policies are enabled for automatic evaluation. 34051 On change – prevent when the policy is on demand 30452 On Schedule 34053 On change – Log * On demand cannot be enabled so there are no alerts. DBA-216| Evaluate Daily Checklist with PBM and CMS 19
  • 20.
    PBM Views Views inMSDB database and dbo schema • syspolicy_policies • syspolicy_conditions • syspolicy_system_health_state • syspolicy_categories • syspolicy_policy_category_subscriptions • syspolicy_policy_execution_history • syspolicy_policy_execution_history_details • syspolicy_object_sets • syspolicy_target_sets For more: http://msdn.microsoft.com/en-us/library/bb510742.aspx DBA-216| Evaluate Daily Checklist with PBM and CMS 20
  • 21.
    PBM - ExecuteSQL TheExecuteSql() function can be used against any facet and it'll be executed once for each target in the target set. The proxy account is called ##MS_PolicyTsqlExecutionLogin## used for scheduled jobs http://blogs.msdn.com/b/sqlpbm/archive/2008/0 7/03/executesql.aspx DBA-216| Evaluate Daily Checklist with PBM and CMS 21
  • 22.
    PBM Gotchas! • Cannotmodify or create facets • Policies fail to read mount points as separate locations • ExecuteSQL only supports @ObjectName and @SchemaName • Reporting is very limited out of the box • On Change-Prevent is limited • Best Practice Policies may not be best practice for your shop. DBA-216| Evaluate Daily Checklist with PBM and CMS 22
  • 23.
    PBM Demo Import Policies Createa Category Export Policies Create Policy Evaluate Policy • On-Demand • Scheduled • Apply Policy Change View Policy History DBA-216| Evaluate Daily Checklist with PBM and CMS 23
  • 24.
    Central Management Server(CMS) Similar to local server group except it’s a repository for your team. Group database servers • Environment • Version • Location Apply scripts or policies against all servers in a group Not all checklist items can be validated with PBM Can use SQL Server 2008 R2 Express DBA-216| Evaluate Daily Checklist with PBM and CMS 24
  • 25.
    CMS Internals MSDB isused to store servers and groups Servers – msdb.dbo.sysmanagement_shared_registered_servers_internal Groups – msdb.dbo.sysmanagement_shared_server_groups_internal DBA-216| Evaluate Daily Checklist with PBM and CMS 26
  • 26.
    CMS Security • ServerGroupAdministratorRole role can manage the central management server. • ServerGroupReaderRole role is required to connect to a central management server. • Windows Authentication of the individual servers is used to execute t-sql and policies. DBA-216| Evaluate Daily Checklist with PBM and CMS 27
  • 27.
    First look atCMS DBA-216| Evaluate Daily Checklist with PBM and CMS 28
  • 28.
    DEMO! Create Configuration ManagementServer Create Groups Register Servers Execute scripts against a group Execute policy against a group DBA-216| Evaluate Daily Checklist with PBM and CMS 29
  • 29.
    CMS Gotchas! • CMSitself cannot automate query or policy execution. • CMS only supports windows authentication • Query results are ordered by server name • Cannot include host server (Unless you use 127.0.0.1 or add port number) • Query executes for all listed servers. (Includes duplicates) DBA-216| Evaluate Daily Checklist with PBM and CMS 30
  • 30.
    Reporting - EPMFramework http://epmframework.codeplex.com/ EPMF leverages • Central Management Server • Policy-Based Management • PowerShell • XML • SQL Server Reporting Services DBA-216| Evaluate Daily Checklist with PBM and CMS 31
  • 31.
    DBA-216| Evaluate DailyChecklist with PBM and CMS 32
  • 32.
    Leverage PowerShell toautomate CMS Aaron Nelson – SQL University PowerShell Week DBA-216| Evaluate Daily Checklist with PBM and CMS 33
  • 33.
    DEMO! Automate CMS withPowerShell DBA-216| Evaluate Daily Checklist with PBM and CMS 34
  • 34.
    Where to gofrom here? Automate a daily checklist! Go to http://johnsterrett.com/go/dailychecklist for reference material and sample code. Session Code | Session Title 35
  • 35.
    Complete the EvaluationForm to Win! Win a Dell Mini Netbook – every day – just for submitting your completed form. Each session evaluation form represents a chance to win. Pick up your evaluation form: • In each presentation room Sponsored by Dell • Online on the PASS Summit website Drop off your completed form: • Near the exit of each presentation room • At the Registration desk • Online on the PASS Summit website Session Code | Session Title 36
  • 36.
    Thank you for attendingthis session and the 2011 PASS Summit in Seattle October 11-14, Seattle, WA
  • 37.
    Microsoft SQL Microsoft Ask The Experts Hands-on Labs Server Clinic Product Pavilion @ Dev Pods Work through your Talk with Microsoft SQL Meet Microsoft SQL Get experienced through technical issues with SQL Server & BI experts to Server Engineering self-paced & instructor- Server CSS & get learn about the next team members & led labs on our cloud architectural guidance version of SQL Server SQL MVPs based lab platform - from SQLCAT and check out the new bring your laptop or use Database Consolidation HP provided hardware Appliance Room 611 Expo Hall 6th Floor Lobby Room 618-620 Session Code | Session Title 38

Editor's Notes

  • #3 If you currently have a solution like Scom or Big Brother to monitor daily checklist then this session will not be for you.
  • #15 Focus on facets because this determines your evaluation mode options.
  • #25 A perfect example of something that cannot be evaluated with Policy Based Management is disk space on a mount point.