0% found this document useful (0 votes)
58 views

Lab Answer Key: Module 10: Monitoring SQL Server With Alerts and Notifications Lab: Monitoring SQL Server With Alerts and Notifications

1. Prepare the lab environment by running the Setup.cmd file as administrator on the SQL Server machine. 2. Configure Database Mail in SQL Server Management Studio by setting up a new profile called "SQL Server Agent Profile" and adding a new mail account for it with details for the AdventureWorks Administrator. 3. Complete the Database Mail configuration wizard by clicking through the remaining pages.

Uploaded by

Luis Correa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Lab Answer Key: Module 10: Monitoring SQL Server With Alerts and Notifications Lab: Monitoring SQL Server With Alerts and Notifications

1. Prepare the lab environment by running the Setup.cmd file as administrator on the SQL Server machine. 2. Configure Database Mail in SQL Server Management Studio by setting up a new profile called "SQL Server Agent Profile" and adding a new mail account for it with details for the AdventureWorks Administrator. 3. Complete the Database Mail configuration wizard by clicking through the remaining pages.

Uploaded by

Luis Correa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

30/1/2019 Librería

Lab Answer Key: Module 10: Monitoring SQL Server


with Alerts and Notifications
Es
te
do
cu
Lab: Monitoring
me
nto
pe
SQL Server with Alerts and
rte
Notifications
No
es
tán
lui
sg
uil
ler
ne
ce
aL
u
pe mo is
rm co Gu
itid rre ille
as a@ rm
las gm oC
rre co ail o
Exercise 1: Configuring
pia
ss
.coDatabase
m aL
o
Mail
in pe
au ra.
tor
iza
ció
n .
Task 1: Prepare the Lab Environment

1. EEnsure
ste that the 20764C-MIA-DC and 20764C-MIA-SQL virtual machines are
do
both crunning,
um
en and then log on to 20764C-MIA-SQL as
to
pe
ADVENTUREWORKS\Student
No lui
rte
ne with the password Pa55w.rd.
es s gu ce
tán ille aL
pe rm uis
o Gu
2. In the D:\Labfiles\Lab10\Starter
rm
itid
co
rre ille folder, right-click Setup.cmd, and then click
as a @ rm
las gm oC
Run as administrator. co ail orr
pia .co ea
ss m Lo
in pe
au ra
3. In the User Account Control t oriz
ac
dialog .box, click Yes and wait for the script to
ión
finish. .

Es
te
do
cu
Task 2: Configure
me
n
Database Mail
to
pe
rte
No lui ne
es sg ce
tán u ille aL
pe uis rm
1. Start SQL rm Server
oc Management
o Gu Studio and connect to the MIA-SQL Database
itid rre ille
sl @ moa a r
Engine instanceas using
c
gm Windows
a Co authentication.
op il.c rre
aL ias om
op sin
a era
2. In Object Explorer, expand
u tor Management,
iza
. right-click Database Mail, and then
ció
click Configure Database Mail. n.

3. On the Welcome to Database Mail Configuration Wizard page, click Next.

https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 1/9
30/1/2019 Librería

4. On the Select Configuration Task page, click Set up Database Mail by


performing the following tasks:, and then click Next.

5. On the New Profile page, in the Profile name box, type SQL Server Agent
Profile, and then click Add.
Es
te
6. do Add Account to profile 'SQL Server Agent Profile' dialog box, click
In thecu
me
to n
New Account.
pe
r
No lui ten
sg ec
es ea
u
tán ille
Lu
7. In the New
p erm Database
r m oc is Mail Account dialog box, enter
Gu the following details and
itid orr ille
a e a rm
click OK: s las @
gm oC
co ail orr
pia .co ea
ss m Lo
in pe
o Account name: aAdventureWorks uto ra. Administrator
riz
ac
ión
.
o Email address: [email protected]

o Display name: Administrator (AdventureWorks)


Es
t
o e docReply
u
email: [email protected]
me
nto
pe
rte
o
No Server
lui
s
name:
ne
c
mia-sql.adventureworks.msft
es gu ea
tán Lu ille
pe is rm
rm Gu oc
8. On the New o
itid Profile rre page, ille click Next.
as a @ rm
las gm oC
co ail orr
pia .co ea
9. On the Manage Profile s sin m
SecurityLopage, select Public for the SQL Server
pe
au ra.
tor
Agent Profile profile, set izits ac Default Profile setting to Yes, and then click
ión
Next.
.

10. On the Configure System Parameters page, click Next.

11. EOn the Complete the Wizard page, click Finish, and when configuration is
ste
do
complete, click Close.
cu
me
nto
pe
rte
No lui ne
es sg ce
tán u ille aL
pe rm uis
rm oc Gu
itid orr ille
as ea rm
@
Task 3: Test Database
las
c
Mail
gm
a
oC
orr
op il.c ea
ias om L
sin op
au era
tor .
iza
1. In Object Explorer, c
right-clickónDatabase
i Mail, and then click Sent Test E-Mail.
.

2. In the Send Test E-Mail from MIA-SQL dialog box, ensure that the SQL

https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 2/9
30/1/2019 Librería

Server Agent Profile database mail profile is selected.

3. In the To box, type [email protected], and then click Send Test


Email.

4. In File Explorer, navigate to the C:\inetpub\mailroot\Drop folder, and verify that


Es
te
an demail
oc
u message has been created.
me
nto
pe
rte
5. Double-click
No lui
s the
ne message to view it in Outlook. When you have read the
c
es gu ea
tán ille Lu
message,
p erm close
r m oc it and is minimize the Drop folder window.
Gu
itid orr ille
as e a@ rm
las gm oC
6. In the DatabaseopMail c
ias
Test
a il.c E-Mail
om
orr
ea dialog box (which might be behind SQL
sin Lo
pe
Server Management Studio), au
tor click OK.
ra.
iza
ció
n.
7. In SQL Server Management Studio, on the toolbar, click New Query.

8. In the query pane, type the following Transact-SQL code, and then click
EExecute:
ste
do
cu
me
nto
pert
NSELECT lui * FROM en
oe sg ec msdb.dbo.sysmail_event_log;
stá u ea
np ille Lu
rm is
SELECT erm * FROM oc msdb.dbo.sysmail_mailitems;
Gu
itid o rre ille
as a @ rm
las gm oC
co ail orr
pia .co ea
ss m Lo
in pe
au ra.
9. Review the results. The first t oriz result shows system events for Database
ac
Mail, and

the second shows records of nemail . messages that have been sent.

10. Close the query pane without saving changes.

ste E
11. Leavedo SSMS open for the next exercise.
cu
me
nto
pe
rte
No lui ne
es sg ce
tán uaL
ille
pe uisrm
r o c Gu
Result: Aftermithis
tid exercise,
o rre ilyou
ler should have configured Database Mail with a new
as a@ mo
profile named SQL las Server gm Agent Co Profile.
co ail rre
pia .co aL
ss m op
in era
au .
tor
iza
ció
n.
Exercise 2: Configuring Operators

https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 3/9
30/1/2019 Librería

Task 1: Create the Student Operator

1. In Object Explorer, expand SQL Server Agent, right-click Operators, and then
click New Operator.
Es
2. Intethe
do New Operator dialog box, in the Name box, type Student, in the E-mail
cu
en m
name box,to type [email protected], and then click OK.
pe
rte
No lui ne
es sg ce
tán uille aL
pe rm uis
rm oc Gu
itid orr ille
as ea rm
las @ oC
gm
rre co ail o
Task 2: Create the DBA .co Operator
pia Team aL
s m o sin pe
au ra.
tor
iza
ció
n .
1. In Object Explorer, under SQL Server Agent, right-click Operators and click
New Operator.

2. EIn
stethe New Operator dialog box, in the Name box, type DBA Team, in the E-
do
cu
mail name me
nto box, type [email protected], and then click OK.
pe
rte
No lui ne
es sgu ce
tán ille aL
pe rm uis
rm o co Gu
itid rre ille
as a @ rm
las gm oC
Task 3: Configure the c a
op SQL ilServer orr Agent Mail Profile
ias . co ea
sin m Lo
pe
au ra.
tor
iza
ció
n.
1. In Object Explorer, right-click SQL Server Agent, and then click Properties.

2. In the SQL Server Agent Properties dialog box, on the Alert System page,
Eselect
ste Enable mail profile.
do
cu
me
3. In the Mail nto profile drop-down list, click SQL Server Agent Profile.
pe
rte
No lui ne
es sg ce
tán uil aL
4. SelectpEnable l erm fail-safe uis operator, in the Operator drop-down list, click DBA
erm oc Gu
itid o rre ille
Team. as
las
a@
gm
rm
oC
co ail orr
pia .co ea
ss m L
5. In the Notify using section, i n au selectopeE-mail,
ra. and then click OK.
tor
iza
ció
n.
6. In Object Explorer, right-click SQL Server Agent, and then click Restart.

7. In the User Account Control dialog box, click Yes.


https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 4/9
30/1/2019 Librería

8. In the Microsoft SQL Server Management Studio dialog box, click Yes.

9. Leave SSMS open for the next exercise.

Es
t
ed
Result: oAfter
cu this exercise, you should have created operators named Student
me
and DBA Team, nto
pe
and configured the SQL Server Agent service to use the SQL
rte
Server
No Agent lui Profile
s
ne
c
Database Mail profile.
es gu ea
tán ille Lu
pe rm is
rm oc Gu
itid orr ille
as ea rm
las @ oC
gm
orr co
Exercise 3: Configuring
pia
s
.coAlerts
m
ea and Notifications
L
ail
sin op
au era
tor .
iza
ció
n.
Task 1: Create an Alert

1. EIn
steObject Explorer, expand SQL Server Agent, right-click Alerts, and then click
d
NewocAlert.
um
en
to
pe
rte
No lui ne
2. In ethe
stá New sg Alert
uil
ce dialog box, on the General page, in the Name box, type
aL
np ler uis
mo
InternetSales
e rm
itid
cLog
orr Full Gu Alert.
ille
as e a rm
las @ oC
gm
co ail orr
3. In the Database name p ias list,
. co click
m
ea InternetSales.
Lo
sin pe
au ra.
tor
iza
4. Click Error number, and type ció the error number 9002.
n.

5. On the Response page, select Execute job, and in the drop-down list, click
Back Up Log - InternetSales ([Uncategorized (Local)]).
Es
te
oc d
6. SelectumNotify operators, and then select E-mail for the Student operator.
e nto
pe
rte
No ne lui
7. Onesthe Options
sg
u
cepage, under Include alert error text in, select E-mail, and
a
tán ille Lu
pe m r is
then click
rm OK.oco
it r
Gu
ille
ida rea rm
sl @ oC
as gm
co ail orr
pia .co ea
ss m Lo
in pe
au ra.
tor
iza
ció
. n
Task 2: Configure Job Notifications

https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 5/9
30/1/2019 Librería

1. In Object Explorer, under SQL Server Agent, expand Jobs and view the
existing jobs.

2. Right-click Back Up Database - AWDataWarehouse, and then click


Properties.
Es
te
3. do Job Properties - Back Up Database - AWDataWarehouse dialog box,
In thecu
me
to n
on the Notifications
pe
r
page, select E-mail.
No lui ten
sg ec
es uea
tán illeLu
4. In the first
p erm drop-down
r m oc is list, click Student.
Gu
itid orr ille
as e a@ rm
las gm oC
5. In the second drop-down c op
ias
a il.c list,oclick
om
rre
aL
When the job fails, and then click OK.
sin op
au era
tor .
6. Right-click Back Up Database iza
ció - HumanResources, and then click Properties.
n.

7. In the Job Properties - Back Up Database - HumanResources dialog box, on


the Notifications page, select E-mail.
Es
te
8. do first drop-down list, click Student.
In thecu
me
nto
pe
rte
9. In
No the second
lui
s
ndrop-down
ec list, click When the job fails, and then click OK.
es gu ea
tán ille
Lu
pe rm
is
rm Guoc
10. Right-clickitidBack o rrUp Database
ille - InternetSales, and then click Properties.
as e a rm
las @ oC
gm
co ail orr
pia .co ea
11. In the Job Properties s m
sin - Back UpLoDatabase - InternetSales dialog box, on the
pe
au ra.
tor
Notifications page, select iza E-mail.
ció
n.

12. In the first drop-down list, click Student.

13. EIn the second drop-down list, click When the job completes, and then click
ste
OK.docu
me
nto
pe
rte
14. Right-click
No lui
s the eBack
n
c Up Log - InternetSales job, and then click Properties.
es gu ea
tán ille
Lu
pe isrm
rm Guoc
15. o
In the JobitidProperties
rre -illeBack Up Log - InternetSales dialog box, on the
as a@ rm
las gm oC
Notifications page, co
pia select
ail
.co E-mail.
orr
ea
ss m Lo
in pe
au ra.
tor
16. In the first drop-down list, zclick i ac
ión
Student.
.

17. In the second drop-down list, click When the job completes, and then click
OK.
https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 6/9
30/1/2019 Librería

18. Expand the Operators folder, right-click Student, and then click Properties.

19. In the Student Properties dialog box, on the Notifications page, click Jobs,
verify the job notifications that have been defined for this operator, and then
click Cancel.
Es
te
do
cu SSMS open for the next exercise.
20. Leave me
nto
pe
rte
No lui ne
es sg ce
tán u ille aL
pe rm uis
rm Gu oc
itid ille orr
a ea rm should have created an alert named InternetSales
Result: After thislaexercise,
s
sc
@
gm youo C
a orr
Log Full Alert. Also,opyou il.c
ias should om have ea
Lo configured the Back Up Database -
sin pe
AWDataWarehouse, Back au Up Database
tor
ra. - HumanResources, Back Up
iza
Database - InternetSales, andciBack ón Up Log - InternetSales jobs to send
.
notifications.

Es
Exercise
te
do 4: Testing Alerts and Notifications
cu
me
nto
pe
rte
No lui ne
e sg c
Task 1:eTest
stá
n the
illeAlerta L
r u
u
pe mo is
rm co Gu
itid rre ille
as a@ rm
las gm oC
co ail orr
ea pia .co
1. On the File menu, spoint
s tom Open,Loand then click File.
p in era
au .
tor
iza
2. In the Open File dialog c
box,iónavigate to the D:\Labfiles\Lab10\Starter folder,
n.
click TestAlert.sql, and then click Open.

3. On the toolbar, click Execute and wait for the script to finish. When the log file
Es
te the InternetSales database is full, error 9002 occurs.
for do
c um
en
to
ert p
4. In
N Object
lu Explorer,
en
e
expand Alerts, right-click InternetSales Log Full Alert, and
oe isg ce
stá ille aL u
then click
np Properties.
rm uis
erm oc Gu
itid ille orr
as rm ea
oC
las @
5. In the 'InternetSales g Log Full
co m ail orr Alert' alert properties dialog box, on the
pia .co ea
ss m Lo
History page, note theauDate of last
i n pe alert and Date of
ra. last response values,
tor
iza
and then click Cancel. ció
n.

6. In File Explorer, in the C:\inetpub\mailroot\Drop folder, verify that four new


email messages have been created.
https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 7/9
30/1/2019 Librería

7. Double-click the new email messages to view them in Outlook. They should
include a notification that the transaction log was filled, and a notification that
the Back Up Log - InternetSales job completed. When you have finished
checking them, close all email messages and minimize the Drop window.
Es
te
do
cu
me
nto
pe
rte
No lui ne
sg ce
Task 2: Test
e stá Jobuil Notifications
ler aL
np m uis
erm oc Gu
itid orr ille
as ea rm
las @ oC
gm
co ail orr
1. In Object Explorer, pia under .co Jobs, ea right-click Back Up Database -
ss m Lo
in pe
au r
AWDataWarehouse, and tor click Starta.Job at Step.
iza
ció
n.
2. When the job has completed, note that it failed and click Close.

3. In Object Explorer, under Jobs, right-click Back Up Database -


Es
HumanResources,
te
do and click Start Job at Step.
cu
me
nto
pe
4. When
N
the
l
jobrte has completed, note that it succeeded and click Close.
n
oe uis ec
stá gu ea
np ille Lu
is rm
5. erm Explorer,
In Object orr under Jobs, right-click Back Up Database - InternetSales,
oc Gu
it ida il ea ler
las Job at oCs @ m
and click Start co
gm Step.
a or
pia il.c rea
ss om Lo
in pe
ra. au
6. When the job has completed,
tor
iz note that it succeeded and click Close.
ac
ión
.
7. Under the Operators folder, right-click Student, and then click Properties.

8. In the Student Properties dialog box, on the History page, note the date and
Es
time
te of the most recent notification by email, and then click Cancel.
do
cu
me
nto
pe
9. In
N
File Explorer,
l
rte
n
in the C:\inetpub\mailroot\Drop folder, verify that new email
oe uis ec
stá uihave g e
messages
np lle
rm been
aL
ui created.
erm oc sG
itid orr uil
as ler ea
l mo @
10. Open each of the
a s c messages
op
g ma Coand verify that they include a failure notification for
rre
il.c
ias om aL
the Back Up Database sin
au
- AWDataWarehouse op
era job and a completion notification
tor .
for the Back Up Database iza - InternetSales job, but no notification regarding the
ció
n.
Back Up Database - HumanResources job.

11. When you have read the messages, close them and close the Drop window.
https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 8/9
30/1/2019 Librería

12. Close SQL Server Management Studio without saving any files.

Result: After this exercise, you will have verified that the notifications you
configured
Es
te
for backups of the AWDataWarehouse, HumanResources, and
do
InternetSalescu
me databases work as expected. You will also verify that an alert is
nto
triggered whenpethe transaction log of the Internet Sales database is full.
rte
No lui ne
es sg ce
tán u ille aL
pe rm uis
rm oc Gu
itid orr ille
as ea rm
las @ oC
gm
co ail orr
pia .co ea
ss m Lo
in pe
au ra.
tor
iza
ció
n.

Es
te
do
cu
me
nto
pe
rte
No lui ne
es sg ce
tán u ille aL
pe rm uis
rm oc Gu
itid orr ille
as ea rm
las @ oC
gm
co ail orr
pia .co ea
ss m Lo
in pe
au ra.
tor
iza
ció
n.

Es
te
do
cu
me
nto
pe
rte
No lui ne
es sg ce
tán u ille aL
pe rm uis
rm oc Gu
itid orr ille
as ea rm
las @ oC
gm
co ail orr
pia .co ea
ss m Lo
in pe
au ra.
tor
iza
ció
n.

https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 9/9

You might also like