alwayson availability group job management

Post on 15-Aug-2015

184 Views

Category:

Technology

4 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Job Management in an AlwaysOn WorldHow to handle jobs that need to run on the primary replica.

About Me…• Database Administrator at Boulder County

• Twitter: @_KenWilson

• Blog: SQLBama.com

• LinkedIn: https://www.linkedin.com/in/sqlbama

Ken Wilson

Agenda• Types of Jobs

• Job Failover Options

Job Types• Active X• Command Line• PowerShell

OS

• Command Jobs• Query JobsAnalysis Services

• Packages• Maintenance Plans

Integration Services

• Replication• T-SQL StatementsSQL Server

So What Are My Options• Add a job step

• Add a job server

• Move logic out of SQL Agent

• Use Alerts to enable/disable jobs

Adding a Job Step• Add top level job step.

• Use logic to detect primary

• Continue Processing

• Exit Gracefully

• Possible Issues Detection could be tricky

In 2012 you need to come up with the logic yourself

In 2014 and newer you can use the system function sys.fn_hadr_is_primary_replica

Misleading Error Log

• Active X• Command Line• PowerShell

OS

• Command Jobs• Query Jobs

Analysis Services

• Packages• Maintenance Plans

Integration Services

• Replication• T-SQL StatementsSQL Server

Add Job Server• Build a separate SQL Server

• Configure Job Server for Multi-Server Administration

• Point Jobs at target servers

• Possible Issues Initial Setup Cost

• Active X• Command Line• PowerShell

OS

• Command Jobs• Query Jobs

Analysis Services

• Packages• Maintenance Plans

Integration Services

• Replication• T-SQL StatementsSQL Server

Moving Logic• Move primary detection logic out of the

SQL Agent Job Works well with T-SQL Statements and

OS job types Examples: Ola Hallengren’s Maintenance

Solution and MidnightDBA’s Minion Backup Solution

• Possible Issues Need access to code Replication job types may be difficult to

setup.

• Active X• Command Line• PowerShell

OS

• Command Jobs• Query Jobs

Analysis Services

• Packages• Maintenance Plans

Integration Services

• Replication• T-SQL StatementsSQL Server

Using Alerts• Setup Alert on 1480 (AlwaysOn Role

Change)

• Setup Job to enable/disable other jobs

• Use the response of the alert to execute the disable/enable job.

• Possible Issues Initial Setup a little more involved False positives are possible

• Active X• Command Line• PowerShell

OS

• Command Jobs• Query Jobs

Analysis Services

• Packages• Maintenance Plans

Integration Services

• Replication• T-SQL StatementsSQL Server

To Recap…• No one right way to manage jobs

• Document, Document, Document

Questions?

top related