<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>HADR - Techyaz.com</title>
	<atom:link href="https://techyaz.com/tag/hadr/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Tips, Tutorials and How-to Topics</description>
	<lastBuildDate>Tue, 15 May 2018 15:29:57 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>

<image>
	<url>https://techyaz.com/wp-content/uploads/2017/11/cropped-Site-icon-150x150.png</url>
	<title>HADR - Techyaz.com</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Understanding Backup Preferences for AlwaysOn Availability Group Databases</title>
		<link>https://techyaz.com/sql-server/alwayson/understanding-sql-server-backup-databases-availability-group/</link>
					<comments>https://techyaz.com/sql-server/alwayson/understanding-sql-server-backup-databases-availability-group/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Thu, 21 Sep 2017 06:53:07 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[Backup & Recovery]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[AOAG]]></category>
		<category><![CDATA[availability group]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[HADR]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[T-SQL]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=943</guid>

					<description><![CDATA[<p>We know SQL Server Backups are resource intensive operation that strain on I/O and CPU (with backup compression). AlwaysOn Availability Group has very good capability to offload SQL Server backups and read operations from primary replica to reduce such workloads&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/understanding-sql-server-backup-databases-availability-group/">Understanding Backup Preferences for AlwaysOn Availability Group Databases</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>We know <a href="https://techyaz.com/sql-server/understanding-sql-server-backups/" target="_blank" rel="noopener">SQL Server Backups</a> are resource intensive operation that strain on I/O and CPU (with backup compression). <a href="https://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">AlwaysOn Availability Group</a> has very good capability to offload SQL Server backups and read operations from primary replica to reduce such workloads and utilize secondary replicas in a better way. Read this article to understand backup preferences for AOAG databases.</p>
<p>Before going ahead, we need to understand the rules/points that are very important in order to decide the backup preferences in AOAG configuration. Below are the important points you should consider during designing backup strategy of availability databases.</p>
<ul>
<li>Regular <strong>Full Backups</strong> are not allowed from secondary replicas. Only <a href="https://techyaz.com/sql-server/understanding-sql-server-backups/" target="_blank" rel="noopener">COPY_ONLY full backups</a> are allowed on secondary replicas. That means you cannot run regular Full backup from any of the secondary replica. Remember that copy-only backups do not impact the log chain or clear the differential bitmap.</li>
<li><strong>Differential backups</strong> are not supported on secondary replicas. If you must run differential backups for your availability databases, you should not choose backup preferences as secondary replicas.</li>
<li>Only regular <strong>Log backups</strong> are supported on secondary replicas. COPY_ONLY log backups are not supported on secondary replicas.</li>
<li>Secondary replica must be in <strong>SYNCHRONIZED </strong>or <strong>SYNCHRONIZING </strong>state to backup a secondary database.</li>
<li>Log backup chain is supported across all replicas regardless of where the log backup is taken (primary or secondary replicas) or the mode of the replication (asynchronous or synchronous).</li>
<li>In a distributed availability group, backups can be performed on secondary replicas in the same availability group as the active primary replica, or on the primary replica of any secondary availability groups.</li>
</ul>
<h5><span style="color: #000080;">How SQL Server Decides Which Replica will execute Backup &#8211; Backup Preferences ?</span></h5>
<p>It’s little complex process to determine where backup jobs should run.  If you are confused about this question, then keep reading to get the answer.</p>
<p>To decide on which replica, you should run your backup job depends on your <strong>Backup Preferences</strong> setting. To address this, configure the availability group to specify which availability replicas where you would prefer backups to be performed.</p>
<p>If you choose backup preferences as <strong>secondary only</strong> then you can create jobs on only secondary replicas or if you choose to run it on <strong>primary replica</strong>, then you can configure it on primary replica only. But if you decided to go with default option that is <strong>preferred secondary</strong> then you should schedule backup jobs on all replicas.  Although, Microsoft suggests to create scripted backup-jobs for every availability database on every server instance that hosts an availability replica that is a candidate for performing backups.</p>
<p>Suppose you have chosen <strong>secondary only</strong> preference and you have 3 secondary replicas then question might arise how database engine will decide that on which replica backup should run. Database engine decides where should run backup based on <strong>preferred backup replica</strong> settings and <strong>backup priority</strong> settings. I have explained about these settings later in this article.</p>
<p>AOAG (AlwaysOn Availability group) has a function named <strong>sys.fn_hadr_backup_is_preferred_replica</strong>  to determine which replica is set as preferred backup replica.  If the out of this function returns 1 it means current instance is the preferred backup replica and backup will run on this instance. If returns 0, it means backup will not run on that replica.  We can use this function in a backup script to determine job should run on which replica, so only one of the scheduled jobs actually proceeds to the backup stage.</p>
<p>In the event of a failover, none of the scripts or jobs needs to be modified. Also, if you reconfigure an availability group to add an availability replica, managing the backup job requires simply copying or scheduling the backup job. If you remove an availability replica, simply delete the backup job from the server instance that hosted that replica. Microsoft has given a sample code logic for this function that can be used to develop backup script.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span style="color: #0000ff;">If sys.fn_hadr_backup_is_preferred_replica( @dbname ) &lt;&gt; 1
BEGIN</span>
<span style="color: #008000;">-- If this is not the preferred replica, exit (probably without error).</span>
<span style="color: #0000ff;">END</span>
<span style="color: #008000;">-- If this is the preferred replica, continue to do the backup.
</span></strong></pre>
<p>If you use the Maintenance Plan Wizard to create a given backup job, the job will automatically include the scripting logic that calls and checks the <strong>sys.fn_hadr_backup_is_preferred_replica</strong> function.</p>
<p>If you want to check the preferred backup replica for any availability database, you can get it by running below command. If the output of this function returns 1 it means current instance is the preferred backup replica and backup will run on this instance. If returns 0, it means backup will not run on that replica.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span style="color: #008000;">--Get the backup preference replica for availability database TechYaz.</span>
<span style="color: #0000ff;">SELECT sys.fn_hadr_backup_is_preferred_replica ('TechYaz');
GO
</span></strong></pre>
<p>I have executed same function on my secondary replica. You can see the output is showing as 1, it means this replica is set to run backups.</p>
<p><img fetchpriority="high" decoding="async" class="aligncenter size-full wp-image-944" src="http://techyaz.com/wp-content/uploads/2017/09/1-backup-replica.jpg" alt="Get preferred backup replica" width="461" height="172" srcset="https://techyaz.com/wp-content/uploads/2017/09/1-backup-replica.jpg 461w, https://techyaz.com/wp-content/uploads/2017/09/1-backup-replica-300x112.jpg 300w" sizes="(max-width: 461px) 100vw, 461px" /></p>
<h5><span style="color: #000080;">Configure Backup of Availability Databases to Run only from Secondary Replicas using GUI</span></h5>
<ol>
<li>Connect to the server instance that hosts the primary replica, and click the server name to expand the server tree. You would not be able to change Backup Preferences from any secondary replicas. If you open the AOAG name property, you will find all options greyed out.</li>
<li>Expand the <strong>Alwayson High Availability </strong>node and the <strong>Availability Groups</strong></li>
<li>Click the availability group whose backup preferences you want to configure, and select the <strong>Properties.</strong></li>
<li>In the <strong>Availability Group Properties </strong>dialog box, select <strong>Backup Preferences</strong> You can see backup preference is set to <strong>Prefer Secondary</strong>, now we need to change it to <strong>Secondary only </strong>option<strong>.</strong> The details about each type of backup preference is given in the screenshot and AOAG backup preference property window.</li>
</ol>
<p><img decoding="async" class="aligncenter size-full wp-image-946" src="http://techyaz.com/wp-content/uploads/2017/09/3-AOAG-property-from-Primary.jpg" alt="AOAG Property Window" width="705" height="637" srcset="https://techyaz.com/wp-content/uploads/2017/09/3-AOAG-property-from-Primary.jpg 705w, https://techyaz.com/wp-content/uploads/2017/09/3-AOAG-property-from-Primary-300x271.jpg 300w" sizes="(max-width: 705px) 100vw, 705px" /></p>
<ol start="5">
<li>There are 4 backup preferences in AOAG that are given below with their capabilities. Choose any as per your requirements. Now I will add one more replica to this availability group as per our requirement and set backup preference to secondary only so that backups always run from either of the both secondary replicas. It is not mandatory for you to add additional replica.</li>
</ol>

<table id="tablepress-3" class="tablepress tablepress-id-3">
<thead>
<tr class="row-1">
	<th class="column-1">Backup Preference</th><th class="column-2">Backup Runs on</th><th class="column-3">Remarks</th>
</tr>
</thead>
<tbody class="row-striping row-hover">
<tr class="row-2">
	<td class="column-1">Prefer Secondary</td><td class="column-2">Secondary Replica</td><td class="column-3">Default Option. You cannot run differential backup in this option. If only Primary Replica is online, backup will run on Primary Replica.</td>
</tr>
<tr class="row-3">
	<td class="column-1">Secondary only</td><td class="column-2">Only Secondary Replicas</td><td class="column-3">Backup will never run on Primary Replica. If only Primary Replica is online, backup will not run. You cannot run differential backup in this option as well.</td>
</tr>
<tr class="row-4">
	<td class="column-1">Primary</td><td class="column-2">Primary Replica</td><td class="column-3">Choose this option if you want to run differential backup.</td>
</tr>
<tr class="row-5">
	<td class="column-1">Any Replica</td><td class="column-2">Can run on any replica based on backup priority of each availability replica in combination with its operational state and connected state.</td><td class="column-3">Set backup priority carefully between replicas.</td>
</tr>
</tbody>
</table>

<ol start="6">
<li>Use the <strong>Replica backup priorities</strong> grid to change the <strong>backup priority</strong> of the availability replicas. <strong>Backup Priority</strong> (Lowest=1, Highest=100) specifies your priority for performing backups on this replica relative to the other replicas in the same availability group. In my case backup will run on the replica that has priority 60% and if this will not be available then backup will run on the replica that has priority of 50%. Backup will never run on primary replica irrespective of backup priority settings because we have chosen to run backups only on secondary replica.<br />
<img decoding="async" class="aligncenter size-full wp-image-947" src="http://techyaz.com/wp-content/uploads/2017/09/4-AOAG-property-from-Primary.jpg" alt="Availability group property Window" width="701" height="635" srcset="https://techyaz.com/wp-content/uploads/2017/09/4-AOAG-property-from-Primary.jpg 701w, https://techyaz.com/wp-content/uploads/2017/09/4-AOAG-property-from-Primary-300x272.jpg 300w" sizes="(max-width: 701px) 100vw, 701px" /><br />
We have also an option Exclude Replica to exclude any replica where you don’t want to run backups. This is useful for remote availability replicas to which you never want to run backups there.<br />
You should click on checkbox for your respective replica name for which you want to exclude the backup as shown in above screenshot.</li>
</ol>
<ol start="7">
<li>Click on OK button to apply the changes.</li>
</ol>
<h5><span style="color: #000080;">Configure SQL Server Backup in AOAG to Run with default backup preference using T-SQL</span></h5>
<p>I have shown you how to change backup preference setting to run backups from secondary replicas using GUI. We can do the same using T-SQL commands as well. Here i will show you how to change backup preference using T-SQL. As we have changed the backup preference to secondary only option where backups will never run from primary replica. Now we can revert this change to default option using T-SQL. <strong>Prefer Secondary</strong> is default option in which backups run from secondary replica and if only primary replica is online then it will run from primary replica only.</p>
<p>Connect to the server instance that hosts the primary replica and run below command.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span style="color: #008000;">--Choose backup preference as per your choice and pass that value in AUTOMATED_BACKUP_PREFERENCE = { PRIMARY | SECONDARY_ONLY| SECONDARY | NONE }</span>
<span style="color: #0000ff;">ALTER AVAILABILITY GROUP AG_AOAGName SET (AUTOMATED_BACKUP_PREFERENCE = SECONDARY)
GO
</span></strong></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-948" src="http://techyaz.com/wp-content/uploads/2017/09/5-t-sql.jpg" alt="Change backup preference using T-sql" width="606" height="151" srcset="https://techyaz.com/wp-content/uploads/2017/09/5-t-sql.jpg 606w, https://techyaz.com/wp-content/uploads/2017/09/5-t-sql-300x75.jpg 300w" sizes="auto, (max-width: 606px) 100vw, 606px" /></p>
<p>Now your backup preference would be set to <strong>Prefer Secondary</strong> and backups will run from primary replica if only primary replica will be online.</p>
<p><em><span style="color: #800000;"><strong>Related Articles:</strong></span></em></p>
<ul>
<li><span style="color: #0000ff;"><strong><a style="color: #0000ff;" href="https://techyaz.com/sql-server/troubleshooting/secondary-replica-not-coming-online-showing-resolving-state-automatic-failover-alwayson-availability-group-configuration/" target="_blank" rel="noopener">Fix: Secondary Replica Stucked in to Resolving state</a></strong></span></li>
<li><span style="color: #0000ff;"><strong><a style="color: #0000ff;" href="https://techyaz.com/sql-server/troubleshooting/fixing-sap-connectivity-issue-aoag-automatic-failover/" target="_blank" rel="noopener">Fix: Connectivity Issue after AOAG Automatic Failover</a></strong></span></li>
<li><span style="color: #0000ff;"><strong><a style="color: #0000ff;" href="https://techyaz.com/sql-server/understanding-sql-server-recovery-model/" target="_blank" rel="noopener">Understanding SQL Server Recovery Models</a></strong></span></li>
<li><span style="color: #0000ff;"><strong><a style="color: #0000ff;" href="https://techyaz.com/sql-server/troubleshooting/fix-error-19471-listener-issue-that-came-during-configuring-sql-server-alwayson-availability-group/" target="_blank" rel="noopener">Fix: Listener Issue Error 19471</a></strong></span></li>
</ul>
<p>I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/understanding-sql-server-backup-databases-availability-group/">Understanding Backup Preferences for AlwaysOn Availability Group Databases</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/alwayson/understanding-sql-server-backup-databases-availability-group/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Fix SQL Server Error 19471: Listener issue that came during Configuring SQL Server AlwaysOn Availability Group</title>
		<link>https://techyaz.com/sql-server/alwayson/fix-error-19471-listener-issue-that-came-during-configuring-sql-server-alwayson-availability-group/</link>
					<comments>https://techyaz.com/sql-server/alwayson/fix-error-19471-listener-issue-that-came-during-configuring-sql-server-alwayson-availability-group/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Mon, 11 Sep 2017 11:02:43 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[Clustering]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[AOAG]]></category>
		<category><![CDATA[AOAG Listener]]></category>
		<category><![CDATA[HADR]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[Listener Issue]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=840</guid>

					<description><![CDATA[<p>I had an AOAG configuration between two replicas that i have deleted in order to perform some activities. I was configuring Always On Availability Group again on this database server. We followed all processes but Listener was failed to create&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/fix-error-19471-listener-issue-that-came-during-configuring-sql-server-alwayson-availability-group/">Fix SQL Server Error 19471: Listener issue that came during Configuring SQL Server AlwaysOn Availability Group</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I had an <a href="http://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">AOAG configuration</a> between two replicas that i have deleted in order to perform some activities. I was configuring Always On Availability Group again on this database server. We followed all processes but Listener was failed to create during AOAG configuration and displayed Microsoft SQL Server error 19471.</p>
<p>I have also explained another aspect of this error in attached article. If your issue is not fixed using this article, you can have a look at this one where i got the same <a href="http://techyaz.com/sql-server/alwayson/fix-aoag-listener-error-19471-kerberos-status-showing-handle-invalid/" target="_blank" rel="noopener">Listener Error 19471 because Kerberos Status was showing &#8216;The handle is invalid&#8217;</a>.</p>
<h5><span style="color: #000080;">Microsoft SQL Server Error 19471: Create failed for Availability Group Listener &#8216;Listener Name&#8217;.</span></h5>
<p>AOAG Listener was failed to create during its configuration and displayed SQL Server error 19471. This error might have multiple reasons. Here i will fix this issue in step by step manner. The full error details are given below.</p>
<div class="codediv"><strong><span class="kwrd" style="color: red;"><em>Creating availability group listener resulted in an error.</em><br />
<em> ADDITIONAL INFORMATION:</em><br />
<em> Create failed for Availability Group Listener &#8216;U********0&#8217;. (Microsoft.SqlServer.Smo)</em><br />
<em> An exception occurred while executing a Transact-SQL statement or batch.</em><br />
<em> The WSFC cluster could not bring the Network Name resource with DNS name &#8216;<span class="kwrd">U*********0</span>&#8216; online. The DNS name may have been taken or have a conflict with existing name services, or the WSFC cluster service may not be running or may be inaccessible. Use a different DNS name to resolve name conflicts, or check the WSFC cluster log for more information.</em><br />
<em> The attempt to create the network name and IP address for the listener failed. The WSFC service may not be running or may be inaccessible in its current state, or the values provided for the network name and IP address may be incorrect. Check the state of the WSFC cluster and validate the network name and IP address with the network administrator. (Microsoft SQL Server, Error: 19471)</em><br />
</span></strong></div>
<p>The screenshot of this error is given below.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-841" src="http://techyaz.com/wp-content/uploads/2017/09/1-AOAG-listener-issue-1024x426.jpg" alt="error 19471" width="1024" height="426" srcset="https://techyaz.com/wp-content/uploads/2017/09/1-AOAG-listener-issue-1024x426.jpg 1024w, https://techyaz.com/wp-content/uploads/2017/09/1-AOAG-listener-issue-300x125.jpg 300w, https://techyaz.com/wp-content/uploads/2017/09/1-AOAG-listener-issue-768x319.jpg 768w, https://techyaz.com/wp-content/uploads/2017/09/1-AOAG-listener-issue.jpg 1335w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><br />
When i checked the AlwaysOn High Availability folder on any of the replica, everything was working fine. AOAG was configured successfully and working fine but listener was not configured due to above error. You can see this in below screenshot.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-842" src="http://techyaz.com/wp-content/uploads/2017/09/2-AOAG-listener-SSMS.jpg" alt="AOAG Listener post error" width="722" height="404" srcset="https://techyaz.com/wp-content/uploads/2017/09/2-AOAG-listener-SSMS.jpg 722w, https://techyaz.com/wp-content/uploads/2017/09/2-AOAG-listener-SSMS-300x168.jpg 300w" sizes="auto, (max-width: 722px) 100vw, 722px" /></p>
<p>You can see there is no listener showing in their respective folder of the AOAG configuration in above screenshot. I tried creating Listener name from &#8220;<strong>Add Listener&#8230;</strong>&#8221; wizard but failed with same error. Let&#8217;s move to next section where we will fix this error.</p>
<h5><span style="color: #000080;">Solution</span></h5>
<p>I did some research on this error code and found a solution suggested by Microsoft in attached <a href="https://blogs.msdn.microsoft.com/alwaysonpro/2013/10/30/create-availability-group-listener-fails-with-message-19471-the-wsfc-cluster-could-not-bring-the-network-name-resource-online/" target="_blank" rel="noopener">MSDN article</a>. I followed step by step process given in this article. High level approach to fix this solution using this method is given below.</p>
<ul>
<li>Create a <strong>Client Access Point (CAP)</strong> for the AOAG <strong>listener</strong> in <strong>Failover Cluster Manager</strong>.</li>
<li>Bring CAP <strong>Online</strong>.</li>
<li><strong>Repair</strong> the CAP, if it is not coming ONLINE.</li>
<li>Once CAP comes online, <strong>remove</strong> it from failover cluster manager.</li>
<li><strong>Add listener</strong> to AOAG in SSMS.</li>
</ul>
<p>You might have a question why we are removing CAP after adding, repairing and bring it online. Creating CAP and bringing it online is to just verify that everything is ok or not. If CAP will not come online then there might be some issue at certain level that needs to be fixed first before creating listener. Let&#8217;s go ahead with above given steps to fix this issue.</p>
<p>I launched <strong>failover cluster manager</strong> and clicked on <strong>Roles</strong> tab from left side pane. Here you can see your <strong>availability group role</strong> in right side pane. Right click on this role and select &#8220;<strong>Add Resources</strong>&#8221; then click on &#8220;<strong>Client Access Point</strong>&#8220;.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-843" src="http://techyaz.com/wp-content/uploads/2017/09/3-client-access-point-FCM.jpg" alt="client access point" width="785" height="501" srcset="https://techyaz.com/wp-content/uploads/2017/09/3-client-access-point-FCM.jpg 785w, https://techyaz.com/wp-content/uploads/2017/09/3-client-access-point-FCM-300x191.jpg 300w, https://techyaz.com/wp-content/uploads/2017/09/3-client-access-point-FCM-768x490.jpg 768w" sizes="auto, (max-width: 785px) 100vw, 785px" /></p>
<p>You will get below screen to enter listener details. I entered listener name into name section and listener IP in to Address section. Once i clicked at Next button to proceed. I got below error which says this<strong> listener is already in use in Active Directory</strong>.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-844" src="http://techyaz.com/wp-content/uploads/2017/09/4-client-access-point-FCM.jpg" alt="Client Access Point Wizard" width="695" height="493" srcset="https://techyaz.com/wp-content/uploads/2017/09/4-client-access-point-FCM.jpg 695w, https://techyaz.com/wp-content/uploads/2017/09/4-client-access-point-FCM-300x213.jpg 300w" sizes="auto, (max-width: 695px) 100vw, 695px" /></p>
<p>As we know, listener name and IP should be unique and unused so here we need to remove this listener details from Active Directory. Contact your domain administrator and tell him to remove the entries for this listener name and IP.</p>
<p><strong>Once listener details will be cleared from Active Directory, go ahead and try to add listener name to the existing AlwaysOn Availability Group</strong>. This time you would be able to create the listener name. If you are still facing some issue, then we will follow remaining steps of the above suggested MSDN article. Read next section to follow remaining steps to fix this issue.</p>
<h5><span style="color: #000080;">Failed to add Listener after clearing DNS entries and DNS Status showing The handle is invalid</span></h5>
<p>If you are still facing same issue during adding listener or configuring AlwaysOn Availability Group then you can again ask your domain admin to relook into Active Directory because there is a possibility of some entries in AD for the listener name and IP during your failed attempts to create the listen name. If domain admin will not find any entry then we will proceed with the steps that Microsoft has suggested in above attached article.</p>
<p>We will create <strong>Client Access Point</strong> in failover cluster manager for Availability Group role as we were trying to create in above section. Right click on Availability Group role and select &#8220;Add Resources&#8221; then &#8220;Client Access Point&#8221; as shown in image no 3. You will get below screen to enter listener name and corresponding IP address in highlighted sections. Click on Next button to proceed post entering the listener details.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-845" src="http://techyaz.com/wp-content/uploads/2017/09/5-CAP.jpg" alt="client access point wizard" width="687" height="481" srcset="https://techyaz.com/wp-content/uploads/2017/09/5-CAP.jpg 687w, https://techyaz.com/wp-content/uploads/2017/09/5-CAP-300x210.jpg 300w" sizes="auto, (max-width: 687px) 100vw, 687px" /></p>
<p>You will get below screen to proceed once you click on next button of above screen.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-846" src="http://techyaz.com/wp-content/uploads/2017/09/6-CAP.jpg" alt="client access point wizard" width="691" height="481" srcset="https://techyaz.com/wp-content/uploads/2017/09/6-CAP.jpg 691w, https://techyaz.com/wp-content/uploads/2017/09/6-CAP-300x209.jpg 300w" sizes="auto, (max-width: 691px) 100vw, 691px" /></p>
<p>Click on Finish button to create the Client Access Point in failover cluster manager for this listener.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-847" src="http://techyaz.com/wp-content/uploads/2017/09/7-CAP.jpg" alt="client access point wizard" width="683" height="475" srcset="https://techyaz.com/wp-content/uploads/2017/09/7-CAP.jpg 683w, https://techyaz.com/wp-content/uploads/2017/09/7-CAP-300x209.jpg 300w" sizes="auto, (max-width: 683px) 100vw, 683px" /></p>
<p>Once you will click on finish button, your Client Access Point for your listener will be created in the failover cluster manager as shown in below screen. Availability Group role was running fine but after adding Client Access Point it has changed into <strong>Partial Running</strong> mode.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-848" src="http://techyaz.com/wp-content/uploads/2017/09/8-CAP-FCM.jpg" alt="CAP in FCM" width="684" height="433" srcset="https://techyaz.com/wp-content/uploads/2017/09/8-CAP-FCM.jpg 684w, https://techyaz.com/wp-content/uploads/2017/09/8-CAP-FCM-300x190.jpg 300w" sizes="auto, (max-width: 684px) 100vw, 684px" /></p>
<p>We can see CAP is showing as offline in above image. That is the reason Availability Group role has changed into Partial Running mode. Now we will bring it online manually. <strong>Right click</strong> on Listener CAP and click on &#8220;<strong>Bring Online</strong>&#8221; option.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-849" src="http://techyaz.com/wp-content/uploads/2017/09/9-CAP-Online.jpg" alt="Bring CAP online" width="591" height="235" srcset="https://techyaz.com/wp-content/uploads/2017/09/9-CAP-Online.jpg 591w, https://techyaz.com/wp-content/uploads/2017/09/9-CAP-Online-300x119.jpg 300w" sizes="auto, (max-width: 591px) 100vw, 591px" /></p>
<p>We can see Listener IP has come online whereas listener name is failed to come online. Now we will check the properties of the client access point (CAP).</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-850" src="http://techyaz.com/wp-content/uploads/2017/09/10-CAP-online.jpg" alt="CAP online" width="477" height="209" srcset="https://techyaz.com/wp-content/uploads/2017/09/10-CAP-online.jpg 477w, https://techyaz.com/wp-content/uploads/2017/09/10-CAP-online-300x131.jpg 300w" sizes="auto, (max-width: 477px) 100vw, 477px" /></p>
<p><strong>Right click</strong> on Listener Name and choose <strong>Properties</strong> option. You will get below screen where you can see <strong>NetBIOS, DNS and Kerberos status</strong>. <strong>NetBIOS</strong> and <strong>Kerberos</strong> <strong>status</strong> is showing OK but <strong>DNS status</strong> is not ok and showing &#8220;<strong>The handle is invalid.</strong>&#8221; This is the issue that needs to be fixed to create listener.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-851" src="http://techyaz.com/wp-content/uploads/2017/09/11-CAP-property.jpg" alt="Client Access Point Property" width="418" height="499" srcset="https://techyaz.com/wp-content/uploads/2017/09/11-CAP-property.jpg 418w, https://techyaz.com/wp-content/uploads/2017/09/11-CAP-property-251x300.jpg 251w" sizes="auto, (max-width: 418px) 100vw, 418px" /></p>
<p>When i checked the cluster events, i saw below error details that are also very much same.</p>
<p><span style="color: #ff0000;"><strong><em>Cluster network name resource &#8216;Cluster Name&#8217; failed registration of one or more associated DNS name(s) for the following reason:</em></strong></span><br />
<span style="color: #ff0000;"><strong><em> The handle is invalid.</em></strong></span><br />
<span style="color: #ff0000;"><strong><em> Ensure that the network adapters associated with dependent IP address resources are configured with at least one accessible DNS server.</em></strong></span></p>
<p><strong>To fix</strong> this DNS issue ( <strong>The handle is invalid</strong> ) we will <strong>repair</strong> this CAP. <strong>Right click</strong> on Listener Name showing in failover cluster manager, click on &#8220;<strong>More Actions</strong>&#8221; and then click on<strong> Repair</strong> as per below image.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-852" src="http://techyaz.com/wp-content/uploads/2017/09/12-CAP-Repair.jpg" alt="CAP Repair" width="797" height="601" srcset="https://techyaz.com/wp-content/uploads/2017/09/12-CAP-Repair.jpg 797w, https://techyaz.com/wp-content/uploads/2017/09/12-CAP-Repair-300x226.jpg 300w, https://techyaz.com/wp-content/uploads/2017/09/12-CAP-Repair-768x579.jpg 768w" sizes="auto, (max-width: 797px) 100vw, 797px" /></p>
<p>Once you will click on <strong>Repair</strong>, it will come online and then go in offline. Now right click on Listener name again and click on <strong>Bring Online</strong> button. This time Listener Name will come online if CAP has been repaired successfully. You can repeat the repair exercise if your CAP is not coming online. If you are still facing issue then you can again contact to domain admin to look into Active Directory server.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-853" src="http://techyaz.com/wp-content/uploads/2017/09/13-CAP-Repair-Online.jpg" alt="CAP status after repair" width="587" height="405" srcset="https://techyaz.com/wp-content/uploads/2017/09/13-CAP-Repair-Online.jpg 587w, https://techyaz.com/wp-content/uploads/2017/09/13-CAP-Repair-Online-300x207.jpg 300w" sizes="auto, (max-width: 587px) 100vw, 587px" /></p>
<p>Now you can see Client Access Point for the listener is showing online now. if you go to the property of this Listener CAP, you can see <strong>NetBIOS, DNS</strong> and <strong>Kerberos status</strong> is showing OK.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-854" src="http://techyaz.com/wp-content/uploads/2017/09/14-CAP-Repair-Property.jpg" alt="Client Access Point Property post Repair" width="425" height="507" srcset="https://techyaz.com/wp-content/uploads/2017/09/14-CAP-Repair-Property.jpg 425w, https://techyaz.com/wp-content/uploads/2017/09/14-CAP-Repair-Property-251x300.jpg 251w" sizes="auto, (max-width: 425px) 100vw, 425px" /></p>
<p>Close above property window. Now DNS issue is resolved that was main culprit during listener creation so next step is to <strong>remove this Client Access Point</strong> for this Listener and create the listener in SSMS that will <strong>create Listener client access point (CAP) automatically in the failover cluster manager.</strong></p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-855" src="http://techyaz.com/wp-content/uploads/2017/09/15-CAP-removal.jpg" alt="Remove Client Access Ppoint" width="583" height="337" srcset="https://techyaz.com/wp-content/uploads/2017/09/15-CAP-removal.jpg 583w, https://techyaz.com/wp-content/uploads/2017/09/15-CAP-removal-300x173.jpg 300w" sizes="auto, (max-width: 583px) 100vw, 583px" /></p>
<p>Once you click on remove button below window will come to proceed. Click on ok to proceed.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-856" src="http://techyaz.com/wp-content/uploads/2017/09/16-CAP-Removal.jpg" alt="CAP removal" width="554" height="291" srcset="https://techyaz.com/wp-content/uploads/2017/09/16-CAP-Removal.jpg 554w, https://techyaz.com/wp-content/uploads/2017/09/16-CAP-Removal-300x158.jpg 300w" sizes="auto, (max-width: 554px) 100vw, 554px" /></p>
<p>Once this CAP will be removed then connect to primary replica of the AOAG configuration. Expand the <strong>AlwaysOn High Availability</strong> folder and then <strong>Availability Group Listeners</strong> folder. You will not be able to see anything as there is no listener as of now. <strong>Right click</strong> on <strong>Availability Group Listeners</strong> folder and click on &#8220;<strong>Add Listener&#8230;&#8221; </strong>option.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-857" src="http://techyaz.com/wp-content/uploads/2017/09/17-Add-Listener.jpg" alt="Add Listener in SSMS" width="389" height="455" srcset="https://techyaz.com/wp-content/uploads/2017/09/17-Add-Listener.jpg 389w, https://techyaz.com/wp-content/uploads/2017/09/17-Add-Listener-256x300.jpg 256w" sizes="auto, (max-width: 389px) 100vw, 389px" /></p>
<p>You will get below image (<strong>New Availability Group Listener Wizard</strong>) to enter the <strong>listener details</strong>. Enter the <strong>Listener DNS Name</strong> then <strong>port</strong> followed by choosing <strong>Network Mode</strong>. Click on <strong>Add</strong> button to enter <strong>Listener IP Address</strong>. Once you are done with all details. Click on Ok button to apply this changes. Add Listener wizard will disappear if listener will be created successfully otherwise it will give you the error on the same wizard.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-858" src="http://techyaz.com/wp-content/uploads/2017/09/18-Add-Listener.jpg" alt="Add listener" width="711" height="637" srcset="https://techyaz.com/wp-content/uploads/2017/09/18-Add-Listener.jpg 711w, https://techyaz.com/wp-content/uploads/2017/09/18-Add-Listener-300x269.jpg 300w" sizes="auto, (max-width: 711px) 100vw, 711px" /></p>
<p>As we have created <strong>Availability Group Listener</strong> for this AOAG configuration so you can go ahead and verify this in SSMS by expanding <strong>Availability Group Listeners</strong> folder. You can see same listener name is showing under Availability Group Listeners folder on both primary as well as secondary replica in below image.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-859" src="http://techyaz.com/wp-content/uploads/2017/09/19-Listener-Created.jpg" alt="Listener created successfully" width="728" height="404" srcset="https://techyaz.com/wp-content/uploads/2017/09/19-Listener-Created.jpg 728w, https://techyaz.com/wp-content/uploads/2017/09/19-Listener-Created-300x166.jpg 300w" sizes="auto, (max-width: 728px) 100vw, 728px" /></p>
<p><em><strong><span style="color: #800000;">Related Articles:</span></strong></em></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">Learn what is AlwaysOn Availability Group.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/fix-aoag-listener-error-19471-kerberos-status-showing-handle-invalid/" target="_blank" rel="noopener">Fix Listener Error 19471 due to Kerberos Status&#8221;The handle is invalid&#8221;</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fixing-sap-connectivity-issue-aoag-automatic-failover/" target="_blank" rel="noopener">How to fix AlwaysOn Availability group Automatic Failover Issue</a>.</strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/secondary-replica-not-coming-online-showing-resolving-state-automatic-failover-alwayson-availability-group-configuration/" target="_blank" rel="noopener">Fix: Secondary Replica is showing in Resolving state and not becoming Primary</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/" target="_blank" rel="noopener">How to fix error 15141: The server principal owns one or more endpoint(s) and cannot be dropped</a></strong></li>
</ul>
<p>I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/fix-error-19471-listener-issue-that-came-during-configuring-sql-server-alwayson-availability-group/">Fix SQL Server Error 19471: Listener issue that came during Configuring SQL Server AlwaysOn Availability Group</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/alwayson/fix-error-19471-listener-issue-that-came-during-configuring-sql-server-alwayson-availability-group/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Fixing SAP Connectivity issue after AOAG Automatic failover</title>
		<link>https://techyaz.com/sql-server/alwayson/fixing-sap-connectivity-issue-aoag-automatic-failover/</link>
					<comments>https://techyaz.com/sql-server/alwayson/fixing-sap-connectivity-issue-aoag-automatic-failover/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Fri, 18 Aug 2017 19:46:24 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[AOAG]]></category>
		<category><![CDATA[connectivity Issue]]></category>
		<category><![CDATA[HADR]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[sap]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=550</guid>

					<description><![CDATA[<p>We have Alwayson Availability Group configuration for our SAP systems. We faced SAP connectivity issue when application team tried to do a failover/HA testing and connect to database post failover, they were failed to connect to the current primary replica&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/fixing-sap-connectivity-issue-aoag-automatic-failover/">Fixing SAP Connectivity issue after AOAG Automatic failover</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>We have <span style="color: #333399;"><strong><a href="https://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">Alwayson Availability Group</a></strong></span> configuration for our SAP systems. We faced SAP connectivity issue when application team tried to do a failover/HA testing and connect to database post failover, they were failed to connect to the current primary replica which was secondary replica before failover.</p>
<h3><span style="color: #000080;"><strong>Automatic Failover Worked Well but Application failed to connect</strong></span></h3>
<p>I have an AOAG configuration with Automatic failover between two replicas in my environment.  Last week, we had High Availability testing for all applications. Everything was working fine if we were doing failover from Management Studio. Databases were failing over and failing back successfully.</p>
<p>Issue occurred when application team tried to connect to database server after failover. They were <span style="color: #333399;"><strong><a href="https://techyaz.com/sql-server/troubleshooting/secondary-replica-not-coming-online-showing-resolving-state-automatic-failover-alwayson-availability-group-configuration/" target="_blank" rel="noopener">failed to connect to the secondary replica after every failover</a></strong></span> but applications were working fine from primary replica. Below are the error details that are coming to application team during establishing database connection post failover to current primary replica (earlier secondary replica).</p>
<div class="codediv"><strong><span class="kwrd" style="color: red;">[Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Invalid object name &#8216;DBPROPERTIES&#8217;.<br />
[Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Invalid object name &#8216;SVERS&#8217;.<br />
</span></strong></div>
<p>When we saw at the database level, everything was working fine.<span style="color: #333399;"><strong> <a href="https://techyaz.com/sql-server/troubleshooting/secondary-replica-not-coming-online-showing-resolving-state-automatic-failover-alwayson-availability-group-configuration/" target="_blank" rel="noopener">Secondary replica was successfully transitioning as primary replica after failover</a></strong></span> and databases were accessible from failover node but application was not able to connect to this replica. We checked all respective logins associated with the application and everything was there on secondary replica.</p>
<p>One thing we have noticed during troubleshooting that SQL login was became orphaned after each failover and we did resolved orphaned user issue manually post each failover. But there is no benefit of automatic failover if you need to establish database connection manually after each failover.</p>
<p>After spending some time, we fixed this issue. Application was not able to connect to database post failover because one of the SQL login which was used by application has different SID on secondary replica than its primary replica. I recreated this login on secondary replica with same SID which was in primary replica and this has fixed the issue. Here, I will explain step by step method to make you understand the issue and its solution.</p>
<h3><span style="color: #000080;"><strong>Resync the SID from Primary Replica</strong></span></h3>
<p>First check the current configuration of this AOAG. Run below command to get the AOAG details. We can see the configuration is running into automatic failover mode along with replica names.</p>
<pre class="brush: sql; title: ; notranslate" title=""><span class="kwrd" style="color: blue;"><strong>SELECT replica_server_name, availability_mode_desc, failover_mode_desc
FROM sys.availability_replicas
</strong></span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-551" src="http://techyaz.com/wp-content/uploads/2017/08/1-AOAG-details.jpg" alt="AOAG details" width="697" height="221" srcset="https://techyaz.com/wp-content/uploads/2017/08/1-AOAG-details.jpg 697w, https://techyaz.com/wp-content/uploads/2017/08/1-AOAG-details-300x95.jpg 300w" sizes="auto, (max-width: 697px) 100vw, 697px" /></p>
<p>If you do failover between replicas then it will not throw any error in SSMS or database level. But if you will ask application team to connect to database server using Listener post failover, you will get error.</p>
<p>You will face error because SID of the login used by application is different on both replica servers. You can also get the error when the login used by application to establish database connection is not present on secondary replica. You need to sync the login, password and SID of this login to the secondary replica. Follow this tip to fix the issue that are coming due to any of the given reason.</p>
<p>The SID identifies the security context of the login and is unique within the server instance. If the login is created from a Windows user or group, it is given the Windows SID of the source principle; the Windows SID is unique within the domain. If the login is created as a legacy-style <strong>SQL Server login </strong>that requires a password, the server will generate a SID. Now check the SID of the login which is used to connect to database on primary replica.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--Replace your identified login with xyz.</span><span class="kwrd" style="color: blue;">
select name,sid from syslogins
where name='xyz'
</span></strong></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-552" src="http://techyaz.com/wp-content/uploads/2017/08/2-check-sid.jpg" alt="check sid" width="394" height="185" srcset="https://techyaz.com/wp-content/uploads/2017/08/2-check-sid.jpg 394w, https://techyaz.com/wp-content/uploads/2017/08/2-check-sid-300x141.jpg 300w, https://techyaz.com/wp-content/uploads/2017/08/2-check-sid-520x245.jpg 520w, https://techyaz.com/wp-content/uploads/2017/08/2-check-sid-720x340.jpg 720w" sizes="auto, (max-width: 394px) 100vw, 394px" /></p>
<p>Now run same command on secondary replica. You can see SID is different on both replicas for same login. Ideally everything should be same and in sync with primary replica that are associated with AOAG.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-553" src="http://techyaz.com/wp-content/uploads/2017/08/3-check-sid.jpg" alt="check sid" width="361" height="198" srcset="https://techyaz.com/wp-content/uploads/2017/08/3-check-sid.jpg 361w, https://techyaz.com/wp-content/uploads/2017/08/3-check-sid-300x165.jpg 300w" sizes="auto, (max-width: 361px) 100vw, 361px" /></p>
<p>Now we need to delete this login from secondary replica and recreate it using same SID which is present on primary replica. Next, drop the login either using SSMS or T-SQL. SSMS way is given below:</p>
<ul>
<li>Connect to target SQL Server Instance.</li>
<li>Expand the security folder.</li>
<li>Expand the Logins folder.</li>
<li>Right click and choose delete on the identified login which needs to be deleted.</li>
<li>Click on Ok button of the login deletion window.</li>
</ul>
<p>If you want to drop this login using T-SQL command then open a query window and execute below command.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--change the name of xyz with your login name which you want to delete.</span><span class="kwrd" style="color: blue;">
DROP Login 'xyz'
</span></strong></pre>
<p>You might get multiple dependency errors during dropping this login because there is possibility, this login might own few objects, agent jobs or databases on this instance. I got <span style="color: #333399;"><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15170/" target="_blank" rel="noopener">Error 15170 during dropping this login</a> </strong></span>which i fixed in attached tip to remove this login. You can also read below articles if you are getting different kind of DROP Login failed issues:</p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">How to fix Error 15174: Login owns one or more databases.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">How to fix Error 15173: Revoke the permissions before dropping the login.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/" target="_blank" rel="noopener">How to fix error 15138 &amp; Error 3729: DROP login failed</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/" target="_blank" rel="noopener">How to fix error 15141: The server principal owns one or more endpoint(s) and cannot be dropped</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15434-not-drop-login-user-currently-logged/" target="_blank" rel="noopener">How to fix error 15434: Could not drop login as the user is currently logged in</a></strong></li>
</ul>
<p>Once login will be dropped, go ahead and create same login with same password and SID which are used on primary replica. Copy the SID from <strong>image 2</strong> when you check the SID for this login on primary replica and use that during CREATE Login statement. If you don&#8217;t have this login on secondary replica yet then also you can follow same process to create the login.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--copy the SID from primary replica.</span><span class="kwrd" style="color: blue;">
CREATE Login xyz WITH password = 'password@123', CHECK_Policy=Off, SID = 0xC2Cabcdefghijk123hghj6C3
</span></strong></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-554" src="http://techyaz.com/wp-content/uploads/2017/08/4-create-login-sid.jpg" alt="create login" width="960" height="204" srcset="https://techyaz.com/wp-content/uploads/2017/08/4-create-login-sid.jpg 960w, https://techyaz.com/wp-content/uploads/2017/08/4-create-login-sid-300x64.jpg 300w, https://techyaz.com/wp-content/uploads/2017/08/4-create-login-sid-768x163.jpg 768w" sizes="auto, (max-width: 960px) 100vw, 960px" /></p>
<p>We can see command executed successfully. Now issue will be fixed if you don&#8217;t had this login on secondary replica and you just created it for very first time. But you might get orphaned user issue if you had this login earlier with different SID on this instance. Now we need to fix the orphaned users on the secondary replica.</p>
<h3><span style="color: #000080;"><strong>Fix Orphaned Users</strong></span></h3>
<p>Now you need to run below command to check the orphaned users on your database. Make sure that your database is working as primary otherwise you would not be able to run this command. You can failover and then run this command if database will become primary.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--change the dbname</span><span class="kwrd" style="color: blue;">
USE DBNAME
Go
sp_change_users_login 'report'
</span></strong></pre>
<p>If you will get your user name which was mapped to the identified login then we need to fix this orphaned user. Run below command to fix this issue.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--change the dbname
--Map database user xyz to login xyz.  </span></strong><span class="kwrd" style="color: blue;"><strong>
USE DBName;  
GO  
EXEC sp_change_users_login 'Update_One', 'xyz', 'xyz';  
GO </strong> 
</span></pre>
<p>Now orphaned user issue is also resolved and we have fixed the application connectivity issue that was reported after automatic failover of AOAG. You can do failover testing again to make sure application connectivity is working fine after AOAG failover.</p>
<p>I hope you like this article. Please follow us on our <strong><a href="https://www.facebook.com/Techyaz/">facebook page</a> </strong>and on<strong> <a href="https://twitter.com/Tech_yaz">Twitter </a></strong>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/fixing-sap-connectivity-issue-aoag-automatic-failover/">Fixing SAP Connectivity issue after AOAG Automatic failover</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/alwayson/fixing-sap-connectivity-issue-aoag-automatic-failover/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Why is Secondary Replica Showing in Resolving state after AOAG Automatic failover?</title>
		<link>https://techyaz.com/sql-server/alwayson/secondary-replica-not-coming-online-showing-resolving-state-automatic-failover-alwayson-availability-group-configuration/</link>
					<comments>https://techyaz.com/sql-server/alwayson/secondary-replica-not-coming-online-showing-resolving-state-automatic-failover-alwayson-availability-group-configuration/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Wed, 02 Aug 2017 15:29:46 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[AOAG]]></category>
		<category><![CDATA[Clustering]]></category>
		<category><![CDATA[HADR]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=341</guid>

					<description><![CDATA[<p>Sometimes AOAG configuration stuck in resolving state and its secondary Replica does not come online. When you check the Alwayson Availability Group configuration, you find it showing in resolving state after Automatic failover of AOAG Configuration. Let us get the&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/secondary-replica-not-coming-online-showing-resolving-state-automatic-failover-alwayson-availability-group-configuration/">Why is Secondary Replica Showing in Resolving state after AOAG Automatic failover?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Sometimes AOAG configuration stuck in resolving state and its secondary Replica does not come online. When you check the Alwayson Availability Group configuration, you find it showing in resolving state after Automatic failover of AOAG Configuration. Let us get the reason behind secondary replica stuck in resolving state and solution to overcome such issues in future.</p>
<h3><span style="color: #000080;"><strong>SQL Server AlwaysOn Availability Group</strong></span></h3>
<p><strong><a href="https://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">SQL Server AlwaysOn Availability Group</a></strong> is an advanced version of database mirroring and introduced in SQL Server 2012. AOAG is HA &amp; DR solution for SQL Server databases. We can group a bunch of databases as one Availability Group and failover/failback as one entity whereas it was not possible in database mirroring. Database Mirroring can be configured only for single database at a time. You can visit the attached link to learn more about <strong><a href="https://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">AlwaysOn Basics.</a></strong></p>
<p>I have also an AOAG configuration in my environment which is set for Automatic failover between both replicas. Last week, we faced an issue during automatic failover. Secondary replica was not transitioning as primary replica during an automatic failover and it was stuck in &#8220;Resolving&#8221; state. It was full down time for application because primary replica was lost and availability databases were not coming online on secondary replica.</p>
<p>I will explain step by step method to make you understand the issue and the fix.</p>
<h3><span style="color: #000080;"><strong>Automatic Failover Not Working and Secondary Replica Stuck in Resolving State</strong></span></h3>
<p>As secondary replica is not transitioning as primary replica after failover because secondary replica hung in resolving state so here, we will check the main root cause and its fix so that secondary replica comes online after every failover. Let&#8217;s check the current configuration of this AOAG. Run below command to get the AOAG details. We can see the configuration is running into automatic failover mode.</p>
<div class="codediv">
<pre><strong><span style="color: #0000ff;">SELECT replica_server_name, availability_mode, availability_mode_desc, failover_mode, failover_mode_desc
FROM sys.availability_replicas
</span></strong></pre>
</div>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-342" src="http://techyaz.com/wp-content/uploads/2017/08/1-check-AOAG-details.jpg" alt="Check AoAG details" width="1009" height="171" srcset="https://techyaz.com/wp-content/uploads/2017/08/1-check-AOAG-details.jpg 1009w, https://techyaz.com/wp-content/uploads/2017/08/1-check-AOAG-details-300x51.jpg 300w, https://techyaz.com/wp-content/uploads/2017/08/1-check-AOAG-details-768x130.jpg 768w" sizes="auto, (max-width: 1009px) 100vw, 1009px" /></p>
<p>Now connect to secondary replica in SQL Server Management Studio. Expand the AlwaysOn High Availability folder followed by Availability Group folder. Here, you can see the current state of this availability group which is showing in <em>Resolving</em> state.<br />
<img loading="lazy" decoding="async" class="aligncenter size-full wp-image-343" src="http://techyaz.com/wp-content/uploads/2017/08/2-secondary-replica-status-post-failover.jpg" alt="secondary replica status in resolving state post failover" width="463" height="317" srcset="https://techyaz.com/wp-content/uploads/2017/08/2-secondary-replica-status-post-failover.jpg 463w, https://techyaz.com/wp-content/uploads/2017/08/2-secondary-replica-status-post-failover-300x205.jpg 300w" sizes="auto, (max-width: 463px) 100vw, 463px" /></p>
<p>I checked the SQL Server error log file but i did not get enough information about this issue to proceed. I searched about this issue and got few suggestions on web that i should check the cluster log. I checked failover cluster manager for critical events. I got below event in failover cluster manager.</p>
<div class="codediv">
<pre><strong><span style="color: #0000ff;">Clustered role 'AG_***' has exceeded its failover threshold. It has exhausted the configured number of failover attempts within the failover period of time allotted to it and will be left in a failed state.
No additional attempts will be made to bring the role online or fail it over to another node in the cluster.
Please check the events associated with the failure. After the issues causing the failure are resolved the role can be brought online manually or the cluster may attempt to bring it online again after the restart delay period.</span></strong></pre>
</div>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-344" src="http://techyaz.com/wp-content/uploads/2017/08/3-check-cluster-events.jpg" alt="check cluster events" width="799" height="333" srcset="https://techyaz.com/wp-content/uploads/2017/08/3-check-cluster-events.jpg 799w, https://techyaz.com/wp-content/uploads/2017/08/3-check-cluster-events-300x125.jpg 300w, https://techyaz.com/wp-content/uploads/2017/08/3-check-cluster-events-768x320.jpg 768w" sizes="auto, (max-width: 799px) 100vw, 799px" /></p>
<h3><span style="color: #000080;"><strong>Fix Resolving state and Make Secondary Replica Primary</strong></span></h3>
<p>Above issue clearly indicates about some cluster configuration related to role created for AOAG. As we can see, there is one role is showing under roles tab of this cluster group in below image. We can see the current owner of this role is still showing as node 1.<br />
<img loading="lazy" decoding="async" class="aligncenter size-full wp-image-345" src="http://techyaz.com/wp-content/uploads/2017/08/4-FCM-status.jpg" alt="failover cluster manager status" width="799" height="212" srcset="https://techyaz.com/wp-content/uploads/2017/08/4-FCM-status.jpg 799w, https://techyaz.com/wp-content/uploads/2017/08/4-FCM-status-300x80.jpg 300w, https://techyaz.com/wp-content/uploads/2017/08/4-FCM-status-768x204.jpg 768w" sizes="auto, (max-width: 799px) 100vw, 799px" /></p>
<p>Now right click on this role and choose properties as per below image.<br />
<img loading="lazy" decoding="async" class="aligncenter size-full wp-image-346" src="http://techyaz.com/wp-content/uploads/2017/08/5-FCM-Roles-Properties.jpg" alt="Role properties in FCM" width="583" height="430" srcset="https://techyaz.com/wp-content/uploads/2017/08/5-FCM-Roles-Properties.jpg 583w, https://techyaz.com/wp-content/uploads/2017/08/5-FCM-Roles-Properties-300x221.jpg 300w" sizes="auto, (max-width: 583px) 100vw, 583px" /></p>
<p>You will get a properties window as shown in below screenshot. Now click on &#8220;Failover&#8221; tab of this screen to check the failover threshold details.<br />
<img loading="lazy" decoding="async" class="aligncenter size-full wp-image-347" src="http://techyaz.com/wp-content/uploads/2017/08/6-FCM-Roles-property.jpg" alt="FCM Role Properties" width="421" height="495" srcset="https://techyaz.com/wp-content/uploads/2017/08/6-FCM-Roles-property.jpg 421w, https://techyaz.com/wp-content/uploads/2017/08/6-FCM-Roles-property-255x300.jpg 255w" sizes="auto, (max-width: 421px) 100vw, 421px" /></p>
<p>We can see the failover threshold is set to only 1 in the 6 hours. It means if any failover happen more than once in the 6 hrs time period it will remain in failed state and will not try to come online. Now increase this value as per your need. I have changed it to 10. Click on apply and Ok button.<br />
<img loading="lazy" decoding="async" class="aligncenter size-full wp-image-348" src="http://techyaz.com/wp-content/uploads/2017/08/7-FCM-Roles-property-change-value.jpg" alt="FCM Role Properties" width="409" height="495" srcset="https://techyaz.com/wp-content/uploads/2017/08/7-FCM-Roles-property-change-value.jpg 409w, https://techyaz.com/wp-content/uploads/2017/08/7-FCM-Roles-property-change-value-248x300.jpg 248w" sizes="auto, (max-width: 409px) 100vw, 409px" /></p>
<p>Now, secondary replica of availability databases will not come online automatically. We need to bring them online. We have multiple options to bring them online from resolving state. You can directly run the failover by right click on availability group in SSMS and then proceed with failover.</p>
<p>Another option is to bring them online from failover cluster manager. You can either right click on the AOAG role and click on &#8220;Bring Online&#8230;&#8221; option or you can failover it to best possible node. As primary replica is down and not accessible so it will be failed over to the secondary replica only because this node is only available this time. Let&#8217;s right click on AOAG role in failover cluster manager, choose move and then click on &#8220;Best Possible Node&#8221;<br />
<img loading="lazy" decoding="async" class="aligncenter size-full wp-image-349" src="http://techyaz.com/wp-content/uploads/2017/08/8-FCM-Failover-post-change.jpg" alt="FCM failover post increasing failover threshold " width="807" height="375" srcset="https://techyaz.com/wp-content/uploads/2017/08/8-FCM-Failover-post-change.jpg 807w, https://techyaz.com/wp-content/uploads/2017/08/8-FCM-Failover-post-change-300x139.jpg 300w, https://techyaz.com/wp-content/uploads/2017/08/8-FCM-Failover-post-change-768x357.jpg 768w" sizes="auto, (max-width: 807px) 100vw, 807px" /></p>
<p>It will process and come online within few seconds and this time you can see this role is online from node 2 as current owner is showing as node 2 now.<br />
<img loading="lazy" decoding="async" class="aligncenter size-full wp-image-350" src="http://techyaz.com/wp-content/uploads/2017/08/9-AOAG-Role-online.jpg" alt="Bring role online" width="801" height="365" srcset="https://techyaz.com/wp-content/uploads/2017/08/9-AOAG-Role-online.jpg 801w, https://techyaz.com/wp-content/uploads/2017/08/9-AOAG-Role-online-300x137.jpg 300w, https://techyaz.com/wp-content/uploads/2017/08/9-AOAG-Role-online-768x350.jpg 768w" sizes="auto, (max-width: 801px) 100vw, 801px" /></p>
<p>We can also validate this change while making a database connection to the secondary replica in SSMS. Connect to secondary replica and expand the AlwaysOn Availability Group folders. You can see now availability group is showing as primary. That means your database is online from secondary replica to accept the user connections.<br />
<img loading="lazy" decoding="async" class="aligncenter size-full wp-image-351" src="http://techyaz.com/wp-content/uploads/2017/08/10-AOAG-secondary-replica.jpg" alt="resolving state changed to primary" width="271" height="275" /></p>
<p>You can also test this exercise to make sure automatic failover is working fine or not to prevent this kind of future outages. Once your earlier primary replica comes online, you shutdown SQL Server services on secondary replica/current primary replica. Once it will go down, your current secondary replica becomes primary automatically. Before shutdown SQL Server services, make sure databases should be fully synchronized.</p>
<p>Hee, we have fixed Alwayson issue where secondary replica is not coming online after failover and hung in resolving state. I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p><em><strong>Read More:</strong></em></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/upgrade-patch-availability-group-instances/" target="_blank" rel="noopener">How to Upgrade or Apply Patches on AOAG Instances?</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/fix-aoag-listener-error-19471-kerberos-status-showing-handle-invalid/" target="_blank" rel="noopener">Fix AOAG Listener Error 19471: The handle is Invalid</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/restore-database-participating-alwayson-availability-group/" target="_blank" rel="noopener">How to Restore a Database participating in AOAG?</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fixing-sap-connectivity-issue-aoag-automatic-failover/" target="_blank" rel="noopener">Fix Application Connectivity Issue after AOAG Failover</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/secondary-replica-not-coming-online-showing-resolving-state-automatic-failover-alwayson-availability-group-configuration/">Why is Secondary Replica Showing in Resolving state after AOAG Automatic failover?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/alwayson/secondary-replica-not-coming-online-showing-resolving-state-automatic-failover-alwayson-availability-group-configuration/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
