How to Setup SQL Server 2008/2008R2 Maintenance Plan and Email Notifications

fonte: http://nideesh.wordpress.com/2012/10/24/how-to-setup-sql-server-20082008r2-maintenance-plan-and-email-notifications/

How to Setup SQL Server 2008/2008R2 Maintenance Plan and Email Notifications

Most of the time we will have good installation and configuration for several systems but when we talk about maintenance and regular health check there should be a delay in talk and response. Database backup and maintenance should consider very important DBA should take responsibility to their assigned database. This article, we will discuss about creating Email notification and alert using out of box notification solutions designed by Microsoft in SQL 2008 /2008R2, we will go deep in maintenance plan and notification task. Backing up database in to tape or disk is not the scope of this articles however to explain SQL Database mail and Email notification ,we will back up the database in to disk and when the backup task is completed we will trigger the notification to the respective admin user for the status of the process. This will become a warning for the admin in case there is a failure in backup or any other task which we have scheduled through maintenance plan with in SQL. Then whole process and step described in this article are done through Microsoft SQL Server Management Studio, of course for email creation you have to go for the mail server.

First step is to configure Database Mail. Open Microsoft SQL Server Management Studio then right-click on Database Mail > select Configure Database Mail

clip_image001

Skip the welcome screen and select Next on the Select Configuration Task window.

clip_image003

Create new profile > fill out Profile name > Select Add under SMTP accounts:

clip_image005

Fill out New Database Mail Account info:

clip_image007

You can create New profile for SMTP Server and Email Address for different jobs and maintenance Plan here by adding more SMTP profile

clip_image009

clip_image011

Consider public and privet profile security, Default Profile and email flow according to your environment and alert requirements. Flowing are the screens for the completion and over view of your Database mail configuration which you have carried out.

clip_image013

clip_image015

clip_image017

After all went right Send test email by Right-click on Database Mail

clip_image019

Fill out test info, by typing the email address and select Send Test Email.

clip_image020

clip_image021

clip_image022

clip_image023

Check your inbox for the test mail .If you do not receive the test mail ,then make sure all the email address and SMTP setting you have configured on the SQL Database Mail configuration and Exchange server incase if your relaying your mail form SQL server.

clip_image025

Also for troubleshooting mail flow, View Database Mail log is a good place for starting.

In order to receive Email we must create at least one operator it will be under SQL Server Agent and right click Operators and click for New Operator

clip_image026

Here you can specify the Name of the Operator then in Notification options, we can set up email, Net send etc…and also the schedule, and these are self-explanatory. After fill all the necessary info and details click OK.

clip_image027

clip_image028

Now we will create a Maintenance Plan, right click on Maintenance Plans àMaintenance Plan Wizard. If you have already one just Modify that plan and add the notify operator task or success and failure.

clip_image030

clip_image032

clip_image034

Write the name and description and schedule it by click the change button.

clip_image036

I have schedule this for daily @12AM with No end date then as soon an you click OK, you will be prompted back to the Select Plan Properties; click Next. You will get help on this and any configuration part by clicking Help button if you have installed the documents and Books while installing SQL Server. This is good practice and you will get a quick reference point.

clip_image037

Here you can select the Maintenance Task for your Maintenance Plan, which is totally based on your requirements Click Next

clip_image039

Move the order if you required then select task and click Next. The few screens below are the backup settings. This is again your choice and requirement.

clip_image041.

clip_image043

clip_image045

clip_image047

Here you can select the report location folder and Email that report to the DB admin or operator you have created earlier in the post. Click Next

clip_image049

This will finish the Maintenance Plan Wizard. Click the + sign and review the settings you have made in this plan.

clip_image050

I fall wend right you will be in Green window and close the Wizard.

clip_image052

Right click on the Maintenance Plan and click Modify this will open the Maintenance Plan Design windows

clip_image054

From the toolbox on your right side drag and drop the Notify Operator Task to any Maintenance Plan you want to notify email alert whether it is success or failure.

clip_image056

Below is the screen for my Maintenance Plan notification design.

clip_image057

Here the red is connector is Failure and Green is Success. You can right click on the connector and change the status to success or failure at any time and also you can edit. Below is the screen for Task connector status.

clip_image058

Now double click on each Notify Operator task and Select the Database Mail which you have created earlier and Type subject and message body according to your need.

clip_image059

Finally, you can test your Maintenance plan and Email notification, If you want to wait for the seclude to be run then fine , otherwise by right click on the Maintenance Plan you have created and click Execute. You will be having a status window like the one shown below close it after finish.

clip_image060

clip_image062

clip_image064

If every this is configured right or not but the Database Mail configuration and Operator email is configured properly you will get notification. There will always be some adjustment and special configuration is required depends upon the environment, that you can sort out with your skill and experience. I have created distribution mail group and add as many administrator you want notify by simply add the user in that AD distribution mail group, this way you can eliminate the errors caused when you fiddle around with SQL management studio and other settings.

This article will help you a better understating for your setup and configuration. Suggestion and questions are very important for me to improve and enhance next article. I always believe in praising of my mistakes.


Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.