Download presentation
Presentation is loading. Please wait.
Published byCaroline Heinrich Modified over 6 years ago
1
The Ultimate Maintenance Plan By Edward Roepe Perimeter DBA, LLC
3
About Me Over 25 years experience in databases
I have been working with SQL Server since version 4.21 Worked as employee and consultant on some of the largest SQL database installations in US Experience in many different industries Experience in very large databases, high transaction systems, and high availability Microsoft Certified Started consulting firm in 2014 in the Atlanta area
4
Agenda Discuss the Microsoft Built-in Maintenance Plans
Discuss the Ola Hallengren Maintenance Solution Discuss other items that should be part of a maintenance plan Discuss some typical maintenance plans Discuss alerts Demo
5
Goals of a maintenance solution
Lights out Reliable Flexible Proactive alerting Robust Report errors
6
Microsoft Maintenance Solution
Integrity Check Index Maintenance Update Statistics Database Backups
7
Starting the Microsoft Maintenance Plan
8
Microsoft Solution – Pros & Cons
Simple to setup. Just run the wizard Designed for basic servers Provided by Microsoft Cons Sometimes with older versions you have to have the same version of SSMS as SQL to create/modify Index maintenance does all indexes Statistics maintenance does all statistics
9
Ola Hallengren Maintenance Solution
Written by Ola Hallengren DBA in Saxo Bank, a Danish investment bank Microsoft MVP – SQL Server Consists of SQL Server Backups SQL Server Integrity Check SQL Server Index and Statistics Maintenance Log of each step into table
10
Installing the solution
Download the scripts Create database to contain stored procedures and log table (suggest DBAUtility) Install the stored procedures Create the scheduled jobs Modify the scheduled jobs as needed Add additional maintenance functions
11
How it works Stored Procedure is called for each function (index, backup, stats, etc.) Start of each function/step is logged into table End of each function/step is logged into table Return code and any errors are returned to calling program
12
Backups – Common Options
Backup location Databases to include or exclude Full Backup Differential Backup Log Backup Verify backup Number of hours to cleanup old backups
13
Backups – Advanced Options
Compression Call to 3rd party backup programs (Quest Litespeed, Idera SQL Safe, etc.) Perform a full backup if log is taken and no full backup exists Copy Only – For snapshots. Take backup without disrupting last full backup Backup to multiple files at the same time Perform Verify and Checksum Specify cleanup BEFORE or AFTER backup
14
Full Backups - Example EXEC = = = = = = = = = = = 'Y'
15
Log Backups - Example EXEC = = = = = = = = = = = 'Y'
16
Index & Statistics – Basic Options
Databases to include or exclude Tables to include or exclude Define three fragmentation groups Low = Zero to first threshold Medium = First threshold to second threshold High = Second threshold to infinity Define actions for each group (example) Low = No action Medium = Index reorganize High = Index Rebuild:
17
Index & Statistics – Advanced Options
Specify the order for performing indexing (Online, reorganize, rebuild, etc.) Program will automatically select available options based on version and edition Specify MAXDOP or SORT_IN_TEMPDB Specify FILLFACTOR and PADINDEX Specify UpdateStatistics or OnlyModifiedStatistics Specify the time limit (to prevent running into production)
18
Index & Statistics - Example
EXEC = = = = = = = = = = = = 'Y'
19
Integrity Check – Basic Options
Specify database to include or exclude Specify PHYSICAL_ONLY or NOINDEX
20
Integrity Check - Example
EXEC = = 'Y'
21
Ola Hallengren – Pros & Cons
Very powerful. A simple command can do 1000s of steps Program automatically deals with version and edition so you can roll out the same plan to multiple different servers The index & statistics program is very sophisticated and will only do what is needed Cons Some learning curve on learning the commands and syntax The supplied maintenance jobs use CMD mode. Using the T-SQL mode is much simpler
22
Tricks to rolling out maintenance jobs
Use CMS or Registered servers to deploy to multiple servers Create first set of jobs, script the jobs, and then deploy to other servers. Will need to remove the ID of the schedule Write script to dynamically calculate the location of the SQL log subdirectory Prefix all maintenance jobs with a unique identifier. I use “DBA –” Setup Database Mail, operator and alerts on all jobs
23
Other Maintenance Items
Recycle the SQL Log daily (retention 15 to 30 days) Cleanup the job history table in MSDB (retention 30 days) Cleanup the backup history table in MSDB (retention 30 days) Cleanup to history table in MSDB (retention 30 days) Cleanup the TXT files in the SQL Log directory (retention 30 days) Cleanup the Ola log table (retention 7 to 30 days) Cleanup the Syspolicy table Setup alerts
24
Alerts – Script Part 1 Error Hardware or System Problems Error Logical Page Consistency I/O Error Error Read Operation I/O Error Error Page Corruption In Memory Error Filegroup Full Error Deadlock Detected Error Database Log Not Available Error Transaction Log Full Error Invalid LSN in Transaction Log Error Error With Transaction Log Error Index Corruption
25
Alerts – Script Part 2 Severity 16 - Miscellaneous User Error Severity 17 - Insufficient Resources Severity 18 - Nonfatal Internal Error Severity 19 - Fatal Error in Resource Severity 20 - Fatal Error in Current Process Severity 21 - Fatal Error in Database Processes Severity 22 - Table Integrity Suspect Severity 23 - Database Integrity Suspect Severity 24 - Hardware Error Severity 25 - Unexpected Fatal Error
26
Suggested Maintenance Plans
Task Small Medium Large Integrity Check Daily Daily or Weekly Weekly Update indexes Update statistics Daily or Hourly Full Backups Differential Backups None Log Backups Hour 15 min or hour 15 min or less Cleanup tasks
27
Demo of OLA install How to download software
How to install stored procedures and jobs Change the default database Create jobs option Backup directory option No schedule on jobs
28
Demo of “DBA” Jobs How to install stored procedures (Script 3023)
How to install scheduled jobs (Script 3022) Show Daily DB Maintenance Show Daily Full Backups Show Daily Log Backups Show Daily Syspolicy Purge Show Daily System Cleanup Show Alerts
29
Summary Tour of Microsoft maintenance solution
Tour of Ola Hallengren maintenance solution Other maintenance items Setup alerts Suggested maintenance plans Demo of Ola install Demo of DBA jobs install
30
Q&A Contact Information Edward Roepe Perimeter DBA, LLC 4780 Ashford Dunwoody Road, Suite 337 Dunwoody GA 30338 (678) Our Services Health Checks Security Checks Performance Tuning High Availability Disaster Recovery Managed Services Business Intelligence Development Services
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.