<?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>AlwaysOn - Techyaz.com</title>
	<atom:link href="https://techyaz.com/tag/alwayson/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Tips, Tutorials and How-to Topics</description>
	<lastBuildDate>Fri, 23 Jul 2021 09:01:31 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8</generator>

<image>
	<url>https://techyaz.com/wp-content/uploads/2017/11/cropped-Site-icon-150x150.png</url>
	<title>AlwaysOn - Techyaz.com</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Fix Always ON Connection Timeout Error 35206 in SQL Server</title>
		<link>https://techyaz.com/sql-server/alwayson/always-on-connection-timeout-error-35206/</link>
					<comments>https://techyaz.com/sql-server/alwayson/always-on-connection-timeout-error-35206/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Fri, 23 Jul 2021 09:01:25 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[connectivity Issue]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2613</guid>

					<description><![CDATA[<p>Recently, my company has migrated all critical SAP systems from on prem Linux based Oracle databases to Azure Cloud windows based SQL Server. These are very high end machines on which very large SQL Server databases are running with Alwayson&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/always-on-connection-timeout-error-35206/">Fix Always ON Connection Timeout Error 35206 in SQL Server</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Recently, my company has migrated all critical SAP systems from on prem Linux based Oracle databases to Azure Cloud windows based SQL Server. These are very high end machines on which very large SQL Server databases are running with Alwayson configuration between 3 replicas. These databases are highly transactional, very large in size approximately more than 10 TB and these are configured to run critical SAP systems. Since few weeks, we have started facing very strange issue of connection timeout ( SQL error 35206 ) on one of our secondary availability replica. Below is full text of this SQL Server error 35206.</p>



<p class="has-vivid-red-color has-text-color"><em><strong>A connection timeout has occurred on a previously established connection to availability replica &#8216;manvendradbggp03&#8217; with id [availability group id]. Either a networking or a firewall issue exists or the availability replica has transitioned to the resolving role.</strong></em></p>



<p>You may also receive similar issue under different alwayson error 35201. Below error will generate while attempting to establish the connection to availability group but failed because of connection timeout error 35206. The error text of this SQL error 35201 is given below.</p>



<p class="has-vivid-red-color has-text-color"> <strong><em>A connection timeout has occurred while attempting to establish a connection to availability replica &#8216;manvendradbggp03&#8217; with id [availability group id]. Either a networking or firewall issue exists, or the endpoint address provided for the replica is not the database mirroring endpoint of the host server instance.</em></strong></p>



<p>If you are always getting above issues and unable to establish any connection to its respective availability replica then you should immediately look in to network side whether there is poor network latency, any network packet drop issue or firewall is blocking some connections or not as suggested in error code. But if you are getting this issue on intermittent basis then you should keep reading this article to understand more about alwayson error 35206.</p>



<h2 class="wp-block-heading">SQL Server Error 35206 and Error 35201 in Always on</h2>



<p>Both errors come because of connection timeout error between their respective replicas. Microsoft has categorized these errors as <a href="https://support.microsoft.com/en-us/topic/kb3213703-fix-an-always-on-secondary-replica-goes-into-a-disconnecting-state-10131118-b63a-f49f-b140-907f77774dc2" target="_blank" rel="noreferrer noopener">product issue</a> and released cumulative updates to fix them. You should also consider these cumulative updates as per your SQL Server version. These issues will be very problematic if you will not address them on time because of below reasons:</p>



<ul class="wp-block-list"><li>Availability databases will stop synchronizing. This could be a risk of potential data loss.</li><li>Log file will start growing on your primary replica. This could be a potential risk for an outage if we will not address this issue on time.</li><li>Frequent repetitive alerts for your critical systems</li></ul>



<p>You must fix this issue by applying the cumulative update to avoid above problematic scenarios. But if you already have applied these updates and are still facing these issues then i would recommend you to read below section to try out other options.</p>



<h2 class="wp-block-heading">Fix Always on Connection Timeout SQL Error 35206 </h2>



<p>Generally, this problem encounters only on high end systems where you have more than 24 cores CPU and SQL Server is highly transactional. One very simple workaround to overcome this issue is to restart SQL Server service on your secondary replica where you are getting this issue. Don&#8217;t restart SQL Server on primary replica. Restarting SQL Server on impacted availability replica will surely fix the issue for the time being. </p>



<p>Additionally, you should consider below checks to review and make changes accordingly as per your system design if you are still getting this issue on frequent basis.</p>



<h3 class="wp-block-heading">Use Default Network Packet Size</h3>



<p>Review network packet size configuration in SQL Server. Microsoft suggested to keep network packet size configuration with default value but sometime we make changes as per our need and forgot to revert these changes to their original values so i would recommend to revert this change to its default value. Read below article if you want to learn how to change network packet size configuration in SQL Server.</p>



<ul class="wp-block-list"><li><a href="https://techyaz.com/sql-server/sql-server-administration/change-network-packet-size-sql-server/" target="_blank" rel="noreferrer noopener"><strong>How to Change Network Packet Size in SQL Server?</strong></a></li></ul>



<p>You should also consider evaluating your network bandwidth and firewall settings to make sure and isolate the issue. I would suggest you to work with network engineer on this front to review network or firewall related configurations.</p>



<h3 class="wp-block-heading">Review Connection Timeout Setting</h3>



<p>Another option i would recommend you to evaluate and review the session or connection time out settings. Make sure that session timeout setting for your always on configuration must be more than or equal to 10 seconds. You can consider increasing session time out if you have slow network between your replicas. Although if you are running highly transactional databases on high end box i assume you already have good network bandwidth but nothing wrong in reviewing the settings. Read below article if you want to reconfigure or change session time out in always on availability group.</p>



<ul class="wp-block-list"><li><a href="https://techyaz.com/sql-server/alwayson/change-session-timeout-for-availability-group-replica/" target="_blank" rel="noreferrer noopener"><strong>How to Change Session Timeout in Always on Availability Group Configuration?</strong></a></li></ul>



<p>If you are running your always on availability group configuration between multi subnet environment then i would recommend you to read attached Microsoft article to fix <a href="https://docs.microsoft.com/en-us/archive/blogs/alwaysonpro/connection-timeouts-in-multi-subnet-availability-group" target="_blank" rel="noreferrer noopener">connection timeout errors in multi subnet availability groups</a>.</p>



<p><strong><em>Read More:</em></strong> </p>



<ul class="wp-block-list"><li><strong><a href="https://techyaz.com/sql-server/alwayson/fix-error-976/" target="_blank" rel="noreferrer noopener">Fix SQL Server Error 976: Cannot connect to Secondary Replica of AlwaysON Availability Group</a></strong></li><li><strong><a href="https://techyaz.com/sql-server/alwayson/fix-alwayson-error-35250-joining-database-secondary-replica-resulted-error/" target="_blank" rel="noreferrer noopener">SQL Server Alwayson Error 35250: Joining database on Secondary Replica resulted in an error</a> </strong></li><li><strong><a href="https://techyaz.com/sql-server/alwayson/fix-error-19471-listener-issue-that-came-during-configuring-sql-server-alwayson-availability-group/" target="_blank" rel="noreferrer noopener">Fix SQL Server Error 19471: Listener issue that came during Configuring SQL Server AlwaysOn Availability Group</a> </strong></li><li><strong><a href="https://techyaz.com/interview-questions/sql-server-interview-questions/sql-server-alwayson-interview-questions-answers/" target="_blank" rel="noreferrer noopener">SQL Server Alwayson Interview Questions &amp; Answers</a></strong></li></ul>



<p></p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/always-on-connection-timeout-error-35206/">Fix Always ON Connection Timeout Error 35206 in SQL Server</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/alwayson/always-on-connection-timeout-error-35206/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>How to Change Session Timeout for Availability Group Replica</title>
		<link>https://techyaz.com/sql-server/alwayson/change-session-timeout-for-availability-group-replica/</link>
					<comments>https://techyaz.com/sql-server/alwayson/change-session-timeout-for-availability-group-replica/#respond</comments>
		
		<dc:creator><![CDATA[Editorial Staff]]></dc:creator>
		<pubDate>Thu, 22 Jul 2021 17:44:39 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[Connection Issue]]></category>
		<category><![CDATA[connectivity Issue]]></category>
		<category><![CDATA[HowTO]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2615</guid>

					<description><![CDATA[<p>Sometimes we get alwayson connection timeout errors on availability group replicas. Always on Connection timeout or alwayson session timeout is same and must be configured as per Microsoft recommendation. SQL Server Session timeout for availability replica is the time (in&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/change-session-timeout-for-availability-group-replica/">How to Change Session Timeout for Availability Group Replica</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Sometimes we get alwayson connection timeout errors on availability group replicas. Always on Connection timeout or alwayson session timeout is same and must be configured as per Microsoft recommendation. SQL Server Session timeout for availability replica is the time (in seconds) an availability replica will wait to get a ping response from connected replica before considering the connection as failed. </p>



<p>The connection timeout setting in AOAG applies only to identified secondary replica and its respective primary replica. Each secondary replica has its different session timeout value which works between the given replica and its primary replica. The default value for session timeout configuration is 10 seconds. Microsoft recommends to keep this setting value to 10 seconds or more to prevent system missing pings and false failure alerts.</p>



<h2 class="wp-block-heading">Change Session Timeout for Availability Replica</h2>



<p>This section will explain how to change or modify connection or session timeout value for an AOAG availability replica. This is needed sometimes if you are frequently getting connection timeout errors for your availability replicas. I will show two ways to modify session timeout in always on availability group. One is by using SQL Server Management Studio and another one by using T-SQL statement.</p>



<h3 class="wp-block-heading">Modify Alwayson Connection Timeout using SQL Server Management Studio</h3>



<p>Make sure you have connected to your SQL Server Instance which is hosting primary replica of always on availability group configuration. Follow below steps to change session timeout or connection timeout for identified availability replica where you are facing connection timeout errors 35206 or 35201.</p>



<ul class="wp-block-list"><li>Launch SQL Server Management Studio and connect to the primary replica</li><li>Expand folders once you connected to the primary replica instance. Click at plus sign to expand Always on High Availability node followed by Availability Groups node.</li><li>Identify and click the availability group for which you have to configure connection timeout for one of its availability replica</li><li>Identify the availability replica for which you have to change this value. Right click at this replica and click at Properties option to launch its properties page</li><li>You can see Session timeout (seconds)&nbsp;option In the&nbsp;Availability Replica Properties&nbsp;dialog box. Use Session timeout (seconds)&nbsp;option to change the number of seconds for the session timeout period on this replica. Always keep it 10 or more as per your specific need. </li></ul>



<p>We have successfully changed alwayson connection timeout for an availability replica using SQL Server management studio in above steps. Now, i will show you T-SQL approach to get this done in below section.</p>



<h3 class="wp-block-heading">Change Alwayson Connection Timeout using T-SQL Statement</h3>



<p>Here, i will show you how to change session timeout for an availability replica using T-SQL statement.</p>



<ul class="wp-block-list"><li>Launch SQL Server Management Studio and connect to the primary replica.</li><li>Open New Query window and run below ALTER AVAILABILITY GROUP statement.</li></ul>



<p class="has-text-align-left has-black-color has-text-color"><strong>ALTER AVAILABILITY GROUP&nbsp;<em>group_name</em></strong></p>



<p class="has-text-align-left has-black-color has-text-color"><strong>MODIFY REPLICA ON &#8216;<em>instance_name</em>&#8216; WITH ( SESSION_TIMEOUT =<em>seconds</em>&nbsp;)</strong></p>



<p>Make sure to replace <em>group_name</em> with your availability group name, <em>instance_name</em> with your secondary replica name for which you want to change session timeout value and <em>seconds</em> with appropriate time in seconds.</p>



<p>Once you will execute above statement, connection timeout value will change as per your specified value for your availability replica. Now, you can go ahead and monitor the connection timeout errors to see whether your issue has been fixed or not.</p>



<p>Here, i have explained how to modify or change session timeout for an always on availability group replica.</p>



<p><strong><em>Read More:</em></strong></p>



<ul class="wp-block-list"><li><strong><a href="https://techyaz.com/interview-questions/sql-server-interview-questions/sql-server-alwayson-interview-questions-answers/" target="_blank" rel="noreferrer noopener">SQL Server Alwayson Interview Questions &amp; Answers</a> </strong></li><li><strong><a href="https://techyaz.com/sql-server/alwayson/fix-alwayson-error-35250-joining-database-secondary-replica-resulted-error/" target="_blank" rel="noreferrer noopener">SQL Server Alwayson Error 35250: Joining database on Secondary Replica resulted in an error</a> </strong></li><li><strong><a href="https://techyaz.com/sql-server/alwayson/understanding-sql-server-backup-databases-availability-group/" target="_blank" rel="noreferrer noopener">Understanding Backup Preferences for AlwaysOn Availability Group Databases</a></strong></li></ul>



<p></p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/change-session-timeout-for-availability-group-replica/">How to Change Session Timeout for Availability Group Replica</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/alwayson/change-session-timeout-for-availability-group-replica/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is Enhanced Database Failover and How to Enable it for Availability Group?</title>
		<link>https://techyaz.com/sql-server/alwayson/enhanced-database-failover-in-availability-group/</link>
					<comments>https://techyaz.com/sql-server/alwayson/enhanced-database-failover-in-availability-group/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Fri, 22 Jun 2018 13:12:20 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[AOAG]]></category>
		<category><![CDATA[availability group]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2404</guid>

					<description><![CDATA[<p>As we know Always on Availability Group is the set of user databases that are combined to failover if primary replica becomes inaccessible. Till SQL Server 2014, Alwayson Availability Group was not able to start failover operation if any individual&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/enhanced-database-failover-in-availability-group/">What is Enhanced Database Failover and How to Enable it for Availability Group?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>As we know Always on Availability Group is the set of user databases that are combined to failover if primary replica becomes inaccessible. Till SQL Server 2014, Alwayson Availability Group was not able to start failover operation if any individual database within AOAG become inaccessible. Microsoft introduced an option named <em>Enhanced Database Failover</em> in SQL Server 2016 to trigger the failover in case any database participating in Availability Group loses the ability to write transactions. We also call it <em>Database Level Health Detection</em> in Availability Group.</p>
<p><em>Enhanced Database Failover</em> option is not mandatory while configuring Always on Availability Group in SQL Server 2016. It’s optional and If you have enabled <em>Enhanced Database Failover</em> option for any Availability Group along with automatic failover configuration then this option will trigger failover to a synchronized secondary replica in case any database participating in that availability group is no longer able to write transactions.</p>
<p>You cannot set this option for specific databases within availability group. <em>Enhanced database failover</em> or <em>database level health detection</em> will be enabled at availability group level. Once you configure it, all databases participating in that availability group can use this feature to trigger failover if anything goes wrong with them.</p>
<h3><span style="color: #333399;">Configure Enhanced Database Failover to Availability Group</span></h3>
<p>We can set this option as per our choice or requirement either by using GUI Wizard or by using Transact-SQL. As of now, you cannot configure <em>Enhanced Database Failover</em> option using PowerShell cmdlets. Remember, by default, enhanced database failover option is disabled. If you want to use this feature, you need to enable it. Here, I will explain how to enable <em>Enhanced Database Failover</em> to an Availability Group while its creation and to the existing one.</p>
<p>If you want to check whether an availability group has <em>enhanced database failover</em> enabled or not then we can use dynamic management view <strong>sys.availability_groups</strong>. You will see a column named <strong>db_failover</strong> in this DMV. If the value of any availability group is showing zero then it means this feature is disabled and if value shows 1 then it means it’s enabled. You can execute below command to get the settings for all availability group.</p>
<pre><strong><span style="color: #0000ff;">select name, db_failover from sys.availability_groups</span></strong><strong> </strong></pre>
<h5><span style="color: #993300;">Enable Enhanced Database Failover using GUI in SSMS</span></h5>
<p>We can enable this option while configuring availability group or later to the existing availability groups that was already created without enabling this option. As we know there are two ways to create an availability group using GUI in SSMS. One is by using <em>New Availability Group</em> dialog box and another way is by using <em>Availability Group</em> wizard window. Enabling this option is quite same in both ways. To enable enhanced database failover, select its checkbox next to <em>Database Level Health Detection</em> as shown in below image.</p>
<p>You can get this window by following given steps. In SQL Server Management Studio, connect to your SQL Server database engine. Right click on the AlwaysOn High Availability node, and run the <strong>New Availability Group Wizard</strong>. Check the <strong>Database Level Health Detection</strong> checkbox on the Specify Name page. Then complete the rest of the pages in the wizard.</p>
<p><img fetchpriority="high" decoding="async" class=" wp-image-2405 aligncenter" src="https://techyaz.com/wp-content/uploads/2018/06/1-Enhanced-DB-Failover.jpg" alt="Enable Enhanced Database Failover" width="534" height="500" srcset="https://techyaz.com/wp-content/uploads/2018/06/1-Enhanced-DB-Failover.jpg 515w, https://techyaz.com/wp-content/uploads/2018/06/1-Enhanced-DB-Failover-300x281.jpg 300w" sizes="(max-width: 534px) 100vw, 534px" /></p>
<p>Another way to enable this option for existing availability groups are given below. Launch <strong>Properties</strong> window of existing Availability Group in SQL Server Management Studio. Here, you can see this option as shown in below image. Check the option <strong>Database Level Health Detection</strong>, then click OK to apply the changes.</p>
<p><img decoding="async" class="size-full wp-image-2406 aligncenter" src="https://techyaz.com/wp-content/uploads/2018/06/2-enhanced-DB-Failover.jpg" alt="Enable Enhanced Database Failover" width="521" height="469" srcset="https://techyaz.com/wp-content/uploads/2018/06/2-enhanced-DB-Failover.jpg 521w, https://techyaz.com/wp-content/uploads/2018/06/2-enhanced-DB-Failover-300x270.jpg 300w" sizes="(max-width: 521px) 100vw, 521px" /></p>
<h5><span style="color: #993300;">Enable Enhanced Database Failover using T-SQL</span></h5>
<p>We can enable enhanced database failover using T-SQL during availability group creation or after creation by running ALTER AVAILABILITY GROUP statement. To configure it during the creation of an availability group, we must set <em>DB_FAILOVER </em>to ON as showing in below command. I have highlighted this in green colour.</p>
<pre><strong><span style="color: #0000ff;">CREATE AVAILABILITY GROUP [AG_Techyaz]</span></strong>
<strong><span style="color: #0000ff;">WITH <span style="color: #008000;">(DB_FAILOVER = ON)</span></span></strong>
<strong><span style="color: #0000ff;">FOR DATABASE [Techyaz]</span></strong>
<strong><span style="color: #0000ff;">REPLICA ON</span></strong>
<strong><span style="color: #0000ff;">       'SQLInstance1' WITH (ENDPOINT_URL = 'ENDPOINT ADDRESS:PORT-Number', FAILOVER_MODE = AUTOMATIC, AVAILABILITY_MODE = SYNCHRONOUS_COMMIT),</span></strong>
<strong><span style="color: #0000ff;">   'SQLInstance2' WITH (ENDPOINT_URL = 'ENDPOINT ADDRESS:PORT-Number', FAILOVER_MODE = AUTOMATIC, AVAILABILITY_MODE = SYNCHRONOUS_COMMIT)</span></strong></pre>
<p>If you have already created availability group without enabling this option then we have also an option to add this behavior to existing availability groups by using ALTER AVAILABILITY GROUP command as given below.</p>
<pre><strong><span style="color: #0000ff;">ALTER AVAILABILITY GROUP [AG_Techyaz] SET (DB_FAILOVER = ON)</span></strong></pre>
<h5><span style="color: #993300;">Disable Enhanced Database Failover using T-SQL</span></h5>
<p>We can disable this option simply by running below command. We must set DB_FAILOVER value to OFF to disable this feature.</p>
<pre><strong><span style="color: #0000ff;">ALTER AVAILABILITY GROUP [Techyaz] SET (DB_FAILOVER = OFF)</span></strong></pre>
<p>You will see error message 41653 logged in SQL Server error log if an availability group has failed over due to the database level health detection checks.</p>
<h3><span style="color: #333399;">Cautions</span></h3>
<p>It is very important to understand how enhanced database failover or database level health detection works. This option does not monitor disk uptime or database file availability to trigger failover.</p>
<p>Suppose your database is idle with no active transactions, and with no physical writes occurring and some of the database files become inaccessible in between then this option will not trigger automatic failover. Later, when a database checkpoint occurs, or a physical read or write occurs for fulfilling a query, then SQL Server may then notice the file issue, and react by changing the database status, and subsequently the availability group with database level health detection set on would failover due to the database health change.</p>
<p>As another example, when the SQL Server database engine needs to read a data page to fulfill a query, if the data page is cached in the buffer pool memory, then no disk read with physical access may be required to fulfill the query request. Therefore, a missing or unavailable data file may not immediately trigger an automatic failover even when database health option is enabled.</p>
<p>I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/" target="_blank" rel="noopener">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p><span style="color: #800000;"><em><strong>Read More:</strong></em></span></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/upgrade-or-patch-sql-server-failover-cluster-instance-with-availability-group/" target="_blank" rel="noopener">How to Patch SQL Server Failover Cluster Instance Running with Always on Availability Group?</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/sql-server-alwayson-interview-questions-answers/" target="_blank" rel="noopener">SQL Server Alwayson Interview Questions &amp; Answers</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/sql-server-administration/understanding-sql-server-backup-databases-availability-group/" target="_blank" rel="noopener">Understanding Backup Preferences in Alwayson Availability Group</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/change-failover-mode-of-availability-replica-in-always-on-availability-group/" target="_blank" rel="noopener">How to Change Failover Mode of Availability Replica 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">Fixing Application connectivity Issue after AOAG automatic failover</a></strong></li>
</ul>
<p>&nbsp;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/enhanced-database-failover-in-availability-group/">What is Enhanced Database Failover and How to Enable it for 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/enhanced-database-failover-in-availability-group/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Change Failover Mode of Availability Replica in Always On Availability Group?</title>
		<link>https://techyaz.com/sql-server/alwayson/change-failover-mode-of-availability-replica-in-always-on-availability-group/</link>
					<comments>https://techyaz.com/sql-server/alwayson/change-failover-mode-of-availability-replica-in-always-on-availability-group/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Mon, 21 May 2018 14:44:56 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[AOAG]]></category>
		<category><![CDATA[availability group]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2339</guid>

					<description><![CDATA[<p>Today, i will describe about the overview of failover modes in AOAG and how to Change failover mode of an availability replica in SQL Server Alwayson Availability Group. As we know SQL Server Always on availability group fails over to&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/change-failover-mode-of-availability-replica-in-always-on-availability-group/">How to Change Failover Mode of Availability Replica in Always On Availability Group?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Today, i will describe about the overview of failover modes in AOAG and how to Change failover mode of an availability replica in <a href="https://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">SQL Server Alwayson Availability Group</a>. As we know SQL Server Always on availability group fails over to one of its secondary replica in case of any failover incident. There are three types of failover exists in SQL Server Always on Availability group. Any such failover might be one of them that are given below.</p>
<ul>
<li>Automatic failover</li>
<li>Planned Manual failover</li>
<li>Forced Manual failover (forced failover).</li>
</ul>
<p><img decoding="async" class="size-full wp-image-2340 alignright" src="https://techyaz.com/wp-content/uploads/2018/05/Change-Failover-Mode-Availability-Replica.png" alt="How to Change Failover Mode of Availability Replica in SQL Server Always On Availability Group" width="300" height="300" srcset="https://techyaz.com/wp-content/uploads/2018/05/Change-Failover-Mode-Availability-Replica.png 300w, https://techyaz.com/wp-content/uploads/2018/05/Change-Failover-Mode-Availability-Replica-150x150.png 150w, https://techyaz.com/wp-content/uploads/2018/05/Change-Failover-Mode-Availability-Replica-160x160.png 160w, https://techyaz.com/wp-content/uploads/2018/05/Change-Failover-Mode-Availability-Replica-320x320.png 320w" sizes="(max-width: 300px) 100vw, 300px" /></p>
<p>There is no data loss if you perform automatic or planned manual failover but there might be some data loss if you are performing forced manual failover. Whether SQL Server Always on Availability group will failover automatically or manual, it depends on the configuration of AOAG availability mode. SQL Server Always on Availability Group supports two availability modes. First one is Synchronous-commit and another one is Asynchronous-commit mode. Synchronous-commit mode supports Automatic and Manual both failover types whereas Asynchronous-commit mode supports only manual failover that is also forced failover type.</p>
<p>The failover type (Automatic or Manual) will be decided by the failover mode property of availability replica. Always on Availability group failover modes depends on the AOAG availability mode configuration as I described above.</p>
<p>If you have synchronous commit replicas then you would have two failover mode options. One is Automatic failover mode and another is Manual failover mode whereas you have only manual failover mode option available in asynchronous commit replicas.</p>
<p>Here, I will describe how to change failover mode of SQL Server Always On availability group using SSMS and T-SQL statements. You can change from automatic failover mode to manual failover mode or vice-versa based on their availability mode configuration. As I explained above, failover mode is a replica property that determines the failover mode for replicas that run under synchronous-commit availability mode. Read below prerequisites before going to change failover mode of availability replica in SQL Server Always On availability group.</p>
<h3><span style="color: #333399;">Prerequisites</span></h3>
<ul>
<li>Make sure to perform this activity on primary replicas.</li>
<li>As we know SQL Server Failover Cluster Instances (FCIs) do not support automatic failover by availability groups, so any availability replica that is hosted by an FCI can only be configured for manual failover.</li>
<li>Make sure that you have admin privilege or minimum you should have ALTER AVAILABILITY GROUP permission on the availability group, CONTROL AVAILABILITY GROUP permission, ALTER ANY AVAILABILITY GROUP permission, or CONTROL SERVER permission.</li>
</ul>
<h3><span style="color: #333399;">Steps to Change Failover Mode of an Availability Replica</span></h3>
<p>Here, I will describe to change it using two ways. One is using SSMS and another is using T-SQL statements. Let&#8217;s start with SSMS method.</p>
<h5><strong><span style="color: #993300;">Using SQL Server Management Studio</span></strong></h5>
<p>Follow below step to change failover mode of an availability replica.</p>
<ol>
<li>Launch SQL Server Management Studio and connect to the primary replica, and expand the server tree.</li>
<li>Expand the <strong>Always On High Availability</strong>node and then <strong>Availability Groups</strong></li>
<li>Select the availability group for which you have to change the failover mode then right-click on the identified replica, and click <strong>Properties</strong>.</li>
<li>In the <strong>Availability Replica Properties </strong>dialog box, you can select correct <strong>Failover mode</strong> as per your requirement from the dropdown list to change the failover mode of this replica.</li>
<li>Choose any value from drop down as per your requirement and close the windows post apply this new change.</li>
</ol>
<h5><span style="color: #993300;">Using T-SQL</span></h5>
<p>We can change failover mode of an availability replica using T-SQL statement as well. Follow below steps to do this change using T-SQL.</p>
<ol>
<li>Connect to the Primary Replica.</li>
<li>Open New Query window to execute your T-SQL statements.</li>
<li>Run below statement to change the failover mode from Manual to Automatic of an availability group named Techyaz.</li>
</ol>
<pre style="padding-left: 30px;"><strong><span style="color: #0000ff;">ALTER AVAILABILITY GROUP Techyaz MODIFY REPLICA ON 'GURTY01' WITH</span></strong>
<strong><span style="color: #0000ff;">(FAILOVER_MODE = AUTOMATIC);</span></strong></pre>
<p>Techyaz is the name of the availability group and GURTY01 is either the computer name or the failover cluster network name. For named instances add full instance name post \ as well. Use the name that hosts the replica that you want to modify.</p>
<p>Here, I have shown you step by step method to change Failover Mode of Availability Replica in SQL Server Always On Availability Group. I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter</a> handle to get latest updates.</p>
<p><em><strong><span style="color: #800000;">Read More:</span></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/sql-server-administration/understanding-sql-server-backup-databases-availability-group/" target="_blank" rel="noopener">Understanding Backup Preferences in Alwayson Availability Group</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/alwayson/sql-server-alwayson-interview-questions-answers/" target="_blank" rel="noopener">SQL Server Alwayson Interview Questions &amp; Answers</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-alwayson-error-35250-joining-database-secondary-replica-resulted-error/" target="_blank" rel="noopener">Fix SQL Server Alwayson Error 35250: Joining Database on Secondary Replica resulted in an Error</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/change-failover-mode-of-availability-replica-in-always-on-availability-group/">How to Change Failover Mode of Availability Replica in Always On 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/change-failover-mode-of-availability-replica-in-always-on-availability-group/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Fix Error 18452: Login failed. The login is from an untrusted domain</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fix-error-18452-login-failed-login-from-untrusted-domain/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fix-error-18452-login-failed-login-from-untrusted-domain/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Tue, 03 Apr 2018 15:20:47 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[login failed]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[security]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=2058</guid>

					<description><![CDATA[<p>Recently a user has reported error 18452 while connecting to database server. Full description of this error is given below: Error: 18452, Severity: 14, State: 1. Login failed. The login is from an untrusted domain and cannot be used with&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-18452-login-failed-login-from-untrusted-domain/">Fix Error 18452: Login failed. The login is from an untrusted domain</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Recently a user has reported error 18452 while connecting to database server. Full description of this error is given below:</p>
<p><span style="color: #ff0000;"><em>Error: 18452, Severity: 14, State: 1.</em></span><br />
<span style="color: #ff0000;"><em>Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.</em></span></p>
<p>You can see the screenshot of the error 18452 in below image.</p>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-2068" src="http://techyaz.com/wp-content/uploads/2018/04/1-errormin-1024x152.jpg" alt="error 18452" width="838" height="124" srcset="https://techyaz.com/wp-content/uploads/2018/04/1-errormin-1024x152.jpg 1024w, https://techyaz.com/wp-content/uploads/2018/04/1-errormin-300x45.jpg 300w, https://techyaz.com/wp-content/uploads/2018/04/1-errormin-768x114.jpg 768w, https://techyaz.com/wp-content/uploads/2018/04/1-errormin.jpg 1118w" sizes="auto, (max-width: 838px) 100vw, 838px" /></p>
<h3><span style="color: #333399;">Error 18452 – Root Cause</span></h3>
<p>Reason behind error 18452 is because of wrong security authentication mode configuration. SQL Server is set to accept only windows logins to connect to database instance.</p>
<p>As we know SQL Server uses two authentication modes to accept database connections. One is <em>Windows Authentication mode</em> and another one is <em>SQL Server and Windows Authentication mode</em>. We also call it <em>Mixed Authentication mode</em>.</p>
<p>Sometimes, SQL Server authentication mode is set to <em>SQL Server and Windows Authentication mode</em> to accept SQL as well as windows connections but still you will face this issue. That might be because you try to connect to a server that has <a href="http://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">Always on Availability Group</a> configuration or database mirroring configuration.</p>
<p>Suppose you have AOAG configuration and you are connecting to database using primary replica name not listener name using a login for which default database is set as availability database. If failover got happen during your activity or you are connecting to secondary replica using a login for which default database is set as availability database then also you will get this error 18452 along with some SSPI context error that I have given below.</p>
<p><span style="color: #ff0000;"><em>Error: 17806, Severity: 20, State: 14.</em></span><br />
<span style="color: #ff0000;"><em>SSPI handshake failed with error code 0x8009030c, state 14 while establishing a connection with integrated security; the connection has been closed. Reason: AcceptSecurityContext failed. The Windows error code indicates the cause of failure. The logon attempt failed  </em></span></p>
<p>SSPI handshake errors comes because of Kerberos failure, which would most likely be related to non-existent SPN or bad SPN for SQL Server.</p>
<h3><span style="color: #333399;">Solution</span></h3>
<p>To fix this issue first we need to check the authentication mode set for your SQL Server Instance. If your SQL Server instance is running with windows authentication mode then you must change it to Mixed mode so that windows and SQL both type of logins can be authenticated.</p>
<p>To check the configured authentication mode for your SQL Server Instance, we need to launch SQL Server Instance property window. Right click at the instance node and click at the properties option as shown in below screenshot.</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-2059" src="http://techyaz.com/wp-content/uploads/2018/04/2-error-min.jpg" alt="Launch SQL Server Instance Property Window" width="319" height="525" srcset="https://techyaz.com/wp-content/uploads/2018/04/2-error-min.jpg 319w, https://techyaz.com/wp-content/uploads/2018/04/2-error-min-182x300.jpg 182w" sizes="auto, (max-width: 319px) 100vw, 319px" /></p>
<p>Once you will click at <strong>Properties</strong> option, you will be getting below SQL Server instance property window. Click at <strong>Security</strong> option from left side pane. You can see current <strong>Server Authentication</strong> configuration is set to <strong><em>Windows Authentication mode</em></strong> in below screenshot.</p>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-2060" src="http://techyaz.com/wp-content/uploads/2018/04/3-error-min.jpg" alt="SQL Server Instance Property Window" width="638" height="573" srcset="https://techyaz.com/wp-content/uploads/2018/04/3-error-min.jpg 703w, https://techyaz.com/wp-content/uploads/2018/04/3-error-min-300x269.jpg 300w" sizes="auto, (max-width: 638px) 100vw, 638px" /></p>
<p>Now we will change it to <strong><em>SQL Server and Windows Authentication mode</em></strong>. Select the radio button for <em>SQL Server and Windows Authentication mode</em> option and click ok button to proceed. You can see that I have selected above mode to apply the changes.</p>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-2061" src="http://techyaz.com/wp-content/uploads/2018/04/4-error-min.jpg" alt="SQL Server Instance Property Window" width="638" height="578" srcset="https://techyaz.com/wp-content/uploads/2018/04/4-error-min.jpg 702w, https://techyaz.com/wp-content/uploads/2018/04/4-error-min-300x272.jpg 300w" sizes="auto, (max-width: 638px) 100vw, 638px" /></p>
<p>Restart SQL Server services to apply the changes.</p>
<p>If your SQL Server Instance is already set with <em>SQL Server and Windows Authentication mode</em> then you should fix this issue in separate way. As I described above that one of the probable reason to get this error 18452 is because you might use AOAG replica server name to connect to the database with the login for which default database is set as the AOAG availability database.</p>
<p>If failover will happen then you would not be able to access the database because it will become secondary. Error 18452 will be generated along with SSPI handshake errors because same database is set as default database for your login that has become inaccessible now because of acting secondary database in AOAG. Failover will not happen for you because you are using replica server name to make database connection.</p>
<p>Possible solution to fix this issue is failback the AOAG to your earlier primary replica or you should use AOAG Listener name to make database connection. Also, to avoid this error during failover you should set default database for your login to master rather than availability database.</p>
<p>I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter</a> handle to get latest updates.</p>
<p><em><strong><span style="color: #800000;">Read More:</span></strong></em></p>
<ul>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/login-failed-user_name-microsoft-sql-server-error-18456/" target="_blank" rel="noopener">Fix Error 18456: Login failed for user &#8220;User_Name&#8221;</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/fix-error-4064-cannot-open-user-default-database-login-failed/" target="_blank" rel="noopener">Fix Error 4064: Cannot open user default database. Login failed</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/fix-error-53-not-open-connection-sql-server/" target="_blank" rel="noopener">Error 53: Could not open a connection on SQL Server</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/alwayson/fix-aoag-listener-error-19471-kerberos-status-showing-handle-invalid/" target="_blank" rel="noopener">AOAG Listener Error 19471: The handle is Invalid</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-18452-login-failed-login-from-untrusted-domain/">Fix Error 18452: Login failed. The login is from an untrusted domain</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/fix-error-18452-login-failed-login-from-untrusted-domain/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server Alwayson Interview Questions &#038; Answers</title>
		<link>https://techyaz.com/interview-questions/sql-server-interview-questions/sql-server-alwayson-interview-questions-answers/</link>
					<comments>https://techyaz.com/interview-questions/sql-server-interview-questions/sql-server-alwayson-interview-questions-answers/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Mon, 12 Feb 2018 07:43:16 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[SQL Server Interview Questions]]></category>
		<category><![CDATA[availability group]]></category>
		<category><![CDATA[DBA interview questions]]></category>
		<category><![CDATA[Interview Questions]]></category>
		<category><![CDATA[SQL Server]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1805</guid>

					<description><![CDATA[<p>I have published SQL Server Interview Questions and Answers on many topics. Visit attached link to get All SQL Server Interview Question and Answers published on this website on different topics. Here, I am going to publish SQL Server Alwayson&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/interview-questions/sql-server-interview-questions/sql-server-alwayson-interview-questions-answers/">SQL Server Alwayson Interview Questions &#038; Answers</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I have published SQL Server Interview Questions and Answers on many topics. Visit attached link to get <strong><a href="http://techyaz.com/category/interview-questions/sql-server-interview-questions/" target="_blank" rel="noopener">All SQL Server Interview Question and Answers</a></strong> published on this website on different topics. Here, I am going to publish SQL Server Alwayson Interview Questions and Answers.</p>
<p><img loading="lazy" decoding="async" class="size-full wp-image-1808 alignright" src="http://techyaz.com/wp-content/uploads/2018/02/AOAG-interview-QA.png" alt="SQL Server Alwayson Interview Questions &amp; Answers" width="300" height="300" srcset="https://techyaz.com/wp-content/uploads/2018/02/AOAG-interview-QA.png 300w, https://techyaz.com/wp-content/uploads/2018/02/AOAG-interview-QA-150x150.png 150w, https://techyaz.com/wp-content/uploads/2018/02/AOAG-interview-QA-160x160.png 160w, https://techyaz.com/wp-content/uploads/2018/02/AOAG-interview-QA-320x320.png 320w" sizes="auto, (max-width: 300px) 100vw, 300px" /></p>
<h3><span style="color: #333399;">SQL Server Interview Questions and Answers on Alwayson</span></h3>
<p><strong>Question- How Always ON Availability Group is different from Database Mirroring?</strong></p>
<p><strong>Answer- </strong>Always On Availability Group is advanced version of Database Mirroring. We cannot configure database mirroring for more than one database per configuration whereas we can group multiple databases as one availability group and do the failover as one unit in AOAG.</p>
<p><strong>Question- How many Replicas we can create in an AOAG Configuration?</strong></p>
<p><strong>Answer- </strong>We can create single primary replica and one to eight secondary replicas in AOAG Configuration.</p>
<p><strong>Question-How many Availability groups we can create in an AOAG configuration?</strong></p>
<p><strong>Answer- </strong>The actual number of availability groups you can create on a Server depends on the hardware and workload, but there is no enforced limit.</p>
<p><strong>Question-How many databases can be added in an AOAG configuration?</strong></p>
<p><strong>Answer- </strong>The actual number of databases you add to the AOAG depends on the available worker threads on the server, as such there is no enforced limit for databases as well.</p>
<p><strong>Question- I have an AOAG configuration between an FCI and standalone server. Why AOAG is not able to perform automatic failover?</strong></p>
<p><strong>Answer- </strong>Automatic Failover is not supported for Availability groups that are configured on Failover Cluster Instances. That is why AOAG is not able to perform automatic failover on such configurations.</p>
<p><strong>Question-What are basic prerequisites for a database to be a part of AOAG?</strong></p>
<p><strong>Answer-</strong>Below are the list of prerequisites for a database that needs to be added in Availability Group.</p>
<ol>
<li>Database should be Online for Read-Write Operation.</li>
<li>Database must be in Full Recovery Model.</li>
<li>Database should be a user database because you cannot configure AOAG for system database.</li>
</ol>
<p><strong>Question-Can we configure database mirroring on a database that is part of Availability group?</strong></p>
<p><strong>Answer- </strong>No, we cannot configure database mirroring for an availability database.</p>
<p><strong>Question- Can we configure Log shipping for a database that is part of Availability Group?</strong></p>
<p><strong>Answer-</strong>Yes, we can configure Log shipping for an availability database.</p>
<p><strong>Question- Can we configure Replication for a database that is part of availability group?</strong></p>
<p><strong>Answer- </strong>Yes, we can configure replication of a AOAG database.</p>
<p><strong>Question- Can we configure AOAG for master database or any system databases?</strong></p>
<p><strong>Answer- </strong>No, we cannot create AOAG for system database.</p>
<p><strong>Question- What is difference between Synchronous-commit mode and Asynchronous-commit mode?</strong></p>
<p><strong>Answer- </strong>Under synchronous-commit mode, primary replica waits for a synchronous-commit secondary replica to acknowledge that it has finished hardening the log before committing transactions on primary replica.</p>
<p>Under asynchronous-commit mode, the primary replica commits transactions without waiting for acknowledgement that an asynchronous-commit secondary replica has hardened the log.</p>
<p><strong>Question- What are the benefits of Readable Secondary Replicas?</strong></p>
<p><strong>Answer- </strong>Readable Secondary Replicas can be used for reporting purpose. We can divide some workload from primary replica and route all SELECT statements to run on readable secondary replicas. Even we can run database backups as well from these secondary replicas.</p>
<p><strong>Question- How can we run backups from secondary replicas?</strong></p>
<p><strong>Answer- </strong>Performing backups on a secondary replica to offload the backup workload from the primary production server is a great benefit.  We can perform log backups and copy_only full backups from secondary replicas. We need to change Backup Preferences setting of AOAG configuration to run these backups from secondary replica. Read below attached article to <a href="http://techyaz.com/sql-server/alwayson/understanding-sql-server-backup-databases-availability-group/"><strong><u>understand AOAG Backup Preferences and how it works</u></strong></a>.</p>
<p><strong>Question-If one of your availability database got corrupted or showing in suspect mode, will AOAG initiate failover to secondary replica?</strong></p>
<p><strong>Answer- </strong>No, failover will not be initiated due to any issue at database level.</p>
<p><strong>Question- Can we configure AOAG of a database that is running in bulk logged recovery model?</strong></p>
<p><strong>Answer- </strong>No, database must be in full recovery model to configure AOAG.</p>
<p><strong>Question- Can we redirect the read only transactions to secondary replica instead of primary replica?</strong></p>
<p><strong>Answer- </strong>Yes, we can specify the <em>read_only</em> intent in the connection string and add only secondary replicas to the <em>read_only_routing</em> list.</p>
<p><strong>Question- What is read intent option?</strong></p>
<p><strong>Answer- </strong>If Read Intent option is set that means read-only connections are allowed to secondary databases on secondary replica.</p>
<p><strong>Question- What is default settings for read intent or read access transactions?</strong></p>
<p><strong>Answer- </strong>By default both read-write and read-intent access are allowed to the primary replica and no connections are allowed to secondary replicas of an Always On availability group.</p>
<p><strong>Question- Why is asynchronous commit mode is faster than synchronous commit mode?</strong></p>
<p><strong>Answer- </strong>Asynchronous-commit is faster because primary replica does not wait for any acknowledgement received from secondary replica to harden the logs there. Read More about these in attached article <a href="http://techyaz.com/sql-server/alwayson/alwayson-availability-group/"><strong><u>Always On Availability Group</u></strong></a><strong><u>.</u></strong></p>
<p><strong>Question- Is it necessary to have shared storage for AOAG?</strong></p>
<p><strong>Answer- </strong>No, it is not necessary to have shared storage of AOAG.</p>
<p><strong>Question- Can we configure AOAG without windows cluster?</strong></p>
<p><strong>Answer- </strong>We can create clusterless AOAG in SQL Server 2017 but rest of all previous version you must have windows cluster to create AOAG.</p>
<p><strong>Question- Can we restore a database participating in Always on Availability Group?</strong></p>
<p><strong>Answer- </strong>No, we cannot restore a database that is participated in AOAG. Neither we can delete or drop these databases.</p>
<p><strong>Question-</strong> <strong>How can we Restore a database that is participated in AOAG?</strong></p>
<p><strong>Answer-</strong> To Restore a database that is part of Availability Group, first we need to remove it from availability group. Once database will be removed from availability group, you can restore it and later you can add it to the same availability group. Read attached article to learn <a href="http://techyaz.com/sql-server/alwayson/restore-database-participating-alwayson-availability-group/"><strong><u>how to restore a database that is part of AOAG</u></strong>.</a></p>
<p><strong>Question- What will be the difference between configuring AOAG in multi-subnet network and same subnet network?</strong></p>
<p><strong>Answer- </strong>When we need to configure AOAG between multi-subnet cluster, we need to have one IP from each subnet to configure Listener whereas we need only one IP for listener in same subnet<strong>. </strong></p>
<p>I hope you like this set of SQL Server Interview Questions &amp; Answers on Alwayson Availability Group. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook page</a> and<u> </u><a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p><em><strong><span style="color: #800000;">Read More Interview Questions:</span></strong></em></p>
<ul>
<li><strong><a href="http://techyaz.com/interview-questions/sql-server-interview-questions-answers-architecture/" target="_blank" rel="noopener">SQL Server Interview Q&amp;A on Architecture</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/sql-server-interview-questions-answers-indexes/" target="_blank" rel="noopener">SQL Server Interview Q&amp;A on Indexes</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/backup-recovery/sql-server-backup-recovery-interview-questions-answers/" target="_blank" rel="noopener">MSSQL Backup and Recovery Interview Q&amp;A</a></strong></li>
<li><strong><a href="http://techyaz.com/interview-questions/sql-server-dba-interview-questions-answers/" target="_blank" rel="noopener">SQL Server General DBA Interview Q&amp;A</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/interview-questions/sql-server-interview-questions/sql-server-alwayson-interview-questions-answers/">SQL Server Alwayson Interview Questions &#038; Answers</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/interview-questions/sql-server-interview-questions/sql-server-alwayson-interview-questions-answers/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>How to Upgrade or Patch Alwayson Availability Group Instances?</title>
		<link>https://techyaz.com/sql-server/alwayson/upgrade-patch-availability-group-instances/</link>
					<comments>https://techyaz.com/sql-server/alwayson/upgrade-patch-availability-group-instances/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Mon, 05 Feb 2018 13:44:59 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[AOAG]]></category>
		<category><![CDATA[availability group]]></category>
		<category><![CDATA[Availability Group Upgrade]]></category>
		<category><![CDATA[SQL Server Patching]]></category>
		<category><![CDATA[SQL Server Upgrade]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1737</guid>

					<description><![CDATA[<p>If you are planning to upgrade your SQL Server instance that hosts an Always on Availability Group (AOAG) to a latest version SQL Server 2017 or you are planning to patch Alwayson Availability Group instances, then you should plan it&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/upgrade-patch-availability-group-instances/">How to Upgrade or Patch Alwayson Availability Group Instances?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>If you are planning to upgrade your SQL Server instance that hosts an <strong><a href="http://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">Always on Availability Group</a></strong> (AOAG) to a latest version SQL Server 2017 or you are planning to patch Alwayson Availability Group instances, then you should plan it carefully to minimize downtime and any risk during these activities. I would suggest you read this article before upgrading or patching SQL Server instances that has Always on Availability Group configured.</p>
<p><span style="color: #000000;"><strong>NOTE:</strong> <strong>First Test this solution in Lower Life Cycle environment then deploy in Production.</strong></span></p>
<h3><span style="color: #333399;">Points to Remember </span></h3>
<p><img loading="lazy" decoding="async" class="size-full wp-image-1740 alignright" src="http://techyaz.com/wp-content/uploads/2018/02/Upgrade-AOAG-min.png" alt="Upgrade or Patch SQL Server AOAG Instances" width="300" height="300" srcset="https://techyaz.com/wp-content/uploads/2018/02/Upgrade-AOAG-min.png 300w, https://techyaz.com/wp-content/uploads/2018/02/Upgrade-AOAG-min-150x150.png 150w, https://techyaz.com/wp-content/uploads/2018/02/Upgrade-AOAG-min-160x160.png 160w, https://techyaz.com/wp-content/uploads/2018/02/Upgrade-AOAG-min-320x320.png 320w" sizes="auto, (max-width: 300px) 100vw, 300px" />Below are important points you should always keep in mind while you are planning or upgrading SQL Server Instances that has Alwayson Availability Group configured.</p>
<ol>
<li>All steps given in this article are limited to upgrading or patching SQL Server Instances that has AOAG configuration. It does not cover operating system upgrade.</li>
<li>Secondary replica will not be available for failover or for read-only operations during the upgrade process.</li>
<li>A higher version of a SQL Server instance cannot be added as a new replica to an existing AOAG. For example, a SQL Server 2016 replica cannot be added to an existing SQL Server 2014 AG.</li>
<li>Don’t upgrade primary replica instance before upgrading or updating any other secondary replica instance. An upgraded primary replica can no longer ship logs to any secondary replica. This may cause data loss as data movement to a secondary replica is suspended.</li>
</ol>
<h3><span style="color: #333399;">Upgrade or Patch SQL Server AOAG Instances &#8211; Prerequisites</span></h3>
<p>Make sure to meet and follow below prerequisites during planning the upgrade or patching of SQL Server Availability Group Instances.</p>
<ol>
<li>Review the Hardware and software requirements for latest SQL Server version on which you are planning to upgrade.</li>
<li>Make sure your application is supported on the latest version of SQL Server on which we are upgrading.</li>
<li>Make sure you can directly upgrade to the latest version of SQL Server 2017. If you are running with SQL Server 2005, you cannot go directly to SQL Server 2017. You must upgrade SQL Server 2005 to SQL Server 2012, 14 or 2016 before moving to latest version SQL Server 2017.</li>
<li>Choose Upgrade approach. As we know, there are three approaches to perform any SQL Server upgrade. In-place upgrade, Side by side upgrade and Rolling upgrade. As we are planning to upgrade AOAG instance so we will choose Rolling Upgrade method. Below are the details of other upgrade methods.</li>
</ol>
<ul>
<li><strong>In-Place Upgrade:</strong> SQL Server setup program upgrades the existing SQL Server installation by replacing the existing SQL Server bits with the new SQL Server bits and then upgrades each of the system and user databases. This method is frequently used in a development environment without a high-availability (HA) configuration or a non-mission critical production environment that can tolerate downtime and that is running on a recent hardware and software.</li>
<li><strong>Side by Side Upgrade:</strong> We build new machine and install all required software keeping source system running separately and then migrate all databases from source to this newly build machine. This method is effective in minimizing the downtime or in case if you need to roll back the upgrade.</li>
<li><strong>Rolling Upgrade:</strong> This method is used if your SQL Server Instances are required to upgrade in particular sequence. We use this approach if SQL Server is configured with Always on availability group, Database Mirroring, Log Shipping, Replication, Failover Cluster Instances, SQL Server Reporting Scale-out environment.</li>
</ul>
<ol start="5">
<li>Develop a rollback plan. Executing this plan will enable you to restore your original environment if you need to rollback.</li>
<li>Plan to test the upgrade on Lower life cycle first before deploying on productions.</li>
<li>Identify your databases if they are involved in Change Data Capture or Replication then we need to perform some addition activities. Have a look into last section of this article before performing the upgrades.</li>
</ol>
<h3><span style="color: #333399;">Upgrade or Patch AOAG Instances &#8211; Planning</span></h3>
<p>Here, I am explaining how to plan SQL Server Availability Group instance patching or upgrade to the newer version. Have a look at below points.</p>
<ol>
<li>Check database integrity on every availability databases that we are going to upgrade. Run DBCC CHECKDB to make sure there is no corruption on databases.</li>
<li>Run Full database backups for all your databases to secure a copy in case anything goes wrong we need it to restore databases.</li>
<li>Make sure Always on Availability Group is working fine and in Healthy state. You can test a manual failover whether it is working fine or not. If any issue during failover or AOAG not in healthy state, you must fix it before going with the upgrade.</li>
<li>Disable the backup job from the system that is going to upgrade (current secondary replica) and make sure to run it from the server that is online and acting as primary replica at the time upgrade will process. You can also<strong> <a href="http://techyaz.com/sql-server/sql-server-administration/understanding-sql-server-backup-databases-availability-group/" target="_blank" rel="noopener">change the Backup Preferences of AOAG</a> </strong>to run backups always from primary replica during this upgrade.</li>
<li>The sequence will be always upgrade the remote secondary replica instances first, then local secondary replica instances next, and the primary replica instance last. If you upgrade the primary replica instance without failing over the Always on availability Group to an upgraded instance with a secondary replica then client applications may suffer extended downtime during the upgrade on the primary replica instance. So better to follow the sequence to reduce downtime.</li>
<li>Always failover the AOAG to a synchronous-commit secondary replica instance. If you fail over to an asynchronous-commit secondary replica instance, you might lose some of your data.</li>
<li>Make sure that synchronization state of the failover target is SYNCHRONIZED during any failover of Availability Group.</li>
</ol>
<h3><span style="color: #333399;">Upgrading or Patching Always on Availability group Instances</span></h3>
<p>Now you have planned and understand the rolling upgrade methodology and the upgrade process of AOAG configured SQL Server Instances. Here, i will explain upgrade or patching of availability group instances into two sections. One has multiple secondary replicas and another have only one secondary replica that also in remote location for DR purpose.</p>
<h5><span style="color: #ff6600;">If Availability Group has Local and Remote Secondary Replicas</span></h5>
<p>Here, I am giving a standard process to perform the upgrade on a configuration that has local secondary replicas as well as remote secondary replicas for DR solution. You can consider it as four replica environments where one replica is hosted on local datacenter and remaining other replicas are hosted on one or multiple remote sites for DR purpose. I have illustrated this configuration in below screenshot where we have one local replica and two remote secondary replicas.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1741 size-large" src="http://techyaz.com/wp-content/uploads/2018/02/1-min-1024x499.png" alt="AOAG with four replicas" width="1024" height="499" srcset="https://techyaz.com/wp-content/uploads/2018/02/1-min-1024x499.png 1024w, https://techyaz.com/wp-content/uploads/2018/02/1-min-300x146.png 300w, https://techyaz.com/wp-content/uploads/2018/02/1-min-768x374.png 768w, https://techyaz.com/wp-content/uploads/2018/02/1-min.png 1873w" sizes="auto, (max-width: 1024px) 100vw, 1024px" />Let’s start with upgrade process considering above scenario.</p>
<ol>
<li>Verify you have full database backup for all availability databases. If you don’t have full backups, make sure to run it before this upgrade to protect your data.</li>
<li>Now, change automatic failover on synchronous-commit replicas to manual (between replica A and B) to prevent any accidently failovers during upgrade process.</li>
<li>Test a manual failover and make sure that it is working fine.</li>
<li>Now upgrade all remote secondary replica instances (Replica C and D) running with asynchronous-commit secondary replicas.</li>
<li>Upgrade the all local replica secondary instances (Replica B) that are not currently running the primary replica.</li>
<li>Once all secondary replicas have been upgraded and you left out only with primary replica to upgrade then manually fail over the AG to a local synchronous-commit secondary replica. Here, Replica B will be acting as primary replica now.</li>
<li>Upgrade or update the local replica instance that formerly hosted the primary replica (Replica A).</li>
<li>Verify SQL Server version on all replicas to make sure every instance is upgraded. Failback current primary replica from replica B to A that was primary replica initially.</li>
<li>Now, configure automatic failover partners from manual failover (between replica A and B) as we did in step 2 to prevent unwanted failover during upgrade process.</li>
<li>Perform a failover testing on upgraded instances to make sure everything is working fine.</li>
</ol>
<h5><span style="color: #ff6600;">If Availability Group has only One Secondary Replica for DR solution</span></h5>
<p>If you have configured Availability group only to achieve DR solution having single remote secondary replica with asynchronous-commit mode then you need to follow little different approach for upgrade or apply patches.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1742 " src="http://techyaz.com/wp-content/uploads/2018/02/2-min-1024x507.png" alt="AOAG with one remote secondary replica" width="705" height="349" srcset="https://techyaz.com/wp-content/uploads/2018/02/2-min-1024x507.png 1024w, https://techyaz.com/wp-content/uploads/2018/02/2-min-300x148.png 300w, https://techyaz.com/wp-content/uploads/2018/02/2-min-768x380.png 768w, https://techyaz.com/wp-content/uploads/2018/02/2-min.png 1271w" sizes="auto, (max-width: 705px) 100vw, 705px" /></p>
<p>You can follow below step by step method to upgrade or Patch your AOAG instances that has only one secondary replica that also on remote site for DR purpose.</p>
<ol>
<li>Verify you have full database backups to secure your data.</li>
<li>Upgrade your remote secondary replica that is hosted for DR.</li>
<li>Once remote secondary replica is upgraded or Patched, make sure to change the data transfer mode from asynchronous-commit to synchronous-commit to prevent any potential data loss during failover. Do not initiate failover until synchronization state will become SYNCHRONIZED.</li>
<li>Initiate the failover once data is synchronized between both replicas. And once failover will be done again change the data transfer more to asynchronous-commit mode to avoid any data latency issue to application users.</li>
<li>Upgrade the current secondary replica (Previous Primary Replica).</li>
<li>Once both replicas will be upgraded, you can again change the data transfer mode from asynchronous-commit to synchronous-commit to prevent any potential data loss during failover. Do not initiate failover until synchronization state will become SYNCHRONIZED.</li>
<li>Failover the AOAG to remote secondary replica and change the data transfer mode to asynchronous-commit.</li>
<li>Verify details about SQL Server version.</li>
</ol>
<h3><span style="color: #333399;">Additional steps for CDC (change data capture) and Replication</span></h3>
<p>I have described in point no 7 of Prerequisite section to identify databases that are participating in change data capture or in Replication. I have mentioned that because we need to take some additional steps for such databases post upgrade or patching activity.</p>
<ol>
<li>Upgrade each secondary replica as described in above sections.</li>
<li>After all secondary replicas have been upgraded, fail over the AG to an upgraded instance.</li>
<li>Execute below T-SQL statement on the instance that hosts the primary replica:</li>
</ol>
<pre><span style="color: #0000ff;"><strong>EXECUTE [master].[sys].[sp_vupgrade_replication];</strong></span></pre>
<ol start="4">
<li>Upgrade SQL Server instance that was originally configured as primary replica.</li>
</ol>
<p>I hope you like this article. Please Like, Comment, Share &amp; Subscribe to this website to get new articles directly into your inbox. You can also follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <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/upgrade-patch-availability-group-instances/">How to Upgrade or Patch Alwayson Availability Group Instances?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/alwayson/upgrade-patch-availability-group-instances/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Restore a Database Participating in Alwayson Availability Group</title>
		<link>https://techyaz.com/sql-server/alwayson/restore-database-participating-alwayson-availability-group/</link>
					<comments>https://techyaz.com/sql-server/alwayson/restore-database-participating-alwayson-availability-group/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Wed, 31 Jan 2018 10:39:33 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[Backup & Recovery]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[availability group]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[restore]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1687</guid>

					<description><![CDATA[<p>Sometimes, we need to restore a database that is part of always on availability group to fulfill our business needs. There might be several reasons behind doing this. Restore a database in availability group is different than restoring a normal&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/restore-database-participating-alwayson-availability-group/">Restore a Database Participating in Alwayson Availability Group</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Sometimes, we need to restore a database that is part of always on availability group to fulfill our business needs. There might be several reasons behind doing this. Restore a database in availability group is different than restoring a normal database. <img loading="lazy" decoding="async" class="size-full wp-image-1698 alignright" src="http://techyaz.com/wp-content/uploads/2018/01/Restore-a-database-in-Availability-Group.png" alt="Restore a database in Availability Group" width="200" height="200" srcset="https://techyaz.com/wp-content/uploads/2018/01/Restore-a-database-in-Availability-Group.png 200w, https://techyaz.com/wp-content/uploads/2018/01/Restore-a-database-in-Availability-Group-150x150.png 150w, https://techyaz.com/wp-content/uploads/2018/01/Restore-a-database-in-Availability-Group-160x160.png 160w, https://techyaz.com/wp-content/uploads/2018/01/Restore-a-database-in-Availability-Group-320x320.png 320w" sizes="auto, (max-width: 200px) 100vw, 200px" />You cannot restore Availability Group database directly as you do for other databases. You will get below error message while doing this.</p>
<p><span style="color: #ff0000;"><em>The operation cannot be performed on database “DBNAME” because it is involved in a database mirroring session or an availability group. Some operations are not allowed on a database that is participating in a database mirroring session or in an availability group.</em></span></p>
<p>As per above error details, we cannot restore a database that is part of always on availability group directly. Here, I will explain step by step process to restore such databases.</p>
<h3><span style="color: #333399;">Restore Databases in Availability Group</span></h3>
<p>If you need to restore an availability group database, you need to first evict that database from availability group and then restore that database and finally you can re-add it to the always on availability group. So, there are three steps involved in restoring an AOAG database.</p>
<ol>
<li>Remove identified database from Availability Group.</li>
<li>Restore that database.</li>
<li>Add database to Availability Group post restore operation.</li>
</ol>
<p>Let&#8217;s explain each steps in detail in order to restore an alwayson database.</p>
<h5><span style="color: #333399;">Remove Database from Availability Group</span></h5>
<p>First step is to remove the identified database from AOAG configuration to restore AOAG database. If you have to restore primary database in AOAG configuration then you should remove it from the primary replica that will automatically remove this database from AOAG configuration on secondary replica as well. You don’t need to separately remove secondary database from AOAG configuration. We can use below T-SQL statement to remove your primary database from AOAG configuration.</p>
<pre><span style="color: #0000ff;"><strong><span style="color: #008000;">--Change name of AG_Techyaz to your Availability group.
--Change database name from Techyaz to your primary database.</span>
ALTER AVAILABILITY GROUP AG_Techyaz REMOVE DATABASE Techyaz
</strong></span></pre>
<p>You can use GUI method as well to remove primary database from AOAG configuration. Read attached article to understand step by step process to<strong> <a href="http://techyaz.com/sql-server/remove-database-always-availability-group/" target="_blank" rel="noopener">remove a database from Availability group using GUI method.</a></strong></p>
<h5><span style="color: #333399;">Restore Database</span></h5>
<p>Once primary database will be removed from availability group, It will disappear from Availability Database folder showing under your Availability group name on both replicas. Now, next step will be database restore. Go ahead to restore your database.<br />
Here, we have to restore our database till 25 Jan 8 AM to<strong> <a href="http://techyaz.com/sql-server/point-in-time-recovery/" target="_blank" rel="noopener">recover point in time data</a></strong>. You can use your backup files as per your requirement. You can use either GUI method  in SSMS or T-SQL method to restore your database. Run below command to restore this database.</p>
<pre><span style="color: #008000;"><strong>--Restore primary database with the help of your backup file.</strong></span>
<span style="color: #0000ff;"><strong>RESTORE DATABASE Techyaz
FROM Disk= ‘F:\Backups\Techyaz_Full.bak’
WITH NORECOVERY, REPLACE;

<span style="color: #008000;">--Restore log backup till the time you want to recover the database.</span></strong></span>
<span style="color: #0000ff;"><strong>RESTORE LOG Techyaz
FROM Disk= ‘F:\Backups\Techyaz_TLog.trn’
WITH NORECOVERY, REPLACE, STOPAT = 'Jan 25, 2018 8:00 AM';

<span style="color: #008000;">--Bring database Online.</span></strong></span>
<span style="color: #0000ff;"><strong>RESTORE DATABASE Techyaz WITH RECOVERY;
</strong></span></pre>
<p>Once your database will be restored and comes online, we will go ahead to add this database to availability group again.</p>
<h5><span style="color: #333399;">Add database to Availability Group</span></h5>
<p>If you want to re-add this database to availability group then you must perform this step otherwise your database will not have any HA or DR capability. I would recommend to first prepare your corresponding secondary database before starting to add it to availability group. If you have a plan to prepare secondary database during adding it to availability group then the processing will take lot of time for huge databases.</p>
<p>To prepare the secondary database, you first need to take a<strong> <a href="http://techyaz.com/sql-server/understanding-sql-server-backups/" target="_blank" rel="noopener">full backup</a></strong> and immediate transaction log backup of your newly restored primary database. Copy these files to secondary replica and restore corresponding secondary database in norecovery mode. Below are high level steps you need to perform to add this database to AOAG configuration.</p>
<ol>
<li>Run full backup and immediate transaction log backup of primary database on primary replica.</li>
<li>Copy both full backup and log backup files to secondary replica.</li>
<li>Restore corresponding secondary database with the help of above copied files in norecovery mode with REPLACE option.</li>
<li>Now, run below T-SQL command to add this database to existing availability group. If you want to<strong> <a href="http://techyaz.com/sql-server/add-database-availability-group/" target="_blank" rel="noopener">add this database to existing AOAG configuration using GUI method</a></strong> in SSMS, visit attached link where I have described it in step by step process.</li>
</ol>
<pre style="padding-left: 30px;"><span style="color: #0000ff;"><strong><span style="color: #008000;">-- Connect to the server instance that hosts the primary replica.
-- Add an existing database to the availability group.</span>
ALTER AVAILABILITY GROUP AG_Techyaz ADD DATABASE Techyaz;
GO
</strong></span></pre>
<p>Make sure to configure your secondary database on secondary replica as we have done from step 1 to step 3.<br />
If you don’t want to add this database to availability group then you can ignore this step and use your database for transactions. You can also remove its corresponding database that is in restoring state on secondary replica. If you want to use that database from secondary replica for any purpose you can bring it online by running below command on secondary replica.</p>
<pre><span style="color: #008000;"><strong>--Run on secondary replica in case you don't want to configure this database in AOAG rather want to use it for transactions.
<span style="color: #0000ff;">RESTORE DATABASE Techyaz WITH RECOVERY;
</span></strong></span></pre>
<p>Now, you are done with database restore in Alwayson Availability Group. Validate it by launching dashboard report or looking in to SSMS to get AOAG health for newly added or restored database.<br />
I hope you like this article. Please comments us and follow our <a href="https://www.facebook.com/Techyaz/">facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter</a> handle to get latest updates.</p>
<p><span style="color: #800000;"><em><strong>Read More:</strong></em></span></p>
<ul>
<li><strong><a href="http://techyaz.com/sql-server/sql-server-administration/understanding-sql-server-backup-databases-availability-group/" target="_blank" rel="noopener">Understanding Backup Preferences in Alwayson Availability Group</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/alwayson/fix-aoag-listener-error-19471-kerberos-status-showing-handle-invalid/" target="_blank" rel="noopener">AOAG Listener Error 19471: The handle is Invalid</a></strong></li>
<li><strong><a href="http://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 Showing in Resolving State after AOAG Automatic Failover</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/fix-error-976/" target="_blank" rel="noopener">Fix Error 976: Cannot Connect to Secondary Replica</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/restore-database-participating-alwayson-availability-group/">Restore a Database Participating in 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/restore-database-participating-alwayson-availability-group/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>How to Add a New Database to Always On Availability Group?</title>
		<link>https://techyaz.com/sql-server/alwayson/add-database-availability-group/</link>
					<comments>https://techyaz.com/sql-server/alwayson/add-database-availability-group/#respond</comments>
		
		<dc:creator><![CDATA[Ganesh Bekkinkeri]]></dc:creator>
		<pubDate>Mon, 22 Jan 2018 11:33:16 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[availability group]]></category>
		<category><![CDATA[SQL Server 2017]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1624</guid>

					<description><![CDATA[<p>Adding or Removing databases from availability group is not day to day task but we need to perform such activities whenever it required. You can read attached article to learn how to remove database from availability group. Here, I will&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/add-database-availability-group/">How to Add a New Database to Always On Availability Group?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Adding or Removing databases from <a href="http://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">availability group</a> is not day to day task but we need to perform such activities whenever it required. You can read attached article to learn <a href="http://techyaz.com/sql-server/remove-database-always-availability-group/" target="_blank" rel="noopener">how to remove database from availability group</a>. Here, I will explain how to add database to an existing Always On availability group by using SSMS (SQL Server Management Studio) and Transact-SQL.</p>
<p>Before starting this exercise, make sure that primary and secondary replicas are accessible to each other and existing AOAG configuration is working fine and in healthy state. You must be connected to the server instance that hosts the primary replica to add a database to availability group.</p>
<h4><span style="color: #333399;">Add Database to Availability Group using GUI in SSMS</span></h4>
<p>First, we need to configure the corresponding secondary database on each server instance that hosts a secondary replica to save <em>add database wizard</em> processing time. You just need to run the full backup and immediate transaction log backup of the database on primary replica that has been identified to add to the availability group and then restore it to corresponding secondary replica.</p>
<p>Although it is not mandatory step to do it before adding the database to availability group as this can be done during adding database to availability group as well. But it is recommended to prepare your secondary databases on secondary replica before adding it to availability group. Let’s start with configuring secondary replicas followed by adding them to AOAG configuration.</p>
<ol>
<li>First run the full backup and immediate transaction log backup of the database that has been identified to add to the availability group on primary replica.</li>
<li>Once backups are completed on primary replica for to-be added database, copy these backups to your secondary replica and restore it with same name in no recovery mode if you want to keep your secondary database inaccessible.</li>
<li>Once database will be restored/ synced on secondary replicas, we will start adding this database to existing AOAG configuration using Add Database to Availability Group Wizard on primary replica.</li>
<li>Launch SQL Server Management Studio. Connect to the server instance that hosts the primary replica, and expand the server tree.</li>
<li>Expand the Always On High Availability folder followed by Availability Groups.</li>
<li>Right-click the availability group name, and select one of the following commands:
<ul>
<li>To launch the Add Database to Availability Group Wizard, select the <strong>Add Database.</strong></li>
<li>To add one or more databases by specifying them in the <strong>Availability Group Properties </strong>dialog box, select the <strong>Properties.<img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1626" src="http://techyaz.com/wp-content/uploads/2018/01/1-Add-Database-to-AOAG-min.jpg" alt="Add Database" width="352" height="222" srcset="https://techyaz.com/wp-content/uploads/2018/01/1-Add-Database-to-AOAG-min.jpg 352w, https://techyaz.com/wp-content/uploads/2018/01/1-Add-Database-to-AOAG-min-300x189.jpg 300w" sizes="auto, (max-width: 352px) 100vw, 352px" /></strong></li>
</ul>
</li>
<li>Once you click on <strong>Add Database…</strong> option to add database to existing AOAG configuration, an Introduction wizard will appear that will very similar to the one you might have seen during creating AOAG on your SQL Server Instance.</li>
<li>Next screen will come to select databases to proceed with adding them in to AOAG configuration.</li>
<li>Third window will come to select initial data synchronization option. Here you should be careful as if you have already configured secondary databases as we did in step 1 and step 2 then you need to select second option that is “<strong>Join Only</strong>”. If you haven’t configured your secondary database you can go with either first option that will backup the primary database and restore it to secondary replica during this processing only or third option in which you can configure secondary database later. If your database is big in size it will take lot much time to complete the processing.<img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1627" src="http://techyaz.com/wp-content/uploads/2018/01/2-join-only.jpg" alt="join only option in add database wizard" width="726" height="669" srcset="https://techyaz.com/wp-content/uploads/2018/01/2-join-only.jpg 726w, https://techyaz.com/wp-content/uploads/2018/01/2-join-only-300x276.jpg 300w" sizes="auto, (max-width: 726px) 100vw, 726px" /></li>
<li>Follow rest of all windows by clicking at next button and once you will click at finish button on last window, your database will be added to existing availability group. You can see the status of this newly added database in to dashboard report or in SSMS.</li>
</ol>
<h4><span style="color: #333399;">Add a Database to Availability Group using T-SQL</span></h4>
<p>As I have described n above section, first thing is to configure secondary database so we need to configure the corresponding secondary database on each server instance that hosts a secondary replica to save add database processing time. You just need to run the full backup and immediate transaction log backup of the database on primary replica that has been identified to add to the availability group and then restore it to corresponding secondary replica. Once restore will be completed then follow below steps to add this database to availability group.</p>
<ol>
<li style="list-style-type: none;">
<ol>
<li>Connect to the server instance that hosts the server instance that hosts the primary replica.</li>
<li>Use the ALTER AVAILABILITY GROUP statement, as follows:</li>
</ol>
</li>
</ol>
<pre><span style="color: #008000;"><strong>--<em>AG_name</em> is the name of the availability group.
--<em>database_name</em> is the name of a database to be added to the group.
<span style="color: #0000ff;">ALTER AVAILABILITY GROUP <em>AG_name</em> ADD DATABASE <em>database_name</em>
</span></strong></span></pre>
<p>The following example adds the <em>Techyaz</em> database to the <em>AG_Techyaz</em> availability group.</p>
<pre><span style="color: #0000ff;"><strong><span style="color: #008000;">-- Connect to the server instance that hosts the primary replica.
-- Add an existing database to the availability group.</span>
ALTER AVAILABILITY GROUP AG_Techyaz ADD DATABASE Techyaz;
GO
</strong></span></pre>
<ol start="3">
<li>If you haven’t configured your secondary database then you need to configure it on each server instance that hosts a secondary replica after adding database to an availability group. If you already added it then you are done with adding your database to existing AOAG configuration. Validate it by launching dashboard report or looking in to SSMS.</li>
</ol>
<p>I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter</a> handle to get latest updates.</p>
<p><em><strong><span style="color: #800000;">Read More:</span></strong></em></p>
<ul>
<li><span style="color: #0000ff;"><strong><a style="color: #0000ff;" href="http://techyaz.com/sql-server/remove-database-always-availability-group/" target="_blank" rel="noopener">How to Remove a Database from AOAG configuration?</a></strong></span></li>
<li><span style="color: #0000ff;"><strong><a style="color: #0000ff;" href="http://techyaz.com/sql-server/alwayson/fix-aoag-listener-error-19471-kerberos-status-showing-handle-invalid/" target="_blank" rel="noopener">Fix AOAG Listener Issue: Error 19471 The handle is Invalid</a></strong></span></li>
<li><span style="color: #0000ff;"><strong><a style="color: #0000ff;" href="http://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 Showing in Resolving State after AOAG Automatic Failover</a></strong></span></li>
<li><span style="color: #0000ff;"><strong><a style="color: #0000ff;" href="http://techyaz.com/sql-server/sql-server-administration/understanding-sql-server-backup-databases-availability-group/" target="_blank" rel="noopener">Understanding Backups in Alwayson Availability Group</a></strong></span></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/add-database-availability-group/">How to Add a New Database to Always On 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/add-database-availability-group/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Remove Database from Always On Availability Group?</title>
		<link>https://techyaz.com/sql-server/alwayson/remove-database-always-availability-group/</link>
					<comments>https://techyaz.com/sql-server/alwayson/remove-database-always-availability-group/#comments</comments>
		
		<dc:creator><![CDATA[Ganesh Bekkinkeri]]></dc:creator>
		<pubDate>Fri, 19 Jan 2018 11:45:20 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[availability group]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1618</guid>

					<description><![CDATA[<p>This article describes how to remove availability database(s) from an Always on Availability Group by using SQL Server Management Studio and Transact-SQL. Here, we will be removing primary database from availability group that will remove corresponding secondary database from AOAG&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/remove-database-always-availability-group/">How to Remove Database from Always On Availability Group?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This article describes how to remove availability database(s) from an <a href="http://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">Always on Availability Group</a> by using SQL Server Management Studio and Transact-SQL. Here, we will be removing primary database from availability group that will remove corresponding secondary database from AOAG configuration as well.</p>
<p>You must be connected to primary replica of AOAG configuration to perform this activity. If you connect to secondary replica to remove availability databases from AOAG configuration then only secondary database from AOAG configuration will be removed. If you remove availability database or say primary database from AOAG configuration on primary replica then it will remove availability databases from always on availability group from both replicas.</p>
<h4><span style="color: #333399;">Remove Availability Database from AOAG using SSMS</span></h4>
<ol>
<li>Launch SQL Server Management Studio. Connect to the SQL Server instance that hosts the primary replica of the database or databases to be removed, and expand the server tree.</li>
<li>Expand the <strong>Always On High Availability </strong>folder followed by <strong>Availability Groups</strong> folder showing in SSMS.</li>
<li>You can see your <strong>Availability Group Name</strong> post expanding <strong>Availability Group</strong> folder. Now expand this folder as well.</li>
<li>Now you can see <strong>Availability Databases</strong> folder. Expand this folder to see your availability databases.</li>
<li>Right-click the selected database or databases, and select <strong>Remove Database from Availability Group </strong>option as shown in below screenshot.<img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1620" src="http://techyaz.com/wp-content/uploads/2018/01/1-Right-Click-AOAG-DB.jpg" alt="Right Click on Primary Database" width="455" height="244" srcset="https://techyaz.com/wp-content/uploads/2018/01/1-Right-Click-AOAG-DB.jpg 455w, https://techyaz.com/wp-content/uploads/2018/01/1-Right-Click-AOAG-DB-300x161.jpg 300w" sizes="auto, (max-width: 455px) 100vw, 455px" /></li>
<li>You will be getting below window to proceed with the database removal from AOAG configuration. In the <strong>Remove Databases from Availability Group </strong>dialog box, to remove all the listed databases, click <strong>OK</strong>.<img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1621" src="http://techyaz.com/wp-content/uploads/2018/01/2-Remove-DB-AOAG.jpg" alt="Remove database from Availability Group window" width="781" height="589" srcset="https://techyaz.com/wp-content/uploads/2018/01/2-Remove-DB-AOAG.jpg 781w, https://techyaz.com/wp-content/uploads/2018/01/2-Remove-DB-AOAG-300x226.jpg 300w, https://techyaz.com/wp-content/uploads/2018/01/2-Remove-DB-AOAG-768x579.jpg 768w" sizes="auto, (max-width: 781px) 100vw, 781px" /></li>
<li>If you want to remove multiple databases from AOAG configuration, use the Object Explorer Details pane to view and select all the databases that you want to remove. You can also remove a single database either from the Object Explorer pane or the Object Explorer Details pane.</li>
</ol>
<p>This way you will remove primary database or say availability database from AOAG configuration. Data synchronization will be stopped for this database between both replicas the moment you remove it from availability group.</p>
<p>Later, you can decide whether you want to remove your secondary database or you want to use it by bringing it online. Make sure to change database name of secondary database to avoid any confusion because a copy of this database is already online with same name on primary replica.</p>
<h4><span style="color: #333399;">Remove Availability Database from AOAG using T-SQL</span></h4>
<p>Connect to SQL Server instance that are acting as primary replica of AOAG configuration.  Open New Query window to execute T-SQL query. Run below ALTER AVAILABILITY GROUP statement. Make sure to change the availability group name and availability database name that needs to be removed from AOAG configuration.</p>
<pre><span style="color: #0000ff;"><strong><span style="color: #008000;">--Availability_group_name is the name of the availability group
--Availability_db_name is the name of the database to be removed</span>
ALTER AVAILABILITY GROUP <em>Availibility_group_name</em> REMOVE DATABASE <em>Availability_db_name</em>
</strong></span></pre>
<p>I have executed below command to remove my availability database <strong>Techyaz</strong> from availability group name <strong>AG_Techyaz</strong> on primary replica.</p>
<pre><strong><span style="color: #0000ff;">ALTER AVAILABILITY GROUP AG_Techyaz REMOVE DATABASE Techyaz;
</span></strong></pre>
<p>You can see i have successfully execute this command in below screenshot.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1622" src="http://techyaz.com/wp-content/uploads/2018/01/3-Remove-DB-AOAG-TSQL.jpg" alt="Remove database from aoag using tsql" width="503" height="136" srcset="https://techyaz.com/wp-content/uploads/2018/01/3-Remove-DB-AOAG-TSQL.jpg 503w, https://techyaz.com/wp-content/uploads/2018/01/3-Remove-DB-AOAG-TSQL-300x81.jpg 300w" sizes="auto, (max-width: 503px) 100vw, 503px" /></p>
<p>Now, database will be removed from always on availability group and data synchronization will be stopped for this database between both replicas. Primary database will come online for read write and secondary database on secondary replica will be in restoring state. I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p><span style="color: #800000;"><em><strong>Read More:</strong></em></span></p>
<ul>
<li><span style="color: #0000ff;"><strong><a style="color: #0000ff;" href="http://techyaz.com/sql-server/alwayson/fix-aoag-listener-error-19471-kerberos-status-showing-handle-invalid/" target="_blank" rel="noopener">Fix AOAG Listener Error 19471</a></strong></span></li>
<li><span style="color: #0000ff;"><strong><a style="color: #0000ff;" href="http://techyaz.com/sql-server/sql-server-administration/understanding-sql-server-backup-databases-availability-group/" target="_blank" rel="noopener">Understanding Backup Preferences for Availability Databases</a></strong></span></li>
<li><span style="color: #0000ff;"><strong><a style="color: #0000ff;" href="http://techyaz.com/sql-server/troubleshooting/fixing-sap-connectivity-issue-aoag-automatic-failover/" target="_blank" rel="noopener">Fixing Application Connectivity Issue after Automatic Failover</a></strong></span></li>
<li><span style="color: #0000ff;"><strong><a style="color: #0000ff;" href="http://techyaz.com/sql-server/troubleshooting/fix-alwayson-error-35250-joining-database-secondary-replica-resulted-error/" target="_blank" rel="noopener">Error 35250: Joining database on Secondary Replica resulted in an error</a></strong></span></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/remove-database-always-availability-group/">How to Remove Database from Always On 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/remove-database-always-availability-group/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server Alwayson Error 35250: Joining database on Secondary Replica resulted in an error</title>
		<link>https://techyaz.com/sql-server/alwayson/fix-alwayson-error-35250-joining-database-secondary-replica-resulted-error/</link>
					<comments>https://techyaz.com/sql-server/alwayson/fix-alwayson-error-35250-joining-database-secondary-replica-resulted-error/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Mon, 09 Oct 2017 14:52:27 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[AOAG]]></category>
		<category><![CDATA[AOAG Listener]]></category>
		<category><![CDATA[endpoints]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[Listener Issue]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1048</guid>

					<description><![CDATA[<p>We got this Microsoft SQL Server error 35250 while configuring Alwayson Availability Group on one of the SQL Server Instance. There could be multiple reasons behind this SQL error 35250. You can find multiple solutions to fix this issue based&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/fix-alwayson-error-35250-joining-database-secondary-replica-resulted-error/">SQL Server Alwayson Error 35250: Joining database on Secondary Replica resulted in an error</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>We got this Microsoft SQL Server error 35250 while configuring <a href="https://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">Alwayson Availability Group</a> on one of the SQL Server Instance. There could be multiple reasons behind this SQL error 35250. You can find multiple solutions to fix this issue based on the nature of the issue. Here I will show you, how to fix this Alwayson error 35250 that came due to SQL Server service accounts.</p>
<h3><span style="color: #000080;">Microsoft SQL Server Error 35250</span></h3>
<p>We generally get this error whenever there is a communication issue between endpoints of both replicas or any replica unable to connect to the endpoints cause this error to generate. You will see below error texts if you are getting this issue.</p>
<p><span style="color: #ff0000;"><em>Alwayson Error 35250</em></span><br />
<span style="color: #ff0000;"><em>Failed to Join the database &#8216;DBName&#8217; to the availability group &#8216;AOAG-Name&#8217; on the availability replica &#8216;Availability Replica Name&#8217;</em></span></p>
<p>There are many reasons behind this error that we will discuss in next section. You might also get below text if you are using T-SQL.</p>
<div><span style="color: #ff0000;"><em>Msg 35250, Level 16, State 7, Line 1</em></span><br />
<span style="color: #ff0000;"><em> The connection to the primary replica is not active.  The command cannot be processed. (microsoft sql server, error: 35250)</em></span></div>
<p>Below is the screenshot of this error.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1049" src="http://techyaz.com/wp-content/uploads/2017/10/1-Error-AOAG.jpg" alt="Error 35250" width="669" height="399" srcset="https://techyaz.com/wp-content/uploads/2017/10/1-Error-AOAG.jpg 669w, https://techyaz.com/wp-content/uploads/2017/10/1-Error-AOAG-300x179.jpg 300w" sizes="auto, (max-width: 669px) 100vw, 669px" /></p>
<h3><span style="color: #000080;">Solution</span></h3>
<p>You should check below points based on attached article <a href="https://blogs.msdn.microsoft.com/alwaysonpro/2013/12/09/create-availability-group-fails-with-error-35250-failed-to-join-the-database/">MSDN link</a> whenever you get this error.</p>
<ul>
<li>Inbound Port 5022 Traffic is Blocked</li>
<li>Endpoint is not created or started</li>
<li>Endpoint permissions</li>
<li>SQL Server is not listening on port 5022</li>
</ul>
<p>But if everything is ok and you are still not able to diagnose this issue, then you should keep reading this article.</p>
<p>I checked everything and all was well on both replicas.  As we know that there should be Grant CONNECT permission on Always On endpoint. I was reassigning GRANT CONNECT on the endpoint and came to know that the SQL Server service account was not added to the SQL Server instance of secondary replica. That is why we faced this error. Let’s first get the endpoint and then we will run Grant connect on endpoint to see the issue. Run below command to get the name of endpoint that is using in this alwayson configuration.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1050" src="http://techyaz.com/wp-content/uploads/2017/10/2-Get-the-endpoint-name.jpg" alt="get endpoint name" width="775" height="227" srcset="https://techyaz.com/wp-content/uploads/2017/10/2-Get-the-endpoint-name.jpg 775w, https://techyaz.com/wp-content/uploads/2017/10/2-Get-the-endpoint-name-300x88.jpg 300w, https://techyaz.com/wp-content/uploads/2017/10/2-Get-the-endpoint-name-768x225.jpg 768w" sizes="auto, (max-width: 775px) 100vw, 775px" /></p>
<p>We can see endpoint name is <strong>hadr_endpoint</strong>. Now run below command to grant connect permission on endpoint hadr_endpoint. The login name is the service account that is used to run SQL Server services.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1051" src="http://techyaz.com/wp-content/uploads/2017/10/3-Run-cmd-togrant-connect.jpg" alt="grant connect on endpoint" width="751" height="179" srcset="https://techyaz.com/wp-content/uploads/2017/10/3-Run-cmd-togrant-connect.jpg 751w, https://techyaz.com/wp-content/uploads/2017/10/3-Run-cmd-togrant-connect-300x72.jpg 300w" sizes="auto, (max-width: 751px) 100vw, 751px" /></p>
<p>You can see, error is saying that the account doesn’t exist on SQL Server.</p>
<p>Although you can directly check this step in SSMS as a prerequisite once error is reported. The SQL Server service accounts should be added to SQL Server Instances. I checked this account on both replica and found that it was very much there on primary replica but it was not created on secondary replica. That was the missing point which caused this issue.</p>
<p>Now create this service account on secondary replica as well or where it was missing on any of the replica then you can try to re-add the database to the AOAG configuration. This time your database will be added to the AOAG configuration. If you are facing issue during joining database to the AOAG configuration then you can remove the existing AOAG and reconfigure it.</p>
<p>Your issue will be fixed if you check and follow all above suggested points including the one mentioned in MSDN link. 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><span style="color: #800000;"><strong>Read More:</strong></span></em></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-976/" target="_blank" rel="noopener">Fix AOAG Error 976:Cannot Connect to Secondary Replica</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">How to fix AOAG Listener Issue 19471: The handle is Invalid</a></strong></li>
<li><strong><a 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 that came during AOAG Configuration</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 endpoints</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fixing-sap-connectivity-issue-aoag-automatic-failover/" target="_blank" rel="noopener">Fixing Application connectivity Issue after AOAG automatic failover</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/fix-alwayson-error-35250-joining-database-secondary-replica-resulted-error/">SQL Server Alwayson Error 35250: Joining database on Secondary Replica resulted in an error</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/alwayson/fix-alwayson-error-35250-joining-database-secondary-replica-resulted-error/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Fix AOAG Listener Error 19471: Kerberos Status is Showing The handle is Invalid</title>
		<link>https://techyaz.com/sql-server/alwayson/fix-aoag-listener-error-19471-kerberos-status-showing-handle-invalid/</link>
					<comments>https://techyaz.com/sql-server/alwayson/fix-aoag-listener-error-19471-kerberos-status-showing-handle-invalid/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Thu, 28 Sep 2017 13:44:47 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[Clustering]]></category>
		<category><![CDATA[Database Mirroring]]></category>
		<category><![CDATA[AOAG]]></category>
		<category><![CDATA[AOAG Listener]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[Listener Issue]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=985</guid>

					<description><![CDATA[<p>I was configuring AlwaysOn Availability Group between two replicas. Everything was configured successfully but Listener was failed to create with an error 19471. I have already explained how to fix listener error 19471 in attached article but this has not&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/fix-aoag-listener-error-19471-kerberos-status-showing-handle-invalid/">Fix AOAG Listener Error 19471: Kerberos Status is Showing The handle is Invalid</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I was configuring <a href="https://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">AlwaysOn Availability Group</a> between two replicas. Everything was configured successfully but Listener was failed to create with an error 19471. I have already explained <a 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">how to fix listener error 19471</a> in attached article but this has not helped me. Here i will explain another aspect of this error along with their fix.</p>
<h3><span style="color: #000080;">AlwaysOn Listener Error 19471</span></h3>
<p>When i checked the <strong>AlwaysOn High Availability</strong> folder in SSMS on any of the replica, everything was working fine. AOAG was configured successfully and working fine but listener was not configured due to below listener error 19471. You can see this in below screenshot.</p>
<div class="codediv"><strong><span class="kwrd" style="color: red;">Create failed for Availability Group Listener &#8216;Listener-Name&#8217;. (Error: 19471)<br />
</span></strong></div>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-987" src="http://techyaz.com/wp-content/uploads/2017/09/1-listenerIssue.jpg" alt="Listener Error 19471" width="673" height="371" srcset="https://techyaz.com/wp-content/uploads/2017/09/1-listenerIssue.jpg 673w, https://techyaz.com/wp-content/uploads/2017/09/1-listenerIssue-300x165.jpg 300w" sizes="auto, (max-width: 673px) 100vw, 673px" /></p>
<p>I tried creating Listener name using &#8220;<strong>Add Listener&#8230;</strong>&#8221; wizard in SSMS but failed with same error. I observed root cause of this issue during following steps given in my last article that i have attached in first paragraph. Make sure to clear all entries from DNS for your listener Name and IP, if there is any.</p>
<h3><span style="color: #000080;">Kerberos Status: The handle is Invalid</span></h3>
<p>First we will create a Client Access Point(CAP) in FCM for this listener name to check the status of NetBIOS, DNS &amp; Kerberos that will help us to go deeper inside the issue.</p>
<ol>
<li>Launch <strong>Failover Cluster Manager</strong> and click on <strong>Roles</strong> tab from left side pane. Here you can see your availability group role in right side pane.</li>
<li>Right click on this role and select &#8220;<strong>Add Resources</strong>&#8221; then &#8220;<strong>Client Access Point</strong>&#8220;.</li>
<li>Enter the <strong>Listener name</strong> and its <strong>IP address</strong> and click on <strong>Next</strong> button to proceed.</li>
<li>Click on <strong>Finish</strong> button of final screen to create the <strong>Listener Client Access Point</strong> in FCM.</li>
<li>Once CAP will be created in FCM, it will be in <strong>Offline</strong> state. <strong>Right click</strong> on listener CAP and click on &#8220;<strong>Bring Online</strong>&#8221; to bring it online. You can see Listener IP comes online but Listener name still shows in offline state.</li>
</ol>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-988" src="http://techyaz.com/wp-content/uploads/2017/09/2-CAL.jpg" alt="client access point in failover cluster manager" width="799" height="481" srcset="https://techyaz.com/wp-content/uploads/2017/09/2-CAL.jpg 799w, https://techyaz.com/wp-content/uploads/2017/09/2-CAL-300x181.jpg 300w, https://techyaz.com/wp-content/uploads/2017/09/2-CAL-768x462.jpg 768w" sizes="auto, (max-width: 799px) 100vw, 799px" /></p>
<p>Now double click on listener client access point or right click on it and choose properties. You will get CAP property window as shown in below image.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-989" src="http://techyaz.com/wp-content/uploads/2017/09/3-CAL-Property.jpg" alt="CAP Property" width="417" height="499" srcset="https://techyaz.com/wp-content/uploads/2017/09/3-CAL-Property.jpg 417w, https://techyaz.com/wp-content/uploads/2017/09/3-CAL-Property-251x300.jpg 251w" sizes="auto, (max-width: 417px) 100vw, 417px" /></p>
<p>You can see, this time issue is with <strong>Kerberos status</strong> that is showing as &#8220;<strong>The handle is invalid</strong>&#8220;. Earlier DNS status was not ok in <a 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">last article</a>.</p>
<h3><span style="color: #000080;">Fix Kerberos Status <em>The handle is invalid</em></span></h3>
<p>When i look into Active Directory server, i found that listener name object was showing as disabled as shown in below image.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-990" src="http://techyaz.com/wp-content/uploads/2017/09/4-AD-1024x124.jpg" alt="listener name is showing as disabled" width="1024" height="124" srcset="https://techyaz.com/wp-content/uploads/2017/09/4-AD-1024x124.jpg 1024w, https://techyaz.com/wp-content/uploads/2017/09/4-AD-300x36.jpg 300w, https://techyaz.com/wp-content/uploads/2017/09/4-AD-768x93.jpg 768w, https://techyaz.com/wp-content/uploads/2017/09/4-AD.jpg 1137w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<p>I decided to enable it and then to create listener. <strong>Right click</strong> on listener name object on AD that are showing in disable mode with down arrow and click on &#8220;<strong>Enable Account</strong>&#8221; button as per below image.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-991" src="http://techyaz.com/wp-content/uploads/2017/09/5-AD.jpg" alt="Enable listener name object in AD" width="880" height="176" srcset="https://techyaz.com/wp-content/uploads/2017/09/5-AD.jpg 880w, https://techyaz.com/wp-content/uploads/2017/09/5-AD-300x60.jpg 300w, https://techyaz.com/wp-content/uploads/2017/09/5-AD-768x154.jpg 768w" sizes="auto, (max-width: 880px) 100vw, 880px" /></p>
<p>You can see, listener name account is enabled and down arrow that are showing during disabled mode is not showing now.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-992" src="http://techyaz.com/wp-content/uploads/2017/09/6-AD.jpg" alt="Enable listener name object in AD" width="666" height="71" srcset="https://techyaz.com/wp-content/uploads/2017/09/6-AD.jpg 666w, https://techyaz.com/wp-content/uploads/2017/09/6-AD-300x32.jpg 300w" sizes="auto, (max-width: 666px) 100vw, 666px" /></p>
<p>Once you enabled the listener name object in AD, bring your listener CAP online in FCM. Right click on listener client access point and click on bring online. You can see listener CAP is showing online now.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-993" src="http://techyaz.com/wp-content/uploads/2017/09/7-CAL-online.jpg" alt="Bring CAP Online" width="779" height="363" srcset="https://techyaz.com/wp-content/uploads/2017/09/7-CAL-online.jpg 779w, https://techyaz.com/wp-content/uploads/2017/09/7-CAL-online-300x140.jpg 300w, https://techyaz.com/wp-content/uploads/2017/09/7-CAL-online-768x358.jpg 768w" sizes="auto, (max-width: 779px) 100vw, 779px" /></p>
<p>When you will launch its property window, you will see the status of NetBIOS, DNS and Kerberos are showing OK now. Close this property window to proceed.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-994" src="http://techyaz.com/wp-content/uploads/2017/09/8-CAL-Property.jpg" alt="CAP Property" width="419" height="491" srcset="https://techyaz.com/wp-content/uploads/2017/09/8-CAL-Property.jpg 419w, https://techyaz.com/wp-content/uploads/2017/09/8-CAL-Property-256x300.jpg 256w" sizes="auto, (max-width: 419px) 100vw, 419px" /><br />
Now we will follow same process that we have followed in my last article. We will remove this listener CAP from FCM and then add listener in AOAG in SSMS. Right click on <strong>CAP</strong> in FCM and click on <strong>Remove</strong> button to delete it.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-995" src="http://techyaz.com/wp-content/uploads/2017/09/9-Remove-CAL.jpg" alt="Remove CAP" width="563" height="289" srcset="https://techyaz.com/wp-content/uploads/2017/09/9-Remove-CAL.jpg 563w, https://techyaz.com/wp-content/uploads/2017/09/9-Remove-CAL-300x154.jpg 300w" sizes="auto, (max-width: 563px) 100vw, 563px" /></p>
<p>Once CAP will be removed, launch the <strong>SSMS</strong> and connect to your <strong>Primary Replica</strong>. Expand <strong>AlwaysOn High Availability</strong> folder followed by <strong>Availability Group</strong>. Now you can right click on <strong>Availability Group Listeners</strong> and click on <strong>Add Listener</strong> option. You will get below window to configure it.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-996" src="http://techyaz.com/wp-content/uploads/2017/09/10-Create-Listener.jpg" alt="Configure Listener" width="707" height="629" srcset="https://techyaz.com/wp-content/uploads/2017/09/10-Create-Listener.jpg 707w, https://techyaz.com/wp-content/uploads/2017/09/10-Create-Listener-300x267.jpg 300w" sizes="auto, (max-width: 707px) 100vw, 707px" /></p>
<p>Enter the <strong>listener name</strong>, <strong>port</strong> and then add its <strong>IP</strong>. Once you entered all details, click on <strong>OK</strong> button to create the listener. This time, listener will be created on all replicas. You can see i have just created listener for my alwayson availability group that are showing in below image for both replicas.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-997" src="http://techyaz.com/wp-content/uploads/2017/09/11-Listener-created.jpg" alt="listener in ssms" width="363" height="607" srcset="https://techyaz.com/wp-content/uploads/2017/09/11-Listener-created.jpg 363w, https://techyaz.com/wp-content/uploads/2017/09/11-Listener-created-179x300.jpg 179w" sizes="auto, (max-width: 363px) 100vw, 363px" /></p>
<p><em><span style="color: #800000;"><strong>Related Articles:</strong></span></em></p>
<ul>
<li><strong><a 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">How to fix Listener Error 19471: DNS Status is showing &#8220;The handle is invalid&#8221; for Listener CAP in FCM</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-976/" target="_blank" rel="noopener">Fix Error 976: Cannot connect to Secondary Replica</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">Fix Error 15434: Could not drop login ‘XXX\yyyy’ as the user is currently logged in</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-aoag-listener-error-19471-kerberos-status-showing-handle-invalid/">Fix AOAG Listener Error 19471: Kerberos Status is Showing The handle is Invalid</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/alwayson/fix-aoag-listener-error-19471-kerberos-status-showing-handle-invalid/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<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 loading="lazy" 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="auto, (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 loading="lazy" 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="auto, (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>
<p>
<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>
</p>
<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 loading="lazy" 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="auto, (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 976: Cannot connect to Secondary Replica of AlwaysON Availability Group</title>
		<link>https://techyaz.com/sql-server/alwayson/fix-error-976/</link>
					<comments>https://techyaz.com/sql-server/alwayson/fix-error-976/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Wed, 13 Sep 2017 10:00:51 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[Database Mirroring]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[AOAG]]></category>
		<category><![CDATA[Connection Issue]]></category>
		<category><![CDATA[connectivity Issue]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=883</guid>

					<description><![CDATA[<p>Today an application user has reported that he is not able to connect to the secondary replica of AlwaysOn Availability Group configuration. The details about error Microsoft SQL Server 976 that he was getting is given below. Cannot connect to&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/fix-error-976/">Fix SQL Server Error 976: Cannot connect to Secondary Replica of AlwaysON Availability Group</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Today an application user has reported that he is not able to connect to the secondary replica of <a href="https://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">AlwaysOn Availability Group</a> configuration. The details about error Microsoft SQL Server 976 that he was getting is given below.</p>
<p><span style="color: #ff0000;"><strong><em>Cannot connect to &#8216;Secondary Replica Server&#8217;.<br />
ADDITIONAL INFORMATION:<br />
</em></strong><em>The target database, &#8216;SDGC&#8217;, is participating in an availability group and is currently not accessible for queries. Either data movement is suspended or the availability replica is not enabled for read access. To allow read-only access to this and other databases in the availability group, enable read access to one or more secondary availability replicas in the group.  For more information, see the ALTER AVAILABILITY GROUP statement in SQL Server Books Online. (Microsoft SQL Server, Error: 976)</em></span></p>
<p>The screenshot of this error is given below.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-884" src="http://techyaz.com/wp-content/uploads/2017/09/1-Error-976.jpg" alt="Error 976" width="614" height="326" srcset="https://techyaz.com/wp-content/uploads/2017/09/1-Error-976.jpg 614w, https://techyaz.com/wp-content/uploads/2017/09/1-Error-976-300x159.jpg 300w" sizes="auto, (max-width: 614px) 100vw, 614px" /></p>
<h3><span style="color: #000080;">Solution</span></h3>
<p>Before going ahead let me give you a background about SQL Server configurations.</p>
<ul>
<li>We have <strong>two SQL Servers Server A &amp; Server B</strong> and there is an user database <strong>SDGC</strong> is hosted on both SQL Server Instances.</li>
<li><strong>AOAG</strong> is configured between both servers in <strong>Automatic failover</strong> mode for database <strong>SDGC</strong>.</li>
<li>Availability database <strong>SDGC </strong>hosted on instance B is <strong>inaccessible</strong> because it was restored in <strong>no recovery mode</strong> and not set in read only mode for AOAG configuration.</li>
<li>User&#8217;s login was created on both SQL Server instances with having default database as <strong>SDGC</strong> that are participating in AOAG.</li>
</ul>
<p>Now, the problem is whenever user tries to connect to the secondary replica whether AOAG is active from instance A or instance B, he is not able to connect to the SQL Server Instance and getting given SQL Server error 976. I analyzed this issue and found two solutions to fix this issue:</p>
<ul>
<li>Change <strong>Connect to database</strong> value in SSMS while establishing the connection.</li>
<li>Change <strong>default database </strong>value of your Login in Login Property window.</li>
</ul>
<p><span style="color: #800000;"><strong>Change Connect to database value in SSMS</strong></span></p>
<p>Launch <strong>SQL Server Management Studio</strong>. Click on <strong>Options</strong> tab of connection details window in SSMS as shown in below image.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-885" src="http://techyaz.com/wp-content/uploads/2017/09/2-connect-using-different-user-Copy.jpg" alt="click on connect button in SSMS" width="397" height="290" srcset="https://techyaz.com/wp-content/uploads/2017/09/2-connect-using-different-user-Copy.jpg 397w, https://techyaz.com/wp-content/uploads/2017/09/2-connect-using-different-user-Copy-300x219.jpg 300w" sizes="auto, (max-width: 397px) 100vw, 397px" /></p>
<p>You can see, <strong>Connect to database</strong> value showing as <strong>default</strong> that means it is connecting to the database that is set as <strong>default database</strong> for user&#8217;s login. Remember, <strong>default database</strong> for user&#8217;s login is set as <strong>SDGC</strong> that is running in <strong>norecovery mode</strong>.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-886" src="http://techyaz.com/wp-content/uploads/2017/09/3.0-connect-default-db.jpg" alt="connect to database in ssms" width="374" height="436" srcset="https://techyaz.com/wp-content/uploads/2017/09/3.0-connect-default-db.jpg 374w, https://techyaz.com/wp-content/uploads/2017/09/3.0-connect-default-db-257x300.jpg 257w" sizes="auto, (max-width: 374px) 100vw, 374px" /></p>
<p>Now, we just need to change the <strong>connect to database</strong> value from <strong>default</strong> to <strong>master</strong> or some other database. As <strong>default database</strong> for user&#8217;s login was set to SDGC, so change it master to make database engine to read an accessible database.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-887" src="http://techyaz.com/wp-content/uploads/2017/09/3.5-Change-default-db.jpg" alt="Change connect to database to master in ssms" width="374" height="436" srcset="https://techyaz.com/wp-content/uploads/2017/09/3.5-Change-default-db.jpg 374w, https://techyaz.com/wp-content/uploads/2017/09/3.5-Change-default-db-257x300.jpg 257w" sizes="auto, (max-width: 374px) 100vw, 374px" /></p>
<p>Once you make changes, hit the connect button and establish a database connection. This time you will be able to establish database connection to secondary replica.</p>
<p><span style="color: #800000;"><strong>Change default database value of your Login</strong></span></p>
<p>If <strong>default database</strong> of your login is <strong>not mandatory</strong> to set to <strong>availability database</strong> then you can change it to master and remove this issue permanently. Otherwise, you need to change default database every time you make a connection to secondary replica as discussed in above section.<br />
You can connect to your <strong>secondary replica</strong> or to the server where you are facing this issue using <strong>different admin or security admin account</strong>. If you have such account and password, you don&#8217;t need to logoff and relogin. You can just <strong>right click on SSMS icon</strong> while <strong>pressing SHIFT button</strong> to logged in using different user to the SQL Server instance. You can see that option in below image.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-888" src="http://techyaz.com/wp-content/uploads/2017/09/4-connect-using-different-user.jpg" alt="login using different account" width="451" height="355" srcset="https://techyaz.com/wp-content/uploads/2017/09/4-connect-using-different-user.jpg 451w, https://techyaz.com/wp-content/uploads/2017/09/4-connect-using-different-user-300x236.jpg 300w" sizes="auto, (max-width: 451px) 100vw, 451px" /></p>
<p>Click on &#8220;<strong>Run as different user</strong>&#8221; option. It will display below login screen to enter your new login and password. Enter the credentials.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-889" src="http://techyaz.com/wp-content/uploads/2017/09/5-connect-different-user.jpg" alt="Enter Credentials" width="382" height="329" srcset="https://techyaz.com/wp-content/uploads/2017/09/5-connect-different-user.jpg 382w, https://techyaz.com/wp-content/uploads/2017/09/5-connect-different-user-300x258.jpg 300w" sizes="auto, (max-width: 382px) 100vw, 382px" /></p>
<p>Once your new account will be authenticated, SSMS will be launched and show you the details as shown in below image. Click on <strong>Connect</strong> button to establish the connection.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-890" src="http://techyaz.com/wp-content/uploads/2017/09/6-connect-using-different-user.jpg" alt="connect using different account in ssms" width="397" height="290" srcset="https://techyaz.com/wp-content/uploads/2017/09/6-connect-using-different-user.jpg 397w, https://techyaz.com/wp-content/uploads/2017/09/6-connect-using-different-user-300x219.jpg 300w" sizes="auto, (max-width: 397px) 100vw, 397px" /></p>
<p>Expand <strong>Security</strong> folder. <strong>Identify</strong> your login for which you have to change the default database setting. <strong>Right click</strong> and choose <strong>properties</strong> on this login to launch properties window. You can <strong>double click</strong> on this login as well to launch this properties window. Below window will come to your screen where you can see the default database set for this login.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-891" src="http://techyaz.com/wp-content/uploads/2017/09/7-login.jpg" alt="login property" width="625" height="559" srcset="https://techyaz.com/wp-content/uploads/2017/09/7-login.jpg 625w, https://techyaz.com/wp-content/uploads/2017/09/7-login-300x268.jpg 300w" sizes="auto, (max-width: 625px) 100vw, 625px" /></p>
<p>You can see <strong>default database</strong> is set as <strong>SDGC</strong> in above screenshot. Now we need to <strong>change</strong> it to <strong>master</strong> or any accessible database. Do the changes, you can see i have changed it to master in our screenshot. Once you make changes, click on <strong>Ok</strong> button to proceed.</p>
<p><strong>NOTE:</strong> <em>If you need to change default database back to availability database due to some application dependencies then you need to first make your availability database accessible. You can perform failover to make secondary replica as primary then you can make changes and then you can failback. If you don&#8217;t want to perform failover/failback, then you can do this by changing the availability database from norecovery to read only mode.</em></p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-892" src="http://techyaz.com/wp-content/uploads/2017/09/8-login.jpg" alt="login property" width="621" height="547" srcset="https://techyaz.com/wp-content/uploads/2017/09/8-login.jpg 621w, https://techyaz.com/wp-content/uploads/2017/09/8-login-300x264.jpg 300w" sizes="auto, (max-width: 621px) 100vw, 621px" /></p>
<p>Now your <strong>issue is fixed. </strong>You would be able to connect to the SQL Server Instance that are running as secondary replica in AOAG configuration.  You can see, i have connected to secondary replica using same account with whom i was facing issue.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-893" src="http://techyaz.com/wp-content/uploads/2017/09/9-connect-using-samelogin.jpg" alt="" width="419" height="452" srcset="https://techyaz.com/wp-content/uploads/2017/09/9-connect-using-samelogin.jpg 419w, https://techyaz.com/wp-content/uploads/2017/09/9-connect-using-samelogin-278x300.jpg 278w" sizes="auto, (max-width: 419px) 100vw, 419px" /></p>
<p><span style="color: #800000;"><em><strong>Related Articles:</strong></em></span></p>
<ul>
<li style="list-style-type: none;">
<ul>
<li><strong><a 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 Error 19471: Listener Issue during Configuring 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">How to Fix SAP connectivity issue after AOAG failover</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</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">Fix SQL Server Error 15141: Server Principal owns one or more endpoints</a></strong></li>
</ul>
</li>
</ul>
<p>Please comment us to give your feedback. 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-976/">Fix SQL Server Error 976: Cannot connect to Secondary Replica of 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-976/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>
	</channel>
</rss>
