Microsoft Press microsoft sql server 2005 PHẦN 7 docx

99 314 0
Microsoft Press microsoft sql server 2005 PHẦN 7 docx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

508 Chapter 14 Working with SQL Server Agent Jobs NOTE Can’t execute multiple tasks on same schedule Remember that when creating a maintenance plan, you are in essence creating an SSIS package, so you are defining the flow control definition within the SSIS package. However, you will not be executing multiple maintenance tasks on the same schedule, so this step in the wizard is superfluous. Depending on the maintenance task you select, the options that you can specify at this point in the wizard vary. If you select a maintenance plan for a database backup, you’ll see the option to select the databases to apply the task to, as shown in Figure 14-12. Figure 14-12 Specifying databases to back up After you select the check box for the databases you want to back up, click OK. You can then specify the folder in which you want to store the backups, along with whether you want to verify the backup integrity, as Figure 14-13 shows. Click Next. When you have specified all the appropriate task options, you can define a schedule, as shown in Figure 14-14. To access scheduling options, click Change. C1462271X.fm Page 508 Friday, April 29, 2005 7:57 PM Lesson 2: Creating a Maintenance Plan 509 Figure 14-13 Specifying backup options Figure 14-14 Defining one schedule for the entire maintenance plan C1462271X.fm Page 509 Friday, April 29, 2005 7:57 PM 510 Chapter 14 Working with SQL Server Agent Jobs The scheduling options available are the same as when you are scheduling a SQL Server Agent job (see Figure 14-15). The difference is that for a regular SQL Server Agent job, you can define multiple schedules for a regular job and reuse previ- ously created job schedules, but you can define only one schedule for a maintenance plan. Figure 14-15 Specifying scheduling options Click OK to close the New Job Schedule dialog box. After defining the schedule, you see a summary of the scheduling options displayed within the Maintenance Plan Wiz- ard, as Figure 14-16 shows. Click Next. For reporting purposes, you can configure each maintenance plan to write an out- put file or to e-mail the report about the actions it performs, as shown in Figure 14-17. You will usually specify writing to an output file that you can scan for errors. Click Next. C1462271X.fm Page 510 Friday, April 29, 2005 7:57 PM Lesson 2: Creating a Maintenance Plan 511 Figure 14-16 Single schedule definition for the maintenance plan Figure 14-17 Specifying reporting options At this point, you have completed the creation of a maintenance plan, and the wizard asks you to verify your choices, as Figure 14-18 shows. When you click Finish, the wiz- ard performs the following steps: 1. Generates an SSIS package. 2. Stores that SSIS package within the msdb database. C1462271X.fm Page 511 Friday, April 29, 2005 7:57 PM 512 Chapter 14 Working with SQL Server Agent Jobs 3. Creates a job in SQL Server Agent to execute the maintenance plan. 4. Creates entries in the sys.dbmaintplan* tables within the msdb database. Figure 14-18 Finishing maintenance plan creation Quick Check 1. What operations can a maintenance plan perform? 2. How many schedules can you apply to a maintenance plan? Quick Check Answers 1. A maintenance plan can back up databases, delete old backup files from the operating system, maintain indexes, execute another job, and shrink a database. 2. You can apply only one schedule to a maintenance plan. PRACTICE Create a Maintenance Job In this exercise, you will practice the creation of a maintenance plan to back up the AdventureWorks database. Instead of using the Maintenance Plan Wizard to create the maintenance plan, you will define it from a generic maintenance plan. 1. In SSMS, right-click the Maintenance Plans node in Object Explorer and choose New Maintenance Plan. C1462271X.fm Page 512 Friday, April 29, 2005 7:57 PM Lesson 2: Creating a Maintenance Plan 513 2. Specify a name for the maintenance plan and click OK. 3. Click the browser button (…) to the right of the Schedule text box. 4. Configure the maintenance plan to run once per day at 23:00, or 11:00 PM. When you’re done, click OK to close the Job Schedule Properties dialog box. 5. Click Connections to open the Manage Connections dialog box. Click Add and specify the server connection options. Click OK to save your changes and then click OK again to close the Manage Connections dialog box. 6. Click Logging and configure the logging options you want to use for this plan. 7. In the Maintenance Plan Tasks toolbox, drag and drop the Back Up Database Task onto the surface of the maintenance plan. 8. Double-click the Back Up Database Task and specify the AdventureWorks data- base to perform a full backup. Click OK to close the Back Up Database Task dialog box. 9. Drag and drop a Maintenance Cleanup Task onto the surface of the maintenance plan. 10. Select the Back Up Database Task. 11. Drag the green arrow from the Back Up Database Task to the Maintenance Cleanup Task, which creates a dependency between the two tasks so that the backup task runs first and the cleanup task runs second. 12. Double-click the Maintenance Cleanup Task and specify saving the backups for one day. When you’re done, click OK to close the Maintenance Cleanup Task dialog box. 13. Click Save on the toolbar to save your maintenance plan. Lesson Summary ■ A maintenance plan enables you to graphically configure SQL Server to perform one or more predefined maintenance tasks on a scheduled basis against one or more databases. ■ The most common type of maintenance plan that you will create is to back up a database on a regular basis. ■ Each maintenance plan is a monolithic SSIS package that can have only one schedule defined for it. C1462271X.fm Page 513 Friday, April 29, 2005 7:57 PM 514 Chapter 14 Working with SQL Server Agent Jobs Lesson Review The following questions are intended to reinforce key information presented in this lesson. The questions are also available on the companion CD if you prefer to review them in electronic form. NOTE Answers Answers to these questions and explanations of why each answer choice is right or wrong are located in the “Answers” section at the end of the book. 1. What types of tasks can you define with the Maintenance Plan Wizard? (Choose all that apply.) A. Database creation B. Database backup C. Index rebuilding D. SSIS package execution C1462271X.fm Page 514 Friday, April 29, 2005 7:57 PM Lesson 3: Configuring Operators 515 Lesson 3: Configuring Operators The SQL Server Agent subsystem enables you to define operators to receive notifica- tions about jobs. You can use this mechanism to enable SQL Server Agent to send a notice when a job has failed, for example, alerting DBAs so that they can quickly eval- uate and repair problems. After this lesson, you will be able to: ■ Configure operators. Estimated lesson time: 10 minutes How to Configure an Operator You configure an operator by naming it and specifying various notification methods for the operator and other parameters, such as an e-mail address to send the notifica- tion to. To begin the configuration, in SSMS, right-click the Operators node below SQL Server Agent, and choose New Operator to define properties for an operator, as Figure 14-19 shows. Figure 14-19 Defining operator parameters C1462271X.fm Page 515 Friday, April 29, 2005 7:57 PM 516 Chapter 14 Working with SQL Server Agent Jobs Each operator needs a name. You then specify which notification methods—e-mail, net send, and pager—are valid for that operator. NOTE Enable the Messenger Service In order to use a net send, the Messenger Service must be enabled. You specify addresses or numbers for each valid notification method. In addition, you can configure an operator to receive notifications only during specific on-duty hours. NOTE Specifying a work week Unfortunately, the graphical user interface (GUI) assumes that the work week is Monday through Friday for everyone in the world. Selecting the Notifications page displays all jobs and alerts for which a particular oper- ator is configured to receive notifications. Click OK to create the operator. Quick Check ■ Which notification methods are valid for an operator? Quick Check Answer ■ You can notify an operator using net send, e-mail, or text messaging. Managing and Troubleshooting Jobs You can manage SQL Server Agent jobs within SSMS. To access the list of jobs that are configured on an instance, expand the SQL Server Agent node within SSMS, right-click the Job Activity Monitor item, and choose View Job Activity. The Job Activity Monitor displays a list of the jobs for the instance, along with the date and time the job was last run and the next date and time the job will run. The Job Activity Monitor also displays whether the job is enabled and whether the last run was successful. You can enable, disable, start, and stop a job by right- clicking it within the job activity grid. The shortcut menu also enables you to access the detailed history for a particular job, including any error messages that might have occurred during job execution. C1462271X.fm Page 516 Friday, April 29, 2005 7:57 PM Lesson 3: Configuring Operators 517 PRACTICE Configuring Operators In this practice, you will configure an operator to receive e-mail notifications. 1. Expand the SQL Server Agent node. 2. Right-click Operators and choose New Operator. 3. Specify a name for the operator. 4. Specify an e-mail address for the operator. 5. Click OK. NOTE Sending e-mail To send e-mail to this operator, you must enable and configure Database Mail. Because text mes- saging also relies on the mail subsystem, it also requires you to configure Database Mail. For infor- mation about configuring Database Mail, see Lesson 2, “Configuring Database Mail,” in Chapter 2, “Configuring SQL Server 2005.” Lesson Summary ■ SQL Server Agent enables you to define operators to receive notifications from jobs via e-mail, net send, or pager. ■ Operators provide a convenient way to refer to one or more messaging addresses by a single name. ■ To send e-mail or text messages, you need to have SQL Server Database Mail con- figured and enabled. Lesson Review The following questions are intended to reinforce key information presented in this lesson. The questions are also available on the companion CD if you prefer to review them in electronic form. NOTE Answers Answers to these questions and explanations of why each answer choice is right or wrong are located in the “Answers” section at the end of the book. C1462271X.fm Page 517 Friday, April 29, 2005 7:57 PM [...]... chapter, see SQL Server 2005 Books Online SQL Server 2005 Books Online is installed as part of SQL Server 2005 Updates for SQL Server 2005 Books Online are available for download at www .microsoft. com/technet/prodtechnol /sql/ 2005/ downloads/books.mspx MORE INFO Top performance Web sites You can also obtain a wealth of performance information from the following valuable Web resources: ■ Microsoft SQL Server. .. C1462 271 X.fm Page 520 Friday, April 29, 2005 7: 57 PM 520 Chapter 14 Working with SQL Server Agent Jobs Figure 14-20 Specifying alert parameters for a SQL Server performance condition Figure 14-21 Specifying alert parameters for a SQL Server event Figure 14-22 shows the final type of alert you can create: a WMI event For this type of alert, you specify a predefined notification query for SQL Server. .. options available, see the “How to Use the Practice Tests” section in this book’s Introduction C1462 271 X.fm Page 528 Friday, April 29, 2005 7: 57 PM C1562 271 X.fm Page 529 Friday, April 29, 2005 7: 59 PM Chapter 15 Monitoring and Troubleshooting SQL Server Performance Monitoring and troubleshooting Microsoft SQL Server is a broad topic that spans a variety of tools and processes All database administrators...C1462 271 X.fm Page 518 Friday, April 29, 2005 7: 57 PM 518 Chapter 14 Working with SQL Server Agent Jobs 1 Which notification methods are available for an operator? (Choose all that apply.) A cell phone B pager C e-mail D instant messaging C1462 271 X.fm Page 519 Friday, April 29, 2005 7: 57 PM Lesson 4: Configuring Alerts 519 Lesson 4: Configuring Alerts The alert subsystem within SQL Server Agent... the Organize Columns dialog box C1562 271 X.fm Page 5 37 Friday, April 29, 2005 7: 59 PM Lesson 1: Working with SQL Server Profiler 5 37 Figure 15-4 Change the order of columns as they are displayed in Profiler MORE INFO Events and Data Columns For a complete list of events and data columns available for capture, see the SQL Server 2005 Books Online articles SQL Server Event Class Reference” and “Describing... data you need C1562 271 X.fm Page 539 Friday, April 29, 2005 7: 59 PM Lesson 1: Working with SQL Server Profiler 539 Quick Check ■ What capabilities does SQL Server Profiler provide DBAs and developers? Quick Check Answer ■ SQL Server Profiler provides a GUI interface to the SQL Trace API SQL Trace lets DBAs and developers gather data on a variety of events as they occur within the server They can then... http://blogs.msdn.com/sqlcat/ ■ Gert Draper’s SQLDEV.Net Web site at www.sqldev.net, which contains useful utilities and background information Both these Web sites should be in your Favorites list 529 C1562 271 X.fm Page 530 Friday, April 29, 2005 7: 59 PM 530 Chapter 15 Monitoring and Troubleshooting SQL Server Performance Exam objectives in this chapter: ■ Gather performance and optimization data by using the SQL Server. .. that customers could complete orders on the company’s Web site instead of taking their business to the competitors C1562 271 X.fm Page 532 Friday, April 29, 2005 7: 59 PM 532 Chapter 15 Monitoring and Troubleshooting SQL Server Performance Lesson 1: Working with SQL Server Profiler SQL Server Profiler is a powerful but rarely used tool for analyzing database performance issues By using Profiler to capture... the most common way to work with the SQL Trace API is through the SQL Server Profiler graphical user interface (GUI) Let’s look at how to define a trace within Profiler You launch SQL Server Profiler from the SQL Server 2005 Performance Tools menu After it opens, choose File, New Trace A connection dialog box appears Connect to the SQL Server instance in which the sample AdventureWorks database is installed... some scenarios, you can configure SQL Server to respond by executing a job that contains a set of steps designed to address the particular alert event If the response to an alert is to notify an operator, you can specify additional options for the notification, as Figure 14-23 shows C1462 271 X.fm Page 522 Friday, April 29, 2005 7: 57 PM 522 Chapter 14 Working with SQL Server Agent Jobs Figure 14-23 Specifying . plan C1462 271 X.fm Page 509 Friday, April 29, 2005 7: 57 PM 510 Chapter 14 Working with SQL Server Agent Jobs The scheduling options available are the same as when you are scheduling a SQL Server Agent. package within the msdb database. C1462 271 X.fm Page 511 Friday, April 29, 2005 7: 57 PM 512 Chapter 14 Working with SQL Server Agent Jobs 3. Creates a job in SQL Server Agent to execute the maintenance. the error text. C1462 271 X.fm Page 519 Friday, April 29, 2005 7: 57 PM 520 Chapter 14 Working with SQL Server Agent Jobs Figure 14-20 Specifying alert parameters for a SQL Server performance condition Figure

Ngày đăng: 07/08/2014, 02:22

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan