plany konserwacji sql server dla żółtodziobów
DESCRIPTION
Opowiedzieć w trzydziesci minut o konserwacji SQL Server wydaje się prawie niemożliwe, ale… Gdybyśmy spróbowali pomyśleć przez chwilę o porządku, spokoju, wolnym czasie i automatyzacji? Z jednej strony zaraportować cieżki dzień w biurze, z drugiej wciąż mieć czas na prasę – chociażby branżową. A jeśli tak naprawdę do naszego SQLa zaglądamy tylko raz dziennie, na kilka minut? Spróbujmy.TRANSCRIPT
Maintenance Plansfor beginners
@KoprowskiT
reklama
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
2
Doroczna konferencja Polskiej Grupy Użytkowników SQL Server – kilka faktów
28 kwietnia – całodzienne warsztaty
29-30 kwietnia – trzy ścieżki po pięć sesji każda
Stadion Miejski we Wrocławiu
Najlepsi prelegenci z Polski i Europy
Impreza integracyjna
Olbrzymia dawka wiedzy
http://conference.plssug.org.pl/
Select {BIO}
polish sql server user group leader
microsoft certified trainer
pass sql azure virtual chapter co-founder
blogger, influencer, technical writer
over 8 years living in data center in wrocław
bout 14 years in it/banking area
trainer, auditor, consultant
speaker at many international conferences: sql server community launch, time for sharepoint,
codecamps, sharepoint community launch, cissp day, sql in the city, infotrams, sql bits, sqlsaturday, careercon, sharepoint & sql connection, it camp,
deep dives co-author: high availability of sql server in the context of service level agreements
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
3
ENGLISH
maksymalny stopień równoległości prostych opcji
max degree of parallelism
Zwalniane spację w plikach bazy danych
Retain freed space in database files
Baza danych jest zagęszczonym mleku do stron ciągłych, ale strony nie są cofniętych przydziałów, a pliki bazy danych nie zmniejszać. Użyj tej opcji, jeśli oczekujesz, że baza
danych, aby rozwinąć ponownie i nie chcesz zmienić alokację przestrzeni. Po wybraniu tej
opcji pliki bazy danych nie zmniejszać możliwie. Korzysta z opcji NOTRUNCATE.
The database is condensed to contiguous pages but the pages are not deallocated, and the
database files do not shrink. Use this option if you expect the database to expand again, and
you do not want to reallocate space. With this option, the database files do not shrink as much as possible. This uses the NOTRUNCATE option.
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
4
AGENDA
Maintenance Plans – what are you talking about?
Maintenance Plans – how, where, when?
Methods, tools, right (?) ways
What Maintenance Plans can do you You
Short Demo
Q&A
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
5
Maintenance Plans – what we are talking about?
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
6
Maintenance Plans – what are you talking about?
Clean Environment
Silence
Knowledge about environment
Productivity / Performance
DEFINITION:
A database maintenance plan is a set of specific, proactive task
that need to be performed regularly on databases
to ensure their adequate performance and availability
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
7
Maintenance Plans – how, where, when?
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
8
Maintenance Plans – how, where, when?
HOW:
Maintenance Plan Wizard
Maintenance Plan Designer
T-SQL Scripts
PowerShell Scripts
WHERE
SQL Server Management Studio from Standard and above
See you in… Express
WHEN:
BEFORE: problems / service windows
AFTER: maintaining / clients back to home
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
9
HOW: Maintenance Plan Wizard
Very simple (although advanced) wizard
Providing possibility for creation simple task in dozens of seconds
Enough in many cases, environments
Limited but include many options
Limitations:
number of databases
granularity
single tasks / no multitasking
no scripting for another instances
some known problems in previous version of SQL Server
SQL Server 2005 Service Pack 2 / SQL Server 2008
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
10
HOW: Maintenance Plan Designer
More flexible and advanced tool (not on this session)
Graphical user interface with SSIS
Most often used for „really DBA”
Increased features
Workflow for specified tasks with execution plan
Multitasking
Two additional Maintenance plans
Execute T-SQL Statement
Notify Operator
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
11
LIMITATIONS: Maintenance Plan wizard & Designer
Limitations for both tools / those ideas are not possible
Identification and removing fragmentation for physical files
Identification abandoned, duplicated, forgotten indexes
Providing backup on demand
Werification good quality of backup
Werification succesful restore
Monitoring of performance
Monitoring of SQL OS
Monitoring of Windows OS
Monitoring available space
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
12
Maintenance Plan: t-sql & powershell scripts
Functionality for „Real *Tru* DBA”
Necessary for working with multiple databases, instances, server farms
Feauters for scripting:
Access to OS
Posibility of moving
Scripts sharing
One of the best examples and tools for free:
HTTP://OLA.HALLENGREN.COM/
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
13
(Everything I do) I do it for you
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
14
Maintenance plans: available tasks
Check Database Integrity | DBCC CHECKDB
Shrink Database | NEVER, NEVER, NEVER
Reorganize Index | ALTER INDEX , and next Update Statistics
Rebuild Index | ALTER INDEX, Update Statistics are not necessary
Update Statistics | Sp_updatestats
History Cleanup | Using msdb, don’t do that too much frequently
Execute SQL Server Agent Job | Providing scrip using wen You work with agent
Back Up Database (Full) | Executing BACKUP DATABASE with FULL option >>Transaction Log
Back Up Database (Differential) | Executing BACKUP DATABASE with DIFFERENTIAL option
Back Up Database (Transaction Log) | Executing BACKUP LOG, frequency...
Maintenance Cleanup Task | Most complicated feature ? BAK, TRN, TXT
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
15
Functionality: Verify Integrity of Database
using DBCC CHECKDB
Daily
Weekly
Monthly
DBCC CHECKDB (’database_name’) WITH NO_INFOMSGS
Suppresses all informational messages.
DBCC CHECKDB (’database_name’) WITH NO_INFOMSGS, ALL_ERRORMSGS
Displays all reported errors per object. All error messages are displayed by default. Specifying or omittingthis option has no effect. Error messages are sorted by object ID, except for those messages generated
from tempdb database.
In SQL Server Management Studio, the maximum number of error messages returned is 1000.
DBCC CHECKDB (’database_name’) NOINDEX
Specifies that intensive checks of nonclustered indexes for user tables should not be performed. Thisdecreases the overall execution time. NOINDEX does not affect system tables because integrity checks are
always performed on system table indexes
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
16Y
O U
S H
O U
L D
R E
M E
M B
E R
POSSIBILITIES: SHRINK DATABASE
NEVER USE THIS OPTION IN MAINTENANCE PLANS
MDF & LDF
100 GB reserved
15 GB in use
DBCC SHRINKDATABASE
or
DBCC SHRINKFILE | MANUAL MODE
Reduction of Reserved Space
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
17Y
O U
M U
S T
R E
M E
M B
E R
POSSIBILITIES: Maintain Index & Column Statistics
Automation:
AUTO_CREATE_STATISTICS
AUTO_UPDATE_STATISTICS
Executing automatically after: INSERT, UPDATE, DELETE
UPDATE STATISTICS table_name WITH FULLSCAN
When:
Never…
Just after Index Reorganization
On the days when we’re not using Index Rebuild or Reorganize Index
Important options (UPDATE STATISTICS):
All existing statistics
Column statistics only
Index statistics only
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
18Y
O U
S H
O U
L D
R E
M E
M B
E R
POSSIBILITIES: Reorganize vs rebuild
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
19
POSSIBILITIES: history clean up (MSDB)
Choosing the data (right data) for deleting:
Backup and restore history
SQL Server Agent job history
Maintenance Plan history
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
20Y
O U
M U
S T
R E
M E
M B
E R
Summary
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
21
SUMMARY
We should remember about:
Task sequences
Task execution
Task priority
Documentation
Using: daily / weekly / occasionally
Better expoloration of our environment
Monitoring (partially) of performance
Standard and above (sorry)
Maintenance Plan Wizard
for beginners and small installations
Maintenance Plan Designer
Adult , more complicated, wide environment
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
22
LINKS
Brad McGehee | Brad’ Sure Guide to SQL Server Maintenance Plans
„My new eBook, Brad’ Sure Guide to SQL Server Maintenance Plans is now available as
a free, 269 page PDF eBook. The book is designed for part-time or novice DBAs who
want to learn how to properly create Maintenance Plans using the tools that come with
SQL Server Management Studio (SSMS) in SQL Server 2005/2008.
LINK: http://bit.ly/1ijdnah
Ola Hallengreen | Maintenance Plans Scripts PASS slidedeck
„The SQL Server Maintenance Solution comprises scripts for running backups,
integrity checks, and index and statistics maintenance on all editions of Microsoft
SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012. The
solution is based on stored procedures, sqlcmd utility, and SQL Server Agent jobs”
LINK: http://bit.ly/1b220Ns
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
23
after hours…
MAIL: [email protected]
MSG: [email protected]
SKYPE: tjkoprowski
TWITTER/FACEBOOK/LINKEDIN: KoprowskiT
BLOGS:
ITPRO Anorak’s Vision: http://itblogs.pl/notbeautifulanymore/ [PL/EN]
Volume Licensing Specialites: http://koprowskit.eu/licensing/ [PL]My MVP Blog: http://koprowskit.eu/geek/ [PL/EN/ES]
Kariera IT Kraków | 22 Feb 2014 | KoprowskiT - Maintenance Plans for Beginners
24