automating routine maintenance

15
AUTOMATING ROUTINE MAINTENANCE Ken Simmons

Upload: kensimmons

Post on 11-May-2015

1.661 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Automating routine maintenance

AUTOMATING ROUTINE

MAINTENANCE

Ken Simmons

Page 2: Automating routine maintenance

Objectives

1. Make informed decisions about the maintenance that must be performed within SQL Server.

2. Enhance Proactive Administration by receiving Notifications for Job Failures and Alerts.

3. Ensure consistency across your environment by performing routine system maintenance.

Page 3: Automating routine maintenance

Agenda

Configuring Database Mail Creating Alerts Creating An Administrative

Database Configuring Maintenance Jobs Maintenance Considerations

When Upgrading a Database

Page 4: Automating routine maintenance

Why Do We Need To Perform Routine Maintenance?

Page 5: Automating routine maintenance

Configuring Database Mail

Enable Database Mail Create Profile Create Account Create Operator Enable Database Mail

in SQL Server Agent Enable Fail-Safe

Operator

Page 6: Automating routine maintenance

Creating Alerts

Automated response to a predefined event

Severity Codes Fatal Errors19-25

Specific Error Numbers Error 825 – Severity 10 http://sqlskills.com/BLOGS/

PAUL/post/A-little-known-sign-of-impending-doom-error-825.aspx

Page 7: Automating routine maintenance

Creating Alerts (Cont) Non Fatal ErrorsSELECT * FROM sys.messagesWHERE language_id = 1033 AND is_event_logged = 1 AND severity < 19

Page 8: Automating routine maintenance

Why Do You Need An Administrative Database?

Provide central location for Administrative Tables, Functions, and Procedures

Track Database Sizes for Capacity Planning

Store DMV Output Holds the Nums or

TallyTable http://www.sqlservercentral.c

om/articles/TSQL/62867/

Page 9: Automating routine maintenance

What Maintenance Jobs Should You Be Running?

Cycle the Error Log Make sure to increase the number

of log files first. sp_cycle_errorlog

Cleanup the Backup History Be careful if you havea lot of

history. sp_delete_backuphistory

Cleanup Mail History sysmail_delete_mailitems_sp sysmail_delete_log_sp

Page 10: Automating routine maintenance

Maintenance Jobs (Cont)

Update Statistics sp_updatestats

Index Maintenance > 5% and < = 30%

REORGANIZE > 30% REBUILD

Page 11: Automating routine maintenance

Maintenance Jobs (Cont)

Collect Database Sizes Check for long running jobs

http://code.msdn.microsoft.com/SQLExamples/Wiki/View.aspx?title=AgentLongRunning&referringTitle=Home

Check Database Integrity DBCC CHECKDB

Backups Script Restore to file using backup history tables

http://www.mssqltips.com/tip.asp?tip=1611 Make sure each job has an output file

Page 12: Automating routine maintenance

Maintenance Jobs(Cont)

Generate SQL Agent Job Schedule Report http://www.mssqltips.com/tip.asp?ti

p=1622

Page 13: Automating routine maintenance

Maintenance Considerations When Upgrading a Database

Change Database Compatibility Level ALTER DATABASE [DatabaseName]

SET COMPATIBILITY_LEVEL = 100

Check the integrity of the objects in your database DBCC CHECKDB ([DatabaseName]) WITH DATA_PURITY

Correct Row and Page Counts DBCC UPDATEUSAGE ([DatabaseName])

Set the page verification method to CHECKSUM ALTER DATABASE [DatabaseName]

SET PAGE_VERIFY CHECKSUM WITH NO_WAIT

Update Statistics With Full Scan sp_msforeachtable 'UPDATE STATISTICS ? WITH FULLSCAN'

Page 14: Automating routine maintenance

Questions?

Page 15: Automating routine maintenance

Links

Preproduction Checklisthttp://www.sqlservercentral.com/

articles/Administration/64732/

Blog: http://cybersql.blogspot.com/ Email: [email protected] Linked In:

http://www.linkedin.com/in/kensimmons Twitter: http://twitter.com/kensimmons