• No results found

SQL Server Automated Administration

N/A
N/A
Protected

Academic year: 2021

Share "SQL Server Automated Administration"

Copied!
32
0
0

Loading.... (view fulltext now)

Full text

(1)

To automate administration:

•Establish the administrative responsibilities or server events that occur regularly and can be administered programmatically.

•Define a set of jobs and alerts.

•Run the SQL Server Agent service.

(2)

SQL Server Automated

Administration

(3)

SQL Server Agent Service

SQL Server Agent supports features allowing the scheduling of periodic activities on Microsoft SQL Server, or the notification to system administrators of problems that have occurred with the server.

The SQL Server Agent components that implement this capability are:

•Jobs

Defined objects consisting of a one or more steps to be

(4)

•Alerts

Actions to be taken when specific events occur, such as a specific error, errors of certain severities, or a

database reaching a defined limit of free space available. The alert can be defined to take such actions as sending an e-mail, paging an operator, or running a job to address the problem.

•Operators

People identified through their network account or e-mail ID who can address problems with the

(5)
(6)

Job Name

Every job must have a name.

Job names must be unique only if they originate from the same server.

A job name can be no more than 128 characters.

Job Category

(7)

Job Owner

The job owner is the individual who creates a job or for whom the job is created.

By default, SQL Server Agent populates the owner information with the SQL Server login ID of the job creator.

(8)

Job Description

A job can be run by other users on both the local and remote computers running SQL Server.

By writing a description at the time a job is created, the job owner can ensure that other users will understand quickly the purpose of the job.

(9)

Implementing Jobs

• Administrative tasks can be automated using SQL Server Agent jobs.

• A job can be defined one time but can be run many times.

(10)

•Jobs can be written to run on the local server or on multiple servers.

•To run jobs on multiple servers, you must set up at least one master server and one or more target servers.

(11)
(12)

•Are errors and messages, or events that are generated

by SQL Server and entered into the Microsoft Windows NT application log.

•SQL Server Agent reads the application log and

compares events to alerts that you have defined.

(13)

Setting up a SQL Server database alert

1. On the View menu, click Alert.

2. On the Edit menu, click Add to Alert....

3. In the Object list, click a SQL Server object, and then click a counter, on which the alert will be based, from the Counter box.

4. Under Alert If, click Over or Under, and then enter a

threshold value. The alert will be generated when the value for the counter is over or under the threshold value

(depending on whether Over or Under was selected).

(14)
(15)

•Allows SQL Server to send and receive e-mail by establishing a client connection with a mail server.

•SQL Server 7.0 uses two services to handle mail.

? SQL Mail.

? SQL Server Agent Mail.

•MS SQL Server processes mail for all of the mail stored procedures.

(16)

•SQL Mail establishes a simple MAPI connection with a

mail host.

•SQL Agent Mail establishes either a simple or extended

MAPI connection.

•Both SQL Mail and SQL Agent Mail can connect with

MS Exchange Server, Windows NT Mail, or a POP3

server.

•SQL Mail stored procedures can manipulate data,

process queries received by e-mail and return the result

set by creating a reply e-mail.

•SQL Agent Mail can be configured to send an e-mail

(17)

MAPI (Messaging Application Program Interface) is a Microsoft Windows program interface that enables

1. You to send e-mail from within a Windows application and attach the document you are working on to the e-mail note.

2. MAPI-compatible applications typically include a Send

Mail or Send in the File pulldown menu of the application.

This sends a request to a MAPI server.

3. MAPI consists of a standard set of C language

(18)

Developers who are using Microsoft's Active Server Page (ASP) technology access the MAPI library by using Microsoft's Collaboration Data Objects (CDO).

(19)

SQL Server and Mail Integration

Microsoft SQL Server provides a set of extended stored

procedures that allow SQL Server to operate as a workgroup post office for a MAPI-enabled e-mail system.

The computer running SQL Server must be set up as an e-mail client. SQL Server Enterprise Manager is used to assign an e- mail account and password to the SQL Server installation.

The mail component of SQL Server can then be enabled to be started automatically when the SQL Server Agent

service is started.

Alternatively, the mail component can be started and

stopped at will using either SQL Server Enterprise Manager, or the xp_startmail, xp_stopmail, and xp_sendmail

(20)
(21)

?When the mail component of SQL

Server is running, it can be used to:

Send e-mail from Transact-SQL batches, scripts,

stored procedures, and triggers using xp_send_mail. The e-mail can be:

Message strings.

The result set of a query.

A Transact-SQL statement or batch to execute.

(22)

E-mail can be read using:

?sp_processmail

?A combination of xp_findnextmessage ?xp_readmail,

(23)

The messages sent to SQL Server typically contain a Transact-SQL statement or batch to be executed.

The statement is executed and the result set is returned as a reply e-mail with an optional CC: list.

SQL Server events and alerts can be combined with SQL Mail functionality to build a system in which a server

running SQL Server can e-mail or page the relevant

(24)

Configuring a SQL Mail Profile

When configured, mail profiles are specific to the Microsoft

Windows NT user domain account that is activated when a user ogs on to Windows NT successfully. SQL Mail must have a mail profile created in the same user domain account or context that is used to start SQL Server. When a mail stored procedure is

executed, SQL Mail looks for the defined mail profile in the domain account that triggered it.

If you plan to use mail stored procedures you must: •Have a mail server that is simple MAPI-compliant.

(25)

How to configure a mail profile (Windows NT)

To configure a mail profile

1. Logon to the Microsoft Windows NT server specifying the name and password used to start SQL Server services for that server.

(26)

3. On the server running Microsoft SQL Server, start the mail client using the newly created mail profile. 4. Send a message addressed to the same profile name

to ensure the mail client, mail profile, and e-mail provider are working properly. If your e-mail message does not appear, you may need to force mail synchronization by going to the Tools menu, and then clicking Deliver Now.

(27)

To set up SQL Mail

How to set up SQL Mail (Enterprise Manager)

1. Expand a server group; then expand a server.

2. Click Support Services, right-click SQL Mail, and then click Properties.

3. In Profile name, select the mail profile that you configured for SQL Mail.

(28)

Configuring a SQL Agent Mail Profile

If you plan to send notifications to operators by e-mail or pager, you must:

•Have a mail server that is simple or extended MAPI-compliant.

•Configure a mail profile for SQL Server Agent to use to connect to your mail server.

(29)

How to set the mail profile for SQL Server Agent (Enterprise Manager)

To set the mail profile for SQL Server Agent

1. Right-click SQL Server Agent; then click Properties.

2. In the SQL Server Agent Properties dialog box, on the

General tab, under Mail session, click a profile in the Mail profile box. If no profiles are listed, enter the name of the

(30)

How to set up SQLAgentMail (Enterprise Manager)

1. Expand a server group; then expand a server.

2. Expand Management, right-click SQL Server Agent, and then click Properties.

3. If you have configured a mail profile using a different domain account than the one used to Microsoft® SQL Server™, click

This Account, and then enter the Windows NT account name

and password used to create the mail profile for SQLAgentMail.

4. In Mail profile, select the mail profile you created for SQLAgentMail.

(31)

Sharing a Profile with SQL Mail

SQL Mail and SQLAgentMail sessions may be configured to use the same Windows NT domain user account. When using the same

domain account, SQL Mail and SQLAgentMail can share the same mail profile using a common mailbox.

Microsoft® SQL Server™ uses two separate mail sessions:

•The MSSQLServer service uses a mail session that is referred to as SQL Mail.

•SQL Server uses this mail session when your database applications execute the xp_sendmail extended stored procedure to send a

message or query result set to a recipient.

(32)

References

Related documents

SQL Server 2012 Data Mirroring 634 Windows Failover Clustering 635 SQL Server 2012 Replication 635. Removing Log

Open SQL Server Management Studio (Start > All Programs > Microsoft SQL Server 2005 or 2008 > SQL Server Management Studio) and log on to the SQL Server instance that

Saving and restoring files where Systems Insight Manager is installed using Microsoft SQL Server 2005 Express, Microsoft SQL Server 2005, or Microsoft SQL server

(You also need to install the client software for the RDBMS on each computer needing network access to the database server. If you are running Microsoft SQL Server or SQL Server

• To send email, the client sends the message to an outgoing mail server, which in turn contacts the destination mail server for delivery. – For this reason, it is necessary

Select the correct server: DOMAIN\SQLEXPRESS, enter the access data (this is generally "Windows-Auth."), choose the relevant file when selecting the database and

When a user send an email, the email client will deliver the mail to the local SMTP server running on the Mail/File server. The SMTP server will then determine if the mail is

a On the computer or server where SQL Server is installed, open the SQL Server Configuration Manager by selecting Start > All Programs > Microsoft SQL Server 2008 R2 (or