This session includes the following topics: Backing up system databases Configuring log shipping Creating database snapshot Reverting a database from a snapshot Best practices
Trang 1Instructor Inputs S e
Trang 3This session includes the following topics:
Backing up system databases
Configuring log shipping
Creating database snapshot
Reverting a database from a snapshot
Best practices
Slide 1
Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005
Objectives
In this session, you will learn about:
Recovery model Backing up system databases Monitoring performance by using dynamic management views Configuring log shipping
Creating database snapshot Reverting a database from a snapshot Best practices that can be considered while restoring databases in SQL Server 2005
Tips and tricks that will help you effectively restore databases and use performance monitoring tools in SQL Server 2005 FAQs related to restore and log shipping concepts of SQL Server 2005
Trang 4Slide 2 of 20
Ver 1.0 Collaborate Session 8
Knowledge Byte
The recovery model determines the backup and restore strategies that can be used for a database.
There are three recovery models available in the SQL Server:
Simple recovery model Full recovery model Bulk-logged recovery model
In addition to user databases, you can back up the msdb, master, and model system databases A backup of these databases allows you to restore and recover the SQL Server system in the event of a system failure, such as a hard disk failure.
Slide 3
Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005
Knowledge Byte (Contd.)
You can create only a full database backup of the master database You should back up the master database when you execute any of the following:
CREATE DATABASE, ALTER DATABASE or DROP DATABASE statements
sp_addserver,sp_dropserver,sp_addlinkedserver, and sp_addmessage system stored procedures
The SQL Server provides database administrators with DMVs, which return server state information
The DMVs are a group of views and table-valued functions
Trang 5Slide 4 of 20
Ver 1.0 Collaborate Session 8
Knowledge Byte (Contd.)
Some DMVs are applied on the server as a whole and are stored in the master databases.
To view these DMVs, the user must have the VIEW SERVER STATE permission.
The remaining DMVs are specific to a particular database and to view them the user must have the VIEW DATABASE STATE permission.
In SQL Server 2005, DMVs have been organized in 12 categories
Microsoft Office
Slide 5
Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005
Knowledge Byte (Contd.)
Log shipping:
Can be used to maintain high availability in situations when it
is essential to provide a reliable stand by server and a fast failover.
To implement log shipping, you need to perform the following tasks:
Create a file share.
Configure log shipping on the primary server.
Specify the secondary server.
Trang 6Slide 6 of 20
Ver 1.0 Collaborate Session 8
Knowledge Byte (Contd.)
Database Snapshot:
Can be created by using the AS SNAPSHOT OF clause with the CREATE DATABASE statement.
Syntax:
CREATE DATABASE database_snapshot_name
ON ( NAME = logical_file_name, FILENAME = 'os_file_name' ) [ , n ]
AS SNAPSHOT OF source_database_name[;]
Slide 7
Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005
Knowledge Byte (Contd.)
Database Snapshot considerations:
You can create a database snapshot on the same server instance as the source database.
You can create multiple snapshots of a database.
You cannot drop, detach, or restore primary database
You cannot drop files from a database snapshot.
You cannot back up or restore database snapshots.
You cannot attach or detach database snapshots.
Trang 7Slide 8 of 20
Ver 1.0 Collaborate Session 8
Knowledge Byte (Contd.)
Reverting a database from a Snapshot:
Use the FROM DATABASE_SNAPSHOT clause with the RESTORE statement.
Syntax:
RESTORE DATABASE database_name FROM DATABASE_SNAPSHOT = snapshot_name
Slide 9
Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005
Best Practices
Avoid restoring databases from unknown sources Drop databases that no longer exist
Shutdown application before using RESTORE
Trang 8Slide 10 of 20
Ver 1.0 Collaborate Session 8
Tips and Tricks
Backup master database when master has been restored and any changes have been reapplied.
Use the Task Manager and Network Monitor Agent tools of Windows operating system to monitor the performance of the database server.
Save trace results to a file.
If you want the witness server to remain disconnected for a significant amount of time, you should remove the witness server from the session until it becomes available.
If you require only a single destination database, database mirroring is the recommended solution If you require more than one destination database, you need to use log shipping, either alone or with database mirroring
Slide 11
Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005
Can you backup and restore individual tables in SQL Server 2005?
No, you cannot backup and restore individual tables in SQL Server 2005.
FAQs
Trang 9Slide 12 of 20
Ver 1.0 Collaborate Session 8
If you execute DBCC CHECKDB statement, which other two statements are automatically executed?
If you execute DBCC CHECKDB statement, the DBCC CHECKTABLE and DBCC CHECKALLOC statements are automatically executed.
FAQs (Contd.)
Slide 13
Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005
Can you create a mirror of system databases?
No, you cannot create a mirror of system database.
FAQs (Contd.)
Trang 10Slide 14 of 20
Ver 1.0 Collaborate Session 8
Log shipping can be used with which all components of SQL Server?
Log shipping can be used with database mirroring, replication, and notification services.
FAQs (Contd.)
Slide 15
Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005
Which user role can configure log shipping on an instance
of a server?
The sysadmin user role can configure log shipping on an instance of a server.
FAQs (Contd.)
Trang 11Slide 16 of 20
Ver 1.0 Collaborate Session 8
Challenge
Which recovery model is used when the data is critical and data cannot be lost?
Simple recovery model Full recovery model Bulk-logged recovery model Bulk recovery model
Answer:
Full recovery model
Slide 17
Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005
Challenge (Contd.)
Which of the following operations is not fully recoverable in bulk-logged recovery model?
CREATE INDEX SELECT INTO WRITETEXT CREATE TABLE
Answer:
Trang 12Slide 18 of 20
Ver 1.0 Collaborate Session 8
Challenge (Contd.)
Which type of database backup you can perform on master database?
Differential backup Full backup Transaction log backup Tail-log backup
Answer:
Full backup
Slide 19
Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005
Challenge (Contd.)
Which DMV is used to view the authenticated SQL Server sessions?
sys.dm_exec_connections sys.dm_exec_requests sys.dm_exec_query_stats sys.dm_exec_sessions
Answer:
sys.dm_exec_sessions
Trang 13Slide 20 of 20
Ver 1.0 Collaborate Session 8
Challenge (Contd.)
The sys.dm_io_backup_tapes and sys.dm_io_pending_io_requests DMVs belong to which category of DMV?
I/O –related DMVs Database –related DMVs Replication –related DMVs Execution –related DMVs
Answer:
I/O –related DMVs
Trang 141 b Full recovery model
3 b Full backup
5 a I/O –related DMVs
Trang 151 How will you check the performance of a server due to a problem with the operating
system?
b By using System Monitor tool
c By using Database Tuning Advisor
d By using SQL Server Profiler
2 Which of the following is not the SQL Server log?
a SQL Server agent log
b SQL Server database engine log
c Transaction log
d Database mail log
3 Which utility is provided by the SQL Server to view all types of event logs?
a Log Viewer utility
b Log File Viewer utility
c SQL Server Agent utility
d Log System utility
4 Which technique in the SQL Server allows you to keep a copy of the database on a
standby server? In this case, the standby server takes over the control from the
primary server if the later is unavailable
a Database Restore
b Database Security
d Database Mirroring
5 Which instance of the database server in database mirroring holds the active
database?
a Witness Server
Trang 16b Database snapshots
c Database mirroring
d Database restore
8 Which of the following cannot be a workload?
a Trace table
b File consisting of T-SQL statements
c Trace file
d File consisting of transaction log
9 Identify the correct statement to restore a full database backup with option to
continue restoring more backups?
NORECOVERY
10 Which of the following is the correct syntax for restoring a log file?
a RESTORE < database_name> FROM <transactionlog_backup_filename>
b RESTORE LOG < database_name> FROM <transactionlog_backup_filename>
<transactionlog_backup_filename>
d RESTORE LOG <transactionlog_backup_filename> FROM < database_name> FROM
Solutions
1 By using System Monitor tool
Trang 17Monitoring the performance of a server is one of the important activities performed by an
administrator The performance of a database server is measured by the time and
resources consumed in responding to the queries posted by the users The performance of
the database server should be regularly monitored An administrator should implement
appropriate solutions to optimize the performance of the database server
Discuss the various tools provided by the SQL Server to monitor and optimize its
performance
Instructor Inputs
You can conduct the discussion as follows:
Discuss the various tools provided by the SQL Server to monitor and optimize its
performance
Discuss the System Monitor tool provided by the Windows operating system
Solution
SQL Server provides various tools such as SQL Server Profiler, Log File Viewer,
Dynamic Management Views (DMVs), and Database Tuning Advisor to monitor and
optimize performance In addition, you can also monitor the performance using the
System Monitor tool provided by the Windows operating system
Monitoring performance by using SQL Server Profiler
While monitoring performance, an administrator needs to check for the events occurring
on the server These events include the execution of T-SQL statements or a change in the
database properties
Trang 18the server at any given point of time The SQL Server provides database administrators with DMVs, which return server state information The DMVs are used as a tool to identify the activities of the SQL Server
Monitoring and optimizing performance by using Database Engine Tuning Advisor Database tuning is one of the most important tasks that a database administrator performs Database tuning involves a set of activities used to optimize the performance of a
database The goal of database tuning is to maximize the use of system resources
Monitoring performance by using System Monitor
Sometimes you can possible face degrade in the performance of the server, which could
be due to some problems with the operating system or other computer resources For example, the size of the paging file or the virtual memory has increased drastically causing the server to run slow
To monitor such problems, you can use the System Monitor tool This tool allows you to monitor the performance of the computer and its resources, such as memory or processor using counters A counter specifies the criteria for monitoring an event