Professional Documents
Culture Documents
Exam 70-432 TS: Microsoft SQL Server 2008, Implementation and Maintenance
Patrick Pitre
Agenda
Microsoft SQL Server 2008 Exams and Certifications
Exam Roadmap
Certification Paths
Certification Roadmap
Deep-dive: Backup/Restore
Backup operations Restore operations Common Scenarios
o Exam Preparation
o Practice Questions o Additional Reading and Study Materials
MCA
IT Certifications
MCM
MOS EXPERT
MCTS
AND/OR
MOS
MTA
MOS Certifications
MOS MASTER
Upgrade Path Exam: 70-453 Transition your MCITP SQL 2005 DBA to
TS: Microsoft SQL Server 2008, Development PRO: Designing Database Solutions and Data Access using Microsoft SQL Server 2008 Prerequisite: 70-433 TS: Microsoft SQL Server 2008, Business Intelligence Development and Maintenance. PRO: Designing a Business Intelligence Infrastructure Using Microsoft SQL Server 2008 Prerequisite: 70-448 Upgrade Path Exams available for all
Microsoft Learning representatives are available all day to answer certification questions via chat
Download promotional offers into your Virtual Backpack and book your exams soon!
Target Audience
Candidates should have one to two years of experience using SQL Server 2008 or two to three years of experience using a previous version of SQL Server. Candidates for this exam are IT professionals who have jobs in which database administration is their main area of responsibility, or they work in environments in which databases are central to their job roles. These job roles include the following:
IT generalists who work in environments in which SQL Server 2008 is part of an overall solution IT professionals who manage systems that run SQL Server 2008 IT professionals who work with third-party applications that are built on SQL Server 2008 Developers who build applications that use SQL Server 2008
Authentication Modes
Windows (local Windows account or Active Directory/Domain account) Mixed Mode Windows and SQL Server authentication. Recommended: Dont use Mixed Mode unless you have to (e.g., dealing with legacy system).
Data Directories
Best practice: Use different disks to house data files (.mdf) and transaction logs (.ldf) files. Use different RAID types for performance. Transaction logs typically need highest disk-throughput. Set default locations for new database directories during installation. Can change later if necessary.
Collation Settings
Supports regional system locale. Affects ordering and case-sensitivity
Named Instance
Allows you to run multiple instances of SQL Server on same machine, all accessible via TCP port 1433 (configurable), named pipes, etc.
Access via the computer hostname (or IP address if allowed) and Instance name.
If computer name is MySqlServer, and instance name is SQL2008, then access with MySqlServer\SQL2008.
Windows Service name will also show Instance name (same as above).
Backup Wisdom
Every hard disk is guaranteed... To crash. - Unknown
A business that fails to backup, risks failure to be in business. - T.E Ronneberg Backup: Do it today, or pay tomorrow. Unknown SYSTEM ALERT: Backup Not Found: A)bort, R)etry, C)ry?
Blessed are the pessimists, for they have made backups. - Unknown
It's so logical and so simple. Fat is the backup fuel system. The role it plays in the body is that when there's no carbohydrate around, fat will become the primary energy fuel. That's pretty well known. Robert Atkins
Backup Basics
Four type of backups:
o Database backups
o Most common for most basic/straight-forward scenarios
o File backups
o Used to backup/recover individual files/filegroups. o Good for large database, where disk space is an issue.
o Partial backups
o o o o Can be used with Full or Differential NOT transaction logs. Works with filegroups. Back up Primary filegroup, read/write filegroups, plus specified files/filegroups Best for read-only filegroups, and you dont want to backup entire database
o Bandwidth, disk space, etc.
o Differential
o Can run in between Full backups o Used to keep backup size small, but each successive differential backup will be bigger than last,, until a full backup is performed again.
Simple
Only recover changes up to last backup.
No transaction log backups. Not suitable for most production OLTP systems, as risk of data-loss is high.
Bulk-Logged
Requires transaction log backups. Minimal logging for recovery operations, so recovery can be faster.
Regular operations are still logged
Use with care set recovery model to bulk-logged, do the data-recovery, then set recovery model back to Full (or Simple).
Backup/Recovery
Transaction Log Backups (Full/Bulk-Logged recovery models only)
Essential for point-in-time data recovery.
Contains all the transactions that have occurred since the last full backup
Differential Backups
Only backs up changes in database since last full backup.
Smaller than Full backup, but will grow in size until next full backup.
Work well with large databases, when disk space or performance can become an issue.
Need a base backup (full backup) to recover fully. Can be used with transaction log backups.
Maintenance Plans
Can automate many DBA tasks, not only backups!
Execute T-SQL Statement, Index rebuild/reorg, update statistics. Management -> Maintenance Plans -> (right-click folder)
Create plan with specs below. Make sure folder exists. Check Verify backup integrity!
<-
Cleanup Task: Remove old backup files Sub-folders Delete old files every week
Cleanup Task: Remove old backup files Include Sub-folders Delete old files every week (in this example)
Minimizes data loss can restore data up to most recent transaction log backup.
The more critical the data, the more often t-log backups should be scheduled.
Tolerance to pain and data loss. Decide, with LOB managers and stakeholders, how much data can be lost in a disaster situation. Every four (4) hours of data loss? Two (2) hours? One (1) hour?! Make sure you have sufficient disk storage for all your backup files!
Restore
Restore full backup first. If you have multiple transaction logs to be restored, make sure you restore and set the option RESTORE WITH NO RECOVERY option.
Or, in the restore wizard, make sure this option is checked. This will allow you restore subsequent tlogs, and restore more data closer to database disaster.
Note: if using Differential backups, restore last full backup, then any differential backups, then any t-log backups.
Restore
Simple Recovery Model is easiest to restore, since only dealing with one or two backups (Full and Differential, respectively).
If you are using Full backups only, only need to restore one backup file (last full backup). If you are using Differential backups, need to restore base backup first (full backup), then restore the differential backup(s).
Replication
Undelivered transactions from Publisher to Subscriber.
Database Mirroring
Paused, or mirror database is significantly behind principle database.
Checkpoints
Write all dirty data and log pages to disk. Happens when a backup occurs.
Using this method, you lose your ability to do point-in-time restores (but can save your hide in an emergency!) Once a transaction log completely fills up a disk, the risk of losing ALL of your data greatly increases.
Perform a FULL backup as soon as possible after a truncate_only command. Resume transaction log backups immediately.
Schedule
Jobs can have multiple schedules.
Notifications
Email, Windows Event Log, Pager. Can automatically delete job upon completion (one-off jobs).
Alerts
E.g., Insufficient Permission (to run job), T-SQL syntax error, Fatal Errors, Can respond to condition, and notify as needed
Logging
Can log SQL job historyto table, output to file, or log in job history
Contains user name, email, pager information, etc. Not used for server/instance/database security Can view notifications sent to user by SQL Agent jobs Can set Operator notification schedules Policies Powerful way to manage security and enforce standards
Create expressions to match conditions. Examples:
Database Roles
Database-specific roles (db_owner, db_datareader, db_datawriter, etc.) Security -> Logins -> (login Properties) -> User Mapping. New SQL Server login/user only has Public database role assigned by default.
Logins Can be user from Active Directory, or can be SQL-specific Authentication (SQL only account)
The sa account is a SQL Server login.
Can be assigned to server roles Can be assigned database roles Using Securables, can apply more fine-grained permissions to servers, endpoints, and logins. Logins can be disabled, have password policy, other controls similar to Windows or AD account.
Server Audit: (Security -> Server Audit Specifications (right-click) -> New Server Audit Specification)
Select Audit object created earlier. Audit Action Type (e.g., BACK_RESTORE_GROUP, FAILED_LOGIN_GROUP, SUCCESSFUL_LOGIN_GROUP, etc.) Object Class: Database, Object, Schema
Database Audit: (Databases -> <database_name> -> Security -> Database Audit Specification (right-click) -> New Database Audit
Same as Server Audit -> select Action Type, object, schema, etc. Database-specific Audit Action Types
Enable new Audit (right click -> Enable) Create Audit Specification
Test by attempting to login with bad account Review Windows Security event log
Admin trick: to find out if a change requires a SQL Service restart, and run SELECT * FROM sys.Configurations; if is_dynamic = 1 (yes/true), then no service restart required.
Bulk Insert
Set Recovery Model to bulk-logged to avoid filling up SQL transaction logs. Inserts comma-separated values from a text file into the AdventureWorks Sales.Customer table. Set/resets recovery model to BULK_LOGGED then back to FULL - to minimally log you bulk load of data (your transaction log will thank you!)
SSIS Package
Use BIDS to create everything from simple one-off jobs to complex ETL (Extract/Transform/Load) packages.
CREATE_PARTITION_FUNCTION
RANGE (LEFT, RIGHT) FOR VALUES (<boundry_value>) SPLIT RANGE
Used to add a partition to the partition function Used to drop a partition, and move its data to an existing partition
MERGE RANGE
CREATE_PARTITION_SCHEME
Partitions use filegroups. This statement maps partitions to filegroups (physical files). Data moved to partitions based on user-defined criteria (e.g., create_date > 6-06-2011 or IDENTITY column (OrderId > 100000).
Non-clustered indexes
Multiple non-clustered indexes per table (999 in SQL Server 2008) Can use on Views. Good candidates are fields frequently included in a WHERE clause, as well as JOIN and GROUP BY statements.
Performance
Although indexes can speed up data access, there is a performance overhead associated with data edits, as indexes have to update as well. Particularly apparently when dealing with very large indexes.
Types of indexes
Filtered index
Allows a WHERE clause on index.
Spatial Geometric data (points, lines, polygons) Same rules apply as other index types. XML
Deadlocks
Severe blocking can lead to deadlocks: where two transactions are competing for the same resource; a vicious circle, as both tasks will wait endlessly for each other.
Multiple way to find deadlocks:
Right click database -> Reports -> Standard Reports -> All Blocking Transactions T-SQL/DMV (Dynamic Management Views)
Second, run wizard again, and choose Set up data collection Be prepared for fast data growth can be upwards of 500 MB/day in some cases. 3-4 % potential performance overhead View reports of collected data: Management -> Data Collection -> (right-click) -> Reports -> Management Data Warehouse ->
Server Activity History Disk Usage Summary Query Statistics History
Merge
Good for mobile/remote databases that need to merge changes when connected.
SQL Compact Edition
Snapshot
Can provide initial data for merge or transactional replication. Can also be used to refresh the data. Can use as basis for reports (to minimize server performance impact of reporting-style queries)
Push/Pull
Snapshot Agent
Manages the snapshot of published DB objects, including generating the file, and synchronization.
Distribution Agent
Moves the snapshots and transactions to the Subscribers.
Principle (Standard or Enterprise edition) Witness (Standard, Enterprise, Workgroup, Express) Server must first be configured (security, TCP port, etc.). Database only. Operating Mode
High-performance (asynchronous)
Commit at principle first, then witness if successful
High-safety (synchronous)
Commit changes on both servers
Failover Clustering (Standard or Enterprise edition) Nodes: Each SQL instance is a node. Up to 16 nodes. Entire instance (Mirroring is per-database only). Single copy of database in shared storage array. Failback policy
Can fall back immediately or during scheduled time.
Upon failover, transactions are rolled forward, incomplete transactions are rolled back, etc. Encryption can use encrypted connections, via certificates.
Eliminate answers you know are not correct Mark to review, and come back later Manage your time Dont Panic! Review all your answers at the end
Q&A