Thursday, September 17, 2015

How licensing works with AlwaysOn Availability groups

I would like to share some knowledge on how licensing works with AlwaysOn Availability groups.
It took 1 week to figure it out, Having calls with Microsoft and help from forums


Min Requirements for having AlwaysOn Availability groups.:

  • Two Windows Servers 2012 R2 Standard Edition
  • Ensure that each computer is a Node in a Windows Server Fail over Clustering (WSFC)
  • All two Windows Servers should reside on one Cluster and One Domain
  • Each SQL Server Instance involved in AlwaysOn Availability Groups must be running Enterprise Edition of SQL Server 2012 or later (2014)
  • Must use same network links for communications between WSFC members and availability Replicas
  • All Databases should be in Full recovery model, only User databases can participate in AlwaysOn Availability Groups 
  • Recommended to keep all configurations/Settings/Drives identical between two nodes


Advantages of using AlwaysOn Availability Groups:
  • AlwaysOn Availability Groups build on Top of Windows Server Fail over Clustering (WSFC)
  • Automatics Failover(Synchronous mode), No witness server needed for automatic failover, uses Windows Server Failover Clustering to do Automatic Failover
  • Can have multiple copies of secondary, but here at FrontPoint we are not going to use secondary
  • Backups and DBCC Check DB operations cane be done on secondary( but need to pay for License)
  • Applications connect to Virtual Server Name any given time, and we do not need to change any in connection strings even after Failover happens 
  • Secondary Replica can be same or different location 
  • More than one secondary and cane be readable and run synchronous mode 
  • Multiple database failover -AlwaysOn Availability Groups ensures all databases are connected when failover happen to secondary Replica
  • No shared Storage is required in AlwaysOn Availability Groups 
AlwaysOn Availability Groups Support Fail over In any of the following  Events
  • Operating System goes down
  • SQL Server Instance, Database goes offline/Shutdown
  • Disk Failures(hardware failures) in which databases cannot be accessed 
  • Network goes down or someone unplug Network cables
  • Manual failover whenever needed in emergency situations
  • Upgrade/Patch Failed/Restarting SQL services 

Manage Jobs and Replication:
  • Jobs should be created on both primary and secondary Replicas with some logic.
  • Jobs run on both servers all times, but which ever is primary actually execute the job and secondary will not pass validation Skip the job to execute the actual code
  • Replication Jobs will be Created on Both server and have to create publications on both servers and configure Distribution database to use remote distributor
IF ( SELECT ars.role_desc
 FROM   sys.dm_hadr_availability_replica_states ars
           INNER JOIN sys.availability_groups ag ON ars.group_id = ag.group_id
         WHERE  ag.name = 'YourAvailabilityGroupName'
         AND ars.is_local = 1
   ) = 'PRIMARY‘
BEGIN
---this server is the primary replica, Put all Job code here 
 END;
ELSE
BEGIN
PRINT 'no';    -- this server is not the primary replica, (optional) do something here
    END;


Finally, How licensing works with AlwaysOn Availability groups ?

 
I am going to explain how it works when we have like below environment

SQL Server 2014 Always ON Availability Groups between 2 nodes(servers) and using SQL server Enterprise edition on top of WSFC, Node1 is primary replica(read/Write)  and Node2 is secondary replica(NON READABLE)  and databases are Restoring mode only and will not use or read/write  data until disaster (failover)happens.

As per documentation , SQL server  Services, Agent  services should run on both servers at anytime but only Primary Replica's  jobs executes at anytime using Some checks like i provided above t SQL script, so we should have JOBS running at both servers, we will have to put a logic inside the jobs , if this is primary execute else come out of the job..--this code or logic make sure the jobs run on PRIMARY REPLICA (now, or after failover)

so we need only 1 SQL SERVER ENTERPRISE Licence to setup ENVIRONMENT like above.....

Note:

1.You probably shouldn't take my word for it, since I don't work for Microsoft, but I'm pretty sure that isn't a problem, You need to have the server ready to take over for any failure. Having your jobs already configured and scheduled is an important part of that.

2.Passive fail-over rights permit a customer to run passive instances of SQL Server in a separate operating system environment (OSE) without requiring the passive server to be licensed for SQL Server. A passive SQL Server instance is one that is not serving SQL Server data to clients or running active SQL Server workloads.e over for any failure. Having your jobs already configured and scheduled is an important part of that.


Some Useful Information:
For each server licensed with SQL Server 2014 and covered by active SA, customers can run up to the same number of passive failover instances in a separate, on-premises OSE to support failover events.
A passive SQL Server instance is one that is not serving SQL Server data to clients or running active SQL Server workloads. The passive failover instances can run on a separate server. These may only be used to synchronize with the primary server and otherwise maintain the passive database instance in a warm standby state in order to minimize downtime due to hardware or software failure.

The secondary server used for failover support does not need to be separately licensed for SQL Server as long as it is truly passive, and the primary SQL Server is covered with active SA. If it is serving data, such as reports to clients running active SQL Server workloads, or performing any “work”, such as additional backups being made from secondary servers, then it must be licensed for SQL Server. 

http://download.microsoft.com/download/B/4/E/B4E604D9-9D38-4BBA-A927-56E4C872E41C/SQL_Server_2014_Licensing_Guide.pdf

So long as the agent jobs only actually perform "work" on the primary, and the other conditions are met, it would be passive. 



Thanks
Naresh DBA



















1 comment:

  1. Hi Naresh,

    I would like to know how the SQL Server AlwaysOn licensing work for the below scenario.

    Scenario 1:

    I set up two node cluster and created a two SQL Instances with one AG each.
    Node A and Node B ( Each node has 1 Physical CPU – 4 cores )
    SQL 1 and SQL 2 ( Instances )
    If I run SQL 1 on Node A and SQL 2 on Node B. Do I need to pay the license for both the servers/2 CPUs?

    ------------------------------------

    Scenario 2:

    Set up two node cluster and created one SQL instance with two availability groups.
    Node A and Node B ( Each node has 1 Physical CPU – 4 cores )
    SQL 1 with AG1 and AG2
    Now if I run AG1 on Node A and AG2 on Node B. Do I need to pay the license both the nodes/2 CPUs?

    Thanks.

    ReplyDelete

https://blog.sqlauthority.com/2009/06/27/sql-server-fix-error-17892-logon-failed-for-login-due-to-trigger-execution-changed-database-context...