learningcomputer.com sql server 2008 – administration, maintenance and job automation
Post on 02-Jan-2016
221 Views
Preview:
TRANSCRIPT
Learningcomputer.com
SQL Server 2008 – Administration, Maintenance
and Job Automation
Agenda today – lots to cover Overview the concepts firstSQL Server AgentManagement TabDemo on Events, Alerts and JobsDatabase Mail configurationMaintenance Plan Demo
Why Automate Admin tasks?Automation frees your time to perform other
administrative functionsAs the tasks are routinely scheduled, they have no
human element which reduces errors and improves consistency
Microsoft SQL Server allows you to automate administrative tasks using SQL Server Agent which runs as a service
To automate administration, you define predictable administrative tasks and then specify the conditions under which each task occurs
The results of these tasks can be delivered to the operators
Events and AlertsEvents are when something typically an
error occurs on the SQL Server e.g. Database log fills up
Alerts would be a message sent to an Operator that an event has occurred e.g. Hey operator, database log is full
By recording specified events, SQL Server can help you troubleshoot performance, audit database activity and gather data for job related issues
More on AlertsAlerts are defined to provide event notificationAlerts have to be user defined as there are none
listed out of the boxAlert can be raised on Error number or Severity
LevelPerformance counters can also be used to define
an alertWith an alert, you execute a job and notify an
operatorCan be created using SQL Server Management
Studio (SSMS) or T-SQLDemo on Alert “AW Log is full” later
OperatorsThe Operator is the person or group
notified about the status of a jobThe methods of notification include
EmailPagerNet Send
Fail-Safe Operator is notified as a last resort
Operator can be created using SQL Server Management Studio (SSMS) or T-SQL stored procedures
JobsJobs contain one or more job steps. Each step
contains its own task, for example, backing up a database
Jobs can be created using SSMSMaintenance PlansT-SQL Jobs are owned by the creator
Jobs Types can be TSQL, Active X, CmdExec, Replication, SSIS and PowerShell
Jobs can be run manually but are often scheduled to run on their own
Bringing it all together
SQL Server AgentSQL Server Agent is a Windows service that executes
scheduled administrative tasks, which are called jobsAgent uses either local system account or domain
user account (preferred). Use configuration manager to set it up
SQL Server Agent uses SQL Server to store job information in the system msdb database
SQL Server Agent can run a job on a schedule, in response to a specific event/alert, or on demand, e.g. backup at midnight
More info can be found by RMB (Right Mouse Button)Discuss General and Alert System tabs
SQL Server Agent TabJobsAlertsOperatorsProxies
An alternative security context that can run SQL Server Agent jobs instead of SQL Server Agent service account
Error Logs (Agent Specific)Demo
Management TabIt has the following important items related
to Management Maintenance Plans – Will cover it later SQL Server Logs Database Mail – Will cover is later Legacy Demo
Demo on Log file is FullThe scenario is: AdventureWorks2008 is our
production databaseWe have created a job called “Increase AW Log”
which creates a copy of Customer table and updates data every 5 minutes. This causes the transaction file to be full
In order to fix the issue, we have created an Alert called “AW Log is full” based on Error Number 9002
When SQL Server agent notices this alert, it takes necessary action which is to run Job “Backup AW Log”
This can be monitored using Job Activity Monitor
Database Mail Database Mail is an enterprise solution for
sending e-mail messages from the SQL Server Database Engine
Using Database Mail, your database applications can send e-mail messages to users. The messages can contain query results, and can also include files from any resource on your network
Database Mail is designed for reliability, scalability, security, and supportability
Lets go ahead and configure Database Mail now
Maintenance PlansMaintenance plans create a workflow of the tasks
required to make sure that your database is optimized, is regularly backed up, and is free of inconsistencies.
The Maintenance Plan Wizard also creates core maintenance plans, but creating plans manually gives you much more flexibility
In SQL Server 2008 Database Engine, maintenance plans create an Integration Services package, which is run by a SQL Server Agent job.
These maintenance tasks can be run manually or automatically at scheduled intervals.
Maintenance Plans – ContinuedWizard is easy to use and intuitiveYou can do all of the following tasks;
Data optimizationDatabase integrity checkBackup databases and transaction logsCleanup files and history information
At the end it creates an SQL Server Integration Services (SSIS) package that can be edited using BIDS
You can execute it on demand or schedule it for later
I use it as a starting point to get the TSQL I need
top related