Presentation on theme: "SQL Server Agent Keith Binford. SQL Server Agent SQL Server Agent is a Windows service that can execute and schedule tasks and jobs."— Presentation transcript:
SQL Server Agent Keith Binford
SQL Server Agent SQL Server Agent is a Windows service that can execute and schedule tasks and jobs.
SQL Server Agent Configuration Manager
Configuring SQL Server Agent Properties Executing jobs based on resource availability Idle CPU Condition When to restart SQL Server Agent Auto restart SQL Server (Recommended) Auto restart SQL Server Agent (Recommended) How much information to persist in the error log Include Execution Trace Messages(check disk space) Alerts and notifications
Configuring SQL Server Agent Properties
SQL Server Agent Job Schedule Operator Alert Proxy
Configuring Jobs A job is a specified series of operations performed sequentially by SQL Server Agent. A job can perform a wide range of activities, including running Transact-SQL scripts, command-line applications, Microsoft ActiveX scripts, Integration Services packages, Analysis Services commands and queries, or Replication tasks. Jobs can run repetitive tasks or those that can be scheduled, and they can automatically notify users of job status by generating alerts, thereby greatly simplifying SQL Server administration. *
SQL Server Agent SQL Server Integration Services (SSIS) packages T-SQL scripts PowerShell scripts ActiveX scripts Replication tasks Analysis Services tasks Operating system task (CmdExec)
USE msdb ; GO EXEC = N'Weekly Sales Data Backup' ; GO EXEC = N'Weekly Sales Data = N'Set database to read = = N'ALTER DATABASE SALES SET = = 5 ; GO EXEC = = = ; USE msdb ; GO EXEC = N'Weekly Sales Data = N'RunOnce'; GO EXEC = N'Weekly Sales Data Backup'; GO
Creating Operators An Operator is the person to be notified when a certain action or event occurs on SQL Server or SQL Server Agent.
Only members of the sysadmin fixed server role can create operators. SQLAgentUserRole SQLAgentReaderRole SQLAgentOperatorRole Note that SQL Server Agent must be configured to use Database Mail to send and pager notifications to operators. The Pager and net send options will be removed from SQL Server Agent in a future version of Microsoft SQL Server. Avoid using these features in new development work, and plan to modify applications that currently use these features.
Creating Operators -- sets up the operator information for user 'danwi.' The operator is enabled. -- SQL Server Agent sends notifications by pager from Monday through Friday from 8 A.M. to 5 P.M. USE msdb ; GO EXEC = N'Dan = = = = = 62 ; GO
Creating Alerts Alerts are automated notifications that are fired when certain events are triggered. SQL Server event SQL Server performance conditions Windows Management Instrumentation(WMI) event Windows Management Instrumentation (WMI) is the infrastructure for management data and operations on Windows-based operating systems. You can write WMI scripts or applications to automate administrative tasks on remote computers but WMI also supplies management data to other parts of the operating system and products, for example System Center Operations Manager, formerly Microsoft Operations Manager (MOM), or Windows Remote Management (WinRM).WinRM
USE msdb EXEC = 'Test = = = 'Error has occurred. The database will be backed = 'Back up the Customer Database'
Creating Alerts -- adds an notification for the specified alert (Test Alert) -- This example assumes that Test Alert already exists and that François Ajenstat is a valid operator name. USE msdb ; GO EXEC = N'Test = N'François = 1 ; GO
Creating Proxies A SQL Server Agent proxy defines the security context for a job step. A proxy provides SQL Server Agent with access to the security credentials for a Microsoft Windows user. Each proxy can be associated with one or more subsystems. A job step that uses the proxy can access the specified subsystems by using the security context of the Windows user. Before SQL Server Agent runs a job step that uses a proxy, SQL Server Agent impersonates the credentials defined in the proxy, and then runs the job step by using that security context.
Creating Credentials Credentials provide a way to allow SQL Server Authentication users to have an identity outside of SQL Server. Credentials can also be used when a SQL Server Authentication user needs access to a domain resource, such as a file location to store a backup A credential can be mapped to several SQL Server logins at the same time. A SQL Server login can only be mapped to one credential at a time.