Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Job Management in an
AlwaysOn World
How 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.li...
Agenda
• Types of Jobs
• Job Failover Options
Job Types
• Active X
• Command Line
• PowerShell
OS
• Command Jobs
• Query JobsAnalysis Services
• Packages
• Maintenance ...
So What Are My Options
• Add a job step
• Add a job server
• Move logic out of SQL Agent
• Use Alerts to enable/disable jo...
Adding a Job Step
• Add top level job step.
• Use logic to detect primary
• Continue Processing
• Exit Gracefully
• Possib...
Add Job Server
• Build a separate SQL Server
• Configure Job Server for Multi-Server
Administration
• Point Jobs at target...
Moving Logic
• Move primary detection logic out of the
SQL Agent Job
 Works well with T-SQL Statements and
OS job types
...
Using Alerts
• Setup Alert on 1480 (AlwaysOn Role
Change)
• Setup Job to enable/disable other jobs
• Use the response of t...
To Recap…
• No one right way to manage jobs
• Document, Document, Document
References
• Michael Campbell’s Blog Series
 http://sqlmag.com/blog/alwayson-availability-groups-and-sql-server-jobs-part...
Questions?
AlwaysOn Availability Group Job Management
AlwaysOn Availability Group Job Management
AlwaysOn Availability Group Job Management
AlwaysOn Availability Group Job Management
Upcoming SlideShare
Loading in …5
×

AlwaysOn Availability Group Job Management

562 views

Published on

So you’ve built out your AlwaysOn Availability Group, tested it and it is ready for production. Great! Now, how do you handle all those database dependent SQL Agent jobs? As with many things regarding SQL Server there are many ways to handle the failover of these jobs and in this session we will discuss a few ways to handle automatic failover of SQL Server Agent jobs and the pros and cons of each.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

AlwaysOn Availability Group Job Management

  1. 1. Job Management in an AlwaysOn World How to handle jobs that need to run on the primary replica.
  2. 2. About Me… • Database Administrator at Boulder County • Twitter: @_KenWilson • Blog: SQLBama.com • LinkedIn: https://www.linkedin.com/in/sqlbama Ken Wilson
  3. 3. Agenda • Types of Jobs • Job Failover Options
  4. 4. Job Types • Active X • Command Line • PowerShell OS • Command Jobs • Query JobsAnalysis Services • Packages • Maintenance Plans Integration Services • Replication • T-SQL StatementsSQL Server
  5. 5. 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
  6. 6. 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
  7. 7. 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
  8. 8. 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
  9. 9. 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
  10. 10. To Recap… • No one right way to manage jobs • Document, Document, Document
  11. 11. References • Michael Campbell’s Blog Series  http://sqlmag.com/blog/alwayson-availability-groups-and-sql-server-jobs-part-1- introduction • SQL Agent Job Types  https://msdn.microsoft.com/en-US/librAry/ms187056.aspx • Minion Backup  http://minionware.net/backup/ • Ola Halengren  https://ola.hallengren.com/
  12. 12. Questions?

×