Lesson 2: SMS Database Disaster Recovery and Maintenance

[Previous] [Next]

The site database and software metering database are supported in SQL Server version 6.5 or version 7.0. SQL Server terminology beyond that explained in Chapter 2 and SMS-related SQL Server functions are explored in this lesson.

NOTE
See Chapter 2 for information on databases, transaction logs, and devices.


After this lesson, you will be able to

  • Back up and restore a database using SQL Server.
  • List and describe the functions of SMS tasks built into SMS 2.0.
  • Configure tasks and create scheduled SQL commands in the SMS Administrator console.
Estimated Completion Time: 40 minutes

Performing a Backup and Restore Procedure in SQL Server

SQL Server Enterprise Manager provides a facility for database and transaction log backup and restore.

Backing Up the SMS Databases

Backing up a database makes copies of its system tables, user-defined objects, and data. A backup is referred to as a dump in SQL Server version 6.5.

Databases and transaction logs are backed up onto backup devices or directly to a file. A backup device may be a disk file or a tape drive. You can back up a database to one device or to multiple devices. You can back up multiple databases or transaction logs to a common device or to separate devices.

Backup responsibility is usually assigned to either the SQL Administrator (sa) or the database owner. However, permissions to back up a database or a transaction log can be transferred by the database owner to other users. In either case, the user responsible for performing database backup should set up a regular backup schedule.

NOTE
Do not use an operating system copy command to make copies of your databases. This method will not ensure transaction integrity.

Use either SQL Server Enterprise Manager or the Transact-SQL BACKUP command to back up the database.

The SQL Server Backup dialog box is accessed from the Tools menu in SQL Server version 6.5. In SQL Server version 7.0, select the database in the SQL console tree, or from the details pane (shown in Figure 13-2), select All Tasks and then choose Backup Database.

click to view at full size

Figure 13-2. Initiating a database backup of the site database in SQL Server Enterprise Manager.

Before performing the backup, provide or change the following information:

  • The device or file you want to use for your backup
  • The database you want to back up
  • Whether SQL Server should back up the entire database (including the transaction log), the transaction log only, or a single user table
  • Whether to write over the existing data and initialize the backup device
  • Whether SQL Server should read or skip existing ANSI tape labels
  • Whether SQL Server should rewind and unload the tape when finished
  • Whether to set an expiration date for the backup
  • Whether to execute the backup immediately or schedule it for later execution

Viewing Histories of Database Backups

SQL Server Enterprise Manager maintains a record of database backups, including backups made through other applications. For backups from SQL Server version 6.5, the Restore tab of the Database Backup Restore dialog box automatically presents a list of database backups, table backups, and transaction log backups from which to choose.

In SQL Server version 7.0, select the database in the console tree, select All Tasks, and then choose Restore Database.

Restoring the SMS Databases

When restoring the database, identify the backup device that contains the backup to be restored. Look at the header information to determine the database name, device size, and date of backup.

A database may be restored using SQL Server Enterprise Manager or the Transact-SQL LOAD command. SQL Server version 7.0 also supports the Transact-SQL RESTORE command. While LOAD will work in SQL Server version 7.0, it is only present for backward compatibility. Future versions of SQL Server will not support the LOAD statement.

Figure 13-3 shows a basic restore operation in SQL Server version 7.0.

click to view at full size

Figure 13-3. Initiating a database restore of the site database in SQL Server Enterprise Manager.

See SQL Server Books Online for detailed information on both backing up and restoring databases. There are many differences between the two versions of SQL Server and many new options in SQL Server version 7.0.

Configuring SMS Database Maintenance Tasks

There are several database maintenance activities that are performed automatically by the SMS SQL Monitor process. Additional Transact-SQL commands may be added and scheduled through the SMS Administrator console. These commands are added to the database maintenance activities completed by the SMS SQL Monitor. Scheduled tasks and Transact-SQL commands are configured from the Database Maintenance node in the SMS Administrator console (Figure 13-4).

click to view at full size

Figure 13-4. The Database Maintenance node in the SMS console tree.

SMS Automated Tasks

Automated tasks are enabled and scheduled through the SMS Administrator console, as shown in Figure 13-5.

click to view at full size

Figure 13-5. Configuring automated tasks in the SMS Administrator console.

By default, all tasks are enabled except for the automatic database export and site server backup tasks.

Export Databases and Transaction Log Tasks

There are four tasks dedicated to backing up the site database, the software metering database, and their associated transaction logs (Figure 13-5). These tasks are disabled by default.

To use these tasks, you must first create a backup device, which is similar to configuring a backup routine directly in the SQL Server Enterprise Manager. Enter this device name in the `Export to' field, also shown in Figure 13-5. Specify a schedule and enable the task.

NOTE
If the `Truncate log on checkpoint' checkbox is selected in the SQL Server Enterprise Manager for the SMS databases, the transaction logs cannot be backed up. This is the default for SMS databases.

Back Up SMS Site Server

This task stops the SMS services and then backs up the site database, the software metering database (if it exists), the site server registry, and the Sms directory on the site server. The task then restarts the SMS services. Therefore, make sure that this backup routine runs when SMS services are not being heavily utilized.

Rebuild Indexes

This task is enabled by default to run once a week on Sundays. Indexes are used by SQL Server to speed up data retrieval. Over time, the data in the tables that are used to create the indexes change as new systems management data is collected. Therefore, it is important that the indexes are updated to the contents of the database tables in order to provide peak performance gains. The Rebuild Indexes task reorganizes the indexes to remove disk fragmentation and correct the index pointers. This maximizes SQL Server performance.

Monitor Keys and Recreate Views

This task is enabled by default to run once a week on Sundays. It monitors the integrity of the primary keys (those columns that uniquely distinguish one row from another in a database table) and writes a status message if a problem is discovered.

Delete Aged Items

These tasks are enabled by default. Old status messages are removed daily. Inventory data, discovery data, and collected files older than 90 days are removed once a week. For example, if a computer does not forward a discovery data record (DDR) to the site database for 90 days, then that computer will be deleted from the site database the next time this task runs. Heartbeat discovery is used to provide an updated DDR regularly enough so that computer resources that do not log on regularly are not deleted.

Update Statistics

This task is enabled by default to run every Monday, Wednesday, Friday, and Saturday. As the database is changed during normal SMS operations, internal statistics used to optimize SQL Server performance become less optimal. This task updates these statistics so that queries run faster. In SQL Server version 7.0, statistics are updated automatically.

Adding Additional SQL Commands

Tasks are only enabled and scheduled—not created—from the Tasks node. To create an automated task, use the SQL Commands node. For example, you can add the DBCC Transact-SQL commands discussed earlier in this lesson to the details pane of the SQL Commands node. The results of a SQL command can be logged to a specified file when you configure the scheduled command. If logging is not enabled, the command still runs. To verify that the command has run, view the SMS SQL Monitor from the Component Status node in the SMS Administrator console.

Exercise 60: Creating SMS SQL Commands

In this exercise, you will configure SMS to automatically run a stored procedure on a schedule. This stored procedure will determine how much drive space is available in the SMS site database.

NOTE
Complete this exercise from the primary site server with only the SMS Administrator console running.

  1. Start this exercise by enabling logging of SMS_SQL_MONITOR using the SMS Service Manager.

NOTE
The steps for enabling logging using SMS Service Manager was explained in Chapter 11, Exercise 51, "Installing SMS 2.0 on Computer 2."

  1. In the SMS console tree, expand the Site Settings node, and then expand the Database Maintenance node.
  2. The SMS console tree displays the SQL Commands and Tasks nodes.

  3. Select the SQL Commands node.
  4. From the Action menu, select New, and then choose SQL Command.
  5. The SQL Command Properties dialog box displays `General' settings for the new SQL command.

  6. Complete the SQL Command Properties dialog box using the following information:
  7. In this field/checkbox You supply
    Name SMS site database space
    `Enable SQL command' Selected
    SQL command sp_spaceused
    Log status to \\SERVER1\SMS_S01\LOGS\DBSPACE.LOG

  8. Under Schedule, set the Start after time to the current time, and the Latest start time to 5 minutes after the configured Start after time.
  9. Select the current day of the week, and then click OK.
  10. The SMS Administrator console appears with the new SQL command in the details pane.

In the following steps, you will use SMS status messages to verify that the SQL command was executed.

  1. In the SMS console tree, expand the System Status and then expand the Site Status node, S01 - Central Site. Then select the Component Status node.
  2. The list of SMS components appears in the details pane.

  3. View all status messages for SMS_SQL_MONITOR.
  4. The SMS Status Message Viewer for <S01> <Central Site> window appears. Notice the messages with IDs of 2408. These messages report the processing of SQL commands and tasks. There should be one message for the sp_spaceused command.

NOTE
The status message may not appear yet, because it may take a few minutes for the SQL command to execute. You may refresh the list of status messages to determine when the command has completed.

  1. View the details of the message for the sp_spaceused command.
  2. Notice the SQL command listed as being run was SMS site database space.

  3. Close the SMS Status Message Viewer for <S01> <Central Site> window.

In the following steps, you will use SMS log files to verify that the SQL command ran successfully.

  1. Start SMS Trace.
  2. The SMS Tracer application appears.

  3. Open d:\SMS\LOGS\SMSDBMON.LOG.
  4. The SMS Tracer application displays the contents of the SMS SQL Monitor's log file.

  5. Search for executing with a time close to the current time.
  6. Notice the executing SQL command for SMS site database space. Also notice a status message was written with an ID of 2408.

  7. Close SMS Tracer.
  8. Use Notepad to open D:\SMS\LOGS\DBSPACE.LOG.
  9. Notepad displays the contents of the log file created by the SQL command. Because this log file was not created by the SMS services as an SMS log file, the formatting is not the same as the standard SMS logs, and SMS Trace will not display the data properly.

    Notice the sp_spaceused command, as well as the results of the command, is referenced. The results are presented in the following format, where x represents the site code and numeric values for your site.

Exercise 61: Configuring SMS Database Maintenance Tasks

In this exercise, you will configure the SMS database maintenance tasks to automatically back up the SMS site and software metering databases. You will begin by creating backup devices to store the backed up data.

  1. From the Start menu, select Programs. Choose Microsoft SQL Server 7.0 and then Enterprise Manager.
  2. The SQL Server Enterprise Manager MMC appears showing the Microsoft SQL Servers node.

  3. Expand the Microsoft SQL Servers node.
  4. The SQL Server Group node appears in the SQL console tree and SERVER1 appears in the details pane.

NOTE
If SERVER1 does not appear in the details pane, you must first register the SQL Server from the Action menu.

  1. In the SQL console tree, select SERVER1 (Windows NT).
  2. The Getting Started Taskpad appears in the details pane.

  3. Expand the Management node and select the Backup object.
  4. From the Action menu, select New Backup Device.
  5. The Backup Device Properties _ New Device dialog box appears. Notice that the default path is D:\MSSQl7\BACKUP\.

  6. In the `Name' field, type SMSDBDump and then click OK.
  7. The SQL Server Enterprise Manager MMC appears.

    Create another backup device with the name SWMDBDump.

  8. Close the SQL Server Enterprise Manager MMC.
  9. View the contents of d:\MSSQl7\BACKUP.
  10. Notice that no files are displayed. Even though the backup devices were created in SQL Server Enterprise Manager, they are not created on the server's hard disk until they are going to be used.

In the following steps, you will configure SMS to automatically back up the SMS site database and the software metering database files.

  1. Switch to the SMS Administrator console.
  2. In the SMS console tree, find and then expand the Site Settings node.
  3. Select and then expand the Database Maintenance node.
  4. The SMS console tree displays the SQL Commands and Tasks objects.

  5. In the SMS console tree, select Tasks.
  6. The details pane displays the available database maintenance tasks.

  7. In the details pane, select Export Site Database. Then from the Action menu, choose Properties.
  8. The Export Site Database Task Properties dialog box displays `General' settings for the database task.

  9. Select Enable this task.
  10. In the `Export to' box, type SMSDBDump.
  11. Under Schedule, set the Start after time to the current time, and the Latest start time to five minutes after the configured Start after time.
  12. Select the current day of the week, and then click OK.
  13. The SMS Administrator console appears. Notice in the details pane that the Export Site Database task is now enabled.

  14. Repeat this procedure to enable backing up of the software metering database (Export Software Metering Database) using the backup device (SWMDBDump) created in the preceding steps.
  15. View the contents of D:\MSSQl7\BACKUP.
  16. When the automated tasks start, the databases will be backed up, and the files will appear in the directory.

    Notice the backup devices were created on the server's hard disk as the databases were backed up. The file size indicates the actual number of used pages in the database.

In the following steps, you will use SMS status messages to verify that the SMS database maintenance tasks were run.

  1. In the SMS console tree, find and then expand the Component Status node for S01 - Central Site.
  2. The list of SMS components appears in the details pane.

  3. View the status messages for SMS_SQL_MONITOR.
  4. The SMS Status Message Viewer for <S01> <Central Site> window appears. Notice the messages with IDs of 2408. These messages relate to the processing of the SQL database maintenance task for backing up the databases.

  5. View the details for one of the two recent messages with an ID of 2408.
  6. Notice the SQL command listed as being run was an export of the SMS site database or the software metering database.

  7. Close the SMS Status Message Viewer for <S01> <Central Site> window.

In the following steps, you will use SMS log files to verify that the SMS database maintenance tasks ran successfully.

  1. Start SMS Trace.
  2. The SMS Tracer application appears.

  3. Open D:\SMS\LOGS\SMSDBMON.LOG.
  4. The SMS Tracer application displays the contents of the SMS SQL Monitor's log file.

  5. Search for executing around the current time.
  6. The first occurrence of executing appears. This may be for the sp_spaceused command run earlier in the previous exercise.

  7. Continue searching for executing until you reach the current time.
  8. Notice the log entry for the executing of the backup of the SMS database indicating that the backup of SMS_S01 completed successfully.

    Following these entries more entries related to the backup of the software metering database will be listed.

  9. Close SMS Tracer.


Microsoft Systems Management Server 2.0 Training Kit
Microsoft Systems Management Server 2.0 Training Kit
ISBN: 1572318341
EAN: 2147483647
Year: 1999
Pages: 107
Authors: Microsoft Press, Microsoft Corporation
BUY ON AMAZON

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net