In this lesson, you will learn about: Creating and Managing SQL Server 2000 Agent alerts Creating operators Creating and Managing SQL Server 2000 Agent jobs Troubleshooting SQL Server 20
Trang 1In this section, you will learn about:
•Creating and managing SQL Server 2000 Agent alerts
•Creating operators
•Creating and managing SQL Server 2000 Agent jobs
•Troubleshooting SQL Server 2000 Agent jobs
Trang 2In this lesson, you will learn about:
Creating and Managing SQL Server 2000 Agent alerts
Creating operators
Creating and Managing SQL Server 2000 Agent jobs
Troubleshooting SQL Server 2000 Agent jobs
Trang 3Managing SQL Server 2000 Agent
Jobs Lesson 2B / Slide 2 of 31
2 Which of the following variables refers to the type of backup device that you want to use?
a) Database_name b) Database_backup_filename c) Transactionlog_backup_filename d) Device_type
Trang 4Managing SQL Server 2000 Agent
Jobs Lesson 2B / Slide 3 of 31
©NIIT
Managing SQL Server 2000 Agent Jobs
Pre-Assessment Questions
3 Which of the following keywords does the SQL Server 2000 Enterprise
Manager use to identify a corrupted database?
a) SUSPECT b) VERIFYONLY c) WITH DIFFERENTIAL d) FILEGROUP
4 Which of the following reasons refers to unpredictable situations?
a) Hardware Failures b) Natural Disasters c) Intentional Data Loss d) Accidental Data Loss
Trang 5Managing SQL Server 2000 Agent
Jobs Lesson 2B / Slide 4 of 31
©NIIT
Managing SQL Server 2000 Agent Jobs
Pre-Assessment Questions
5 Which of the following backup methods of SQL Server is used to speed
up the backup operation?
a) Full Backup b) Filegroup Backup c) Transaction Log Backup d) Parallel Striped Backup
Trang 6Managing SQL Server 2000 Agent
Jobs Lesson 2B / Slide 5 of 31
©NIIT
Managing SQL Server 2000 Agent Jobs
Solutions to Pre-assessment Questions:
Ans 1 c Differential Filegroup Backup
Ans 2 d Device_type
Ans 3 a SUSPECT
Ans 4 b Natural Disasters
Ans 5 d Parallel Striped Backup
Trang 7Customers.mdb
Sales.mdb
Trang 8I NTRODUCING SQL S ERVER A GENT
S ERVICE
Managing SQL Server 2000 Agent
Jobs Lesson 2B / Slide 6 of 31
©NIIT
Managing SQL Server 2000 Agent Jobs
Introduction to SQLServerAgent
Service
• SQL Server 2000 provides SQLServerAgent service to administer
programmatically certain administrative tasks or server events that
Trang 9Managing SQL Server 2000 Agent
Jobs Lesson 2B / Slide 7 of 31
Trang 10Managing SQL Server 2000 Agent
Jobs Lesson 2B / Slide 8 of 31
• Operators receives the notification from SQL Server Agent using
one of three messaging methods: E-mail, Pager, Net Send.
Trang 11Managing SQL Server 2000 Agent
Jobs Lesson 2B / Slide 9 of 31
• Using jobs, you can define schedules for the execution of task
• In addition, using jobs you can define the administrative task that can be monitored for success or failure each time it executes
• The defined tasks can be executed on one local server or multiple remote servers.
SQL Server 2000 provides the SQLServerAgent service to programmatically administer certain administrative tasks or server events that occur regularly The
SQLServerAgent service uses three components to accomplish this task They are:
Trang 12An operator is a user, who receives the messages when an alert is fired Operators receive the notification from SQL Server Agent using one of three messaging
methods:
E-mail: SQLServerAgent service sends notifications to operators using e-mail
This is possible only if SQLAgentMail has been previously configured The SQLServerAgent service should be using the domain user account that must have a MAPI messaging profile on the computer on which SQLServerAgent is running You can also use group e-mail to send notifications to multiple
operators However, you need to test the e-mail configuration before sending the notifications to the operators
Pager: SQLServerAgent service sends notifications to operators using a pager
This notification is implemented using e-mail and a third-party paging software Since pager notifications require an e-mail, SQLAgentMail must be configured In addition, you need to prepare a work schedule for each operator who needs to
be notified by pager If the job requiring notifications for an operator conflicts with the work schedule, then the notification fails
Net Send: This utility is provided by the Windows NT and 2000 operating
systems and is used to send messages across the network NET SEND utility requires the Windows Messenger service to be running on the receiving and the transmitting computers
You can define a new operator using SQL Server Enterprise Manager or by executing
sp_add_operator system stored procedure The definition of operator is stored in the msdb.sysopeartors system table
Jobs
A job is a series of steps that are performed sequentially by SQLServerAgent Using jobs, you can define schedules for the execution of task In addition, using jobs you can define the administrative task that can be monitored for success or failure each time it executes The defined tasks can be executed on one local server or multiple remote servers
Trang 13I NSTRUCTOR N OTES
Next, you need to discuss about SQL Server 2000 alerts in detail Also tell the students about the attributes of SQL Server alerts and messages Now, tell the students about creating alerts using the Create Alert wizard of SQL Server 2000 Enterprise Manager To explain the process of creating alerts, present the students with a business problem that requires creating alerts using the Create Alert wizard Discuss the solution of the problem in detail You can divide the solution in to logically related tasks for better understanding of the process Now, you can ask the students
to perform the process of creating alerts using the SQL Server 2000 Enterprise Manager as a practice exercise Finally, discuss the steps to review the details of the existing alerts and alert history using SQL Server 2000 Enterprise Manager You can end the session by telling the students about troubleshooting SQL Server agents, jobs, and alerts
Trang 14C REATING AND M ANAGING SQL
S ERVER 2000 A GENT A LERTS
You can use the components of SQL Server 2000 Agent services such as alerts to provide notification for various events You can create alerts using the Create Alert Wizard of the SQL Server 2000 Enterprise Manager
Introducing Alerts
Managing SQL Server 2000 Agent
Jobs Lesson 2B / Slide 10 of 31
• The different types of system alerts are stored in the sysmessages table
of the master system database of SQL Server 2000.
• You can define your own alerts using SQL Server 2000 Enterprise Manager and store them in the sysmessages table.
Trang 15Managing SQL Server 2000 Agent
Jobs Lesson 2B / Slide 11 of 31
©NIIT
Managing SQL Server 2000 Agent Jobs
Introducing Alert (Contd.)
• The following are the main attributes of the SQL Server alerts and their messages:
with the previously defined alerts in the msdb.sysalerts system table If a match is
found during the comparison process, an event alert is fired The SQL Server Agent
processes these alert and checks the msdb.sysnotifications system table to send
notification, such as e-mail, pager, or net send In addition, SQL Server Agent checks
the msdb.sysoperators system table to identify the operator for sending notification
SQL Server Agent also monitors SQL Server performance objects and counters If the value of the performance object and their associated counters is lower than, equal to,
or more than the specified value of the object and their counters, the SQL Server
Trang 16Error number: Each error has a unique number
Message string: It contains information about the cause of the error, place
where the error has occurred, and the object concerned with this error
Severity: It is a numeric value Low numeric value of severity indicates
information messages whereas high numeric values indicate serious errors
State code: It is used to find the source code location of the error and is used by
Microsoft support engineers
Procedure name: It contains the name of the stored procedure if the error has
occurred in a stored procedure
Line number: It indicates the line number of the Transact-SQL statement in the
stored procedure, which has caused the error
You need to be a member of the sysadmin server role, to define
alerts
Trang 17C REATING A LERTS
Managing SQL Server 2000 Agent
Jobs Lesson 2B / Slide 12 of 31
©NIIT
Managing SQL Server 2000 Agent Jobs
Creating Alerts Using Create Alert
Problem Statement
The System Administrator, James of Mac Aluminum, Inc wants to generate an alert for the backup operations of all databases James wants to fire an alert when an insufficient resource occurs during backup operation Finally, James wants to assign the name of the generated alert as ‘Database Backup’
Trang 18Solution
Managing SQL Server 2000 Agent
Jobs Lesson 2B / Slide 13 of 31
©NIIT
Managing SQL Server 2000 Agent Jobs
Task List
• Open the New Alert Properties dialog box.
• Define the severity level.
• Specify the database in which error must occur.
• Verify that the alert has been created.
To solve the preceding problem, perform the following tasks:
1 Open the New Alert Properties dialog box
2 Define the severity level
3 Specify the database in which error must occur
4 Verify that the alert has been created
Trang 191: Open the New Alert Properties dialog box
Action:
1 Click StartÆAll ProgramsÆMicrosoft SQL ServerÆEnterprise Manager,
to open the Enterprise Manager console of SQL Server 2000
2 Expand Console RootÆMicrosoft SQL ServersÆSQL Server Group Select
the default instance
3 Expand the default instance Select and expand the Management option, to reach the SQL Server Agent.
4 Expand SQL Server Agent Right-click Alerts and select New Alert from the
pop-up menu to open the New Alert Properties dialog box
Ensure that the SQL Server Agent Service is running
5 In the Name text box, enter Backup Database, as shown
Trang 202: Define the severity level
Action:
1 Under Event alert definition section, select 017-Insufficient Resources
option from the Severity drop-down list, as shown
3: Specify the database in which error must occur
Since James wants to fire an alert for all the databases, hence all the databases need
to be selected from the Database name drop-down list
Action:
1 Verify that All Databases is selected in the Database name drop-down list
Trang 214: Verify that the alert has been created
Result:
You can view the details of all the existing alerts using the SQL Server 2000 Enterprise
Manager It is essential that you must be a member of the sysadmin server role to
view the details of the existing alerts The following are the steps to view the details, properties, and history of the existing alerts using SQL Server 2000 Enterprise Manager:
1 From SQL Server 2000 Enterprise Manager, expand the Microsoft SQL
ServerÆ SQL Server GroupÆ SQL Server default instanceÆ
Management option
2 From the Management option, expand the SQL Server Agent option
3 Select the Alerts option The details pane displays all the existing alerts
4 In the details pane, click the Name column to sort the displayed alerts
5 The Enabled column displays the status of the displayed alerts
6 The details of the alerts, such as Severity, Error, Last Occurred, Email,
Pager, Net Send, and Count are also displayed, as shown
Trang 22To view the properties of an alert, right-click the specified alert and select the
Now, you can explain creating operators and fail-safe operators using SQL Server
2000 Enterprise Manager To explain the process of creating operators and fail-safe operators, present the students with a business problem that requires creating an operator and a fail-safe operator Discuss the solution of the problem To help the students to effectively understand the process, divide the solution in to logically related tasks and then explain each task in detail
Additional Inputs
Using Transact-SQL to Create Operators
You can create operators using the sp_add_operator system stored procedure of Transact-SQL The following is the syntax of the sp_add_operator system stored
procedure:
sp_add_operator [@name = ] ‘name’ [, [@email_address = ] ‘email_address’ [, [@pager_address = ] ‘pager_address’
In the above syntax:
The @name keyword takes the value specified with the name variable
The name variable refers to the name of the operator to be created
The @email_address keyword takes the value specified with the email_address variable
The email_address variable refers to the e-mail address of the newly created operator
Trang 23The pager_address variable refers to the pager address of the newly created operator
You can use the sp_update_operator system stored procedure to update the
existing operators
Trang 24C REATING O PERATORS
Managing SQL Server 2000 Agent
Jobs Lesson 2B / Slide 14 of 31
an SQL Server 2000 Operator To designate James as an Operator, the System Administrator wants to configure the operator options in SQL Server 2000 The System Administrator wants the notification of result
of backup operations should be done through e-mail, and NET SEND utility of Windows operating system The e-mail, and NET SEND addresses of James are ‘james@macaluminium.com’ and ‘James’
respectively In case of failure on notifying the message to the Operator, the System Administrator wants to notify the results of backup operations to another operator Scott who is designated as a fail- safe operator by SQL Server 2000
Problem Statement
The System Administrator of Mac Aluminum, Inc wants to monitor backup operations and their results for all the databases The System Administrator wants to assign this task to James and designate him as an SQL Server 2000 Operator To designate James as an Operator, the System Administrator wants to configure the operator options in SQL Server 2000 The System Administrator wants the notification of result
of backup operations should be done through e-mail, and NET SEND utility of Windows operating system The e-mail, and NET SEND addresses of James are
‘james@macaluminium.com’ and ‘James’ respectively In case of failure on notifying the message to the Operator, the System Administrator wants to notify the results of
Trang 25Solution
Managing SQL Server 2000 Agent
Jobs Lesson 2B / Slide 15 of 31
©NIIT
Managing SQL Server 2000 Agent Jobs
Task List
• Configure operator details.
• Configure notification details.
• Configure fail-safe operator details.
• Verify the operator configuration.
To solve the preceding problem, perform the following tasks:
1 Configure operator details
2 Configure notification details
3 Configure Fail-safe operator details
4 Verify the operator configuration
Trang 261: Configure operator details
You can define a new operator using SQL Server Enterprise Manager or by executing
sp_add_operator system stored procedure The definition of operator is stored in the msdb.sysoperators system table
Action:
1 Select StartÆAll ProgramsÆMicrosoft SQL ServerÆEnterprise Manager,
to open the Enterprise Manager console
2 In the Console Root, expand Microsoft SQL ServersÆSQL Server
GroupÆDefault instanceÆManagementÆSQL Server Agent container
3 Right-click the Operators container and then click the New Operator option,
to open the New Operator Properties dialog box
4 Type James in the Name text box
5 Type James@macaluminium.com in the E-mail name text box
6 Type James in the Net send address text box
Trang 272: Configure notification details
In the Notifications screen, you can select one or more alerts that will be notified to the operators You can also specify new task by selecting Job option
Action:
1 Click the Notifications tab
Trang 282 Verify that the Alerts option is selected in the Notifications screen Select Backup Database as the Alert Name and select E-mail, and Net Send as
the notification media, as shown
3 Click the OK button to close the New Operator Properties dialog box
3: Configure Fail-safe operator details
A fail-safe operator is an operator who receives the message, when SQL Server Agent services fails to deliver the message to the defined operator
1 Right-click the SQL Server Agent and select the Properties option to open
the SQL Server Agent Properties dialog box
Trang 292 Click the Alert System tab In the Fail-safe operator section, select New
Fail-Safe Operator from the Operator drop-down list, as shown
3 The New Operator Properties dialog box appears In the Name text box,
enter Scott.
4 In the E-mail name text box, enter Scott@macaluminium.com In the Net send address text box, enter Scott, as shown
Trang 306 Verify that the Notify using option as E-mail is selected In addition, select
the Net send option, as shown
7 Click the OK button to close the SQL Server Agent Properties dialog box
4: Verify the operator configuration
Action:
Click the Operators in the console tree Notice that James and Scott operators appear
in details pane
Trang 31I NSTRUCTOR N OTES
Next, tell the students about jobs in SQL Server 2000 Tell the students that jobs are
a set of steps performed sequentially by SQL Server Agent services Explain job steps and tell the tell the students that the following job steps are supported by SQL Server 2000:
Operating system commands or CMDExec commands
Trang 32C REATING AND M ANAGING SQL
S ERVER 2000 A GENT J OBS
Managing SQL Server 2000 Agent
Jobs Lesson 2B / Slide 16 of 31
©NIIT
Managing SQL Server 2000 Agent Jobs
Creating and Managing SQL Server
2000 Agent Jobs
• Jobs can be defined as a set of tasks performed sequentially by SQL
Server 2000 Agent services
• The action performed by jobs on database or server is known as job
steps SQL Server 2000 supports job steps that can be:
• Operating system commands or CMDExec commands
• Transact-SQL statements
• Microsoft ActiveX scripts
• Replication tasks
• Job Step Process:
• You can configure a job step to perform multiple jobs sequentially
on success or failure of a job process
• A job process can also be configured to quit or report its success or
failure For example, you can program a job step to continue with the subsequent steps or quit the job and report its success or failure.
Trang 33Managing SQL Server 2000 Agent
Jobs Lesson 2B / Slide 17 of 31
©NIIT
Managing SQL Server 2000 Agent Jobs
Creating and Managing SQL Server
2000 Agent Jobs (Contd.)
Export Database
Update Database
Backup Database Success Report
Failure Report
On Success
On Failure