<?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/category/sql-server/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.1</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>How to Add Data File to Availability Database?</title>
		<link>https://techyaz.com/sql-server/alwayson/how-to-add-data-file-to-availability-database/</link>
					<comments>https://techyaz.com/sql-server/alwayson/how-to-add-data-file-to-availability-database/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Wed, 11 Jul 2018 03:49:25 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[availability group]]></category>
		<category><![CDATA[data file]]></category>
		<category><![CDATA[HowTO]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2418</guid>

					<description><![CDATA[<p>Sometimes, we need to add data file to availability database in Always on Availability Group. Adding database file is a straight forward method but if your databases participate in Always on Availability group then you need to take extra care&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/how-to-add-data-file-to-availability-database/">How to Add Data File to Availability Database?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Sometimes, we need to add data file to availability database in Always on Availability Group. Adding database file is a straight forward method but if your databases participate in Always on Availability group then you need to take extra care while planning or performing such activity. If you add data file to availability database on primary replica without planning then your secondary databases in availability group might get into “<em>Not Synchronizing</em>” state  irrespective of having identical drives and folder structure on all your replica servers.</p>
<p>If your drive letters or folder structures are identical on all replica servers then most of the time you will not face any issue while adding the database files but sometimes if you mount additional drive on all replicas to make it identical and then add data file in this new drive then you might face the issue. If all replica servers don’t have identical path then adding database file operation on primary replica will not successfully replicate to other replica servers because of different drive and folder structure. This, in turn, causes the secondary replica to enter the NOT SYNCHRONIZING state.</p>
<p><strong>Note:</strong> <em>Always try to keep drive and folder structure identical on all secondary replica servers to the corresponding primary replica.</em></p>
<p>If you have added a data file on primary database of Always on Availability group then you will see multiple errors logged in SQL Server error log on your secondary replica where secondary database is suspended from always on availability group and showing in “Not Synchronizing” state. You might see one of the below error codes in your log file.</p>
<p><span style="color: #ff0000;"><em>Error:5123, Severity:16, State:1.</em></span><br />
<span style="color: #ff0000;"><em>CREATE FILE encountered operating system error 3(The system cannot find the path specified.) while attempting to open or create the physical file ‘E:\MSSQL\Data\Techyaz_Data2.ndf’.</em></span></p>
<p>Or</p>
<p><span style="color: #ff0000;"><em>Error:5183, Severity:16, State:1.</em></span><br />
<span style="color: #ff0000;"><em>Cannot create the file “Techyaz_Data2”. Use WITH MOVE to specify a usable physical file name. Use WITH REPLACE to overwrite an existing file.</em></span></p>
<p>Or</p>
<p><em><span style="color: #ff0000;">Error: 3313, Severity: 21, State: 2.</span></em><br />
<em><span style="color: #ff0000;">During redoing of a logged operation in database ‘Techyaz’, an error occurred at log record ID (76:659:1).</span></em></p>
<p>Now i will describe how to fix such issues or how to plan and add a database file to always on availability databases.</p>
<h3><span style="color: #333399;">Add Data file to Availability Database</span></h3>
<p>If you have already added data file on primary database and your secondary databases are suspended from availability group then we need to fix it to reestablish always on availability group. If you have not added the data file and want to add it then you can keep reading this article as i have described it later in this article. I have described how to plan database file addition to avoid any future synchronization issue.</p>
<p>Let’s go ahead with the first option where you have already added the data file to primary availability database and secondary database status is showing as not synchronizing due to this change. Now we need to fix this issue to reestablish the synchronization between replicas of availability group. To resolve this problem the DBAs  must complete the following steps:</p>
<ol>
<li>Remove the secondary database from the availability group that is showing as &#8220;<em>Not Synchronizing&#8221;</em>. To do this, either you can use GUI method in SSMS or run below T-SQL statement. You can connect to secondary replica then you can expand <strong>Always On High Availability </strong>node followed by <strong>Availability Groups</strong> Now, select the availability group and then expand the <strong>Availability Databases</strong> node. To remove a single database, select it in either the <strong>Object Explorer</strong> pane or the <strong>Object Explorer Details</strong> pane. Right-click the selected database or databases, and select <strong>Remove Secondary Database</strong> in the command menu. If you want to do it using T-SQL statement then you must connect to secondary replica and execute below Alter command.</li>
</ol>
<pre style="padding-left: 60px;"><span style="color: #0000ff;"><strong>ALTER DATABASE Techyaz SET HADR OFF;  </strong></span>
<strong><span style="color: #0000ff;">GO</span> </strong></pre>
<ol start="2">
<li>Once database will be removed from AOAG, restore a full backup of the filegroup that contains the added file to the secondary database, using WITH <em>NORECOVERY</em> and <em>WITH MOVE</em> option. This option is mandatory if you don’t have any log backups. Although sometimes you can do it by only running log backup on primary replica and restore it on secondary replica in norecovery mode as mentioned in next step.</li>
<li>Now, back up the transaction log that contains the add-file operation on the primary database, and manually restore the log backup on the secondary database using WITH <em>NORECOVERY</em> and <em>WITH MOVE</em>.</li>
<li>Prepare the secondary database for re-joining the availability group, by restoring, WITH NO RECOVERY, any other outstanding log backups from the primary database.</li>
<li>Rejoin the secondary database to the availability group. Read this article to get <a href="https://techyaz.com/sql-server/add-database-availability-group/" target="_blank" rel="noopener">step by step method to add a database to availability group</a>.</li>
</ol>
<p>If you havenot added the data file then you can plan it with following steps.</p>
<ol>
<li>Remove the database from secondary replica as described in above section. Now, secondary database will be showing in to restoring state.</li>
<li>Add the data file to your availability database on primary replica.</li>
<li>Take a log backup of this availability database on primary replica.</li>
<li>Copy this log backup to secondary replica and restore it on its corresponding secondary replica using NORECOVERY and WITH MOVE option.</li>
<li>Now add the database back to always on Availability Group.</li>
</ol>
<p>Here, I have shown you step by step process to add data file to availability database. I have also let you know how to fix the issues that might arise due to adding the database files to availability database on primary replica. 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/alwayson/upgrade-or-patch-sql-server-failover-cluster-instance-with-availability-group/" target="_blank" rel="noopener">Upgrade or Patch SQL Server Failover Cluster Instance Running with Availability Group</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/enhanced-database-failover-in-availability-group/" target="_blank" rel="noopener">Understanding Enhanced Database Failover in Always on 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/alwayson/sql-server-alwayson-interview-questions-answers/" target="_blank" rel="noopener">Always ON Availability Group Interview Questions &amp; Answers</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/how-to-add-data-file-to-availability-database/">How to Add Data File to Availability Database?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/alwayson/how-to-add-data-file-to-availability-database/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>Upgrade or Patch SQL Server Failover Cluster Instance Running with Availability Group</title>
		<link>https://techyaz.com/sql-server/alwayson/upgrade-or-patch-sql-server-failover-cluster-instance-with-availability-group/</link>
					<comments>https://techyaz.com/sql-server/alwayson/upgrade-or-patch-sql-server-failover-cluster-instance-with-availability-group/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Mon, 04 Jun 2018 14:39:57 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[AOAG]]></category>
		<category><![CDATA[Availability Group Upgrade]]></category>
		<category><![CDATA[Clustering]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2391</guid>

					<description><![CDATA[<p>I have explained step by step process to upgrade or patch SQL Server instance that hosts an Always on Availability Group (AOAG) to latest version in attached article. Here, I will explain how to upgrade or patch SQL Server failover&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/upgrade-or-patch-sql-server-failover-cluster-instance-with-availability-group/">Upgrade or Patch SQL Server Failover Cluster Instance Running with Availability Group</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I have explained step by step process to <strong><a href="https://techyaz.com/sql-server/upgrade-patch-availability-group-instances/" target="_blank" rel="noopener">upgrade or patch SQL Server instance that hosts an Always on Availability Group (AOAG)</a></strong> to latest version in attached article. Here, I will explain how to upgrade or patch SQL Server failover cluster instance running with Always on Availability Group. We should plan and execute such upgrades carefully to avoid any risk during execution. The process to upgrade or patch SQL Server cluster instances running with AOAG is quite similar.</p>
<p><strong>NOTE:</strong> Always test any solution in Lower life cycle environment before deploying it to Production.</p>
<h3><span style="color: #333399;">Points to Remember</span></h3>
<ol>
<li>I have described steps to upgrade or patch SQL Server failover cluster instance having always on availability group. Do not use these steps while upgrading or patching Windows clustering or standalone SQL Server instances running with Always on Availability groups. If you have AOAG configured on standalone SQL Server instances then read <strong><a href="https://techyaz.com/sql-server/upgrade-patch-availability-group-instances/" target="_blank" rel="noopener">attached article</a></strong>.</li>
<li>During the upgrade process, a secondary replica will not be available for failover or for read-only operations, and after the upgrade, it may take some time for the secondary replica to catch up with the primary replica node depending upon the volume of activity on the primary replica node (so expect high network traffic).</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>Always first upgrade secondary replica then primary replica because 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;">Planning </span></h3>
<p>We should be very careful while planning upgrade or Patching for your SQL Server Failover cluster instances and if your SQL Server cluster instances are running with availability groups then you need to be more careful considering its complex configuration. Here, i have given multiple steps that you need to plan during patching any AOAG cluster instance.</p>
<ol>
<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>Identify your databases if they are involved in Change Data Capture or Replication then we need to perform some additional activities. These additional steps are given later in this article.</li>
<li>Run DBCC CHECKDB to make sure there is no corruption on databases hosted on these cluster instances.</li>
<li>You must run Full database backups for all your databases to secure a copy in case anything goes wrong and we need it to restore databases.</li>
<li>Make sure Always on Availability Group is working fine and in Healthy state. Fix the issues and make your AOAG configuration in healthy state 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="https://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>No replicas are readable or available for backups during a version upgrade whereas during a non-version upgrade you can configure automated backups to run on secondary replicas prior to upgrading the primary replica.</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. We will be using rolling upgrade process to apply patch or upgrade SQL Server cluster instances. This approach 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>
<li>Make sure that synchronization state of the failover target is SYNCHRONIZED during any failover of Availability Group.</li>
<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>
</ol>
<h3><span style="color: #333399;">Upgrade or Patch SQL Server Failover Cluster Instance running with Availability Group</span></h3>
<p>Here, I will explain how to upgrade or patch SQL Server failover cluster Instance running with Always on Availability group. Let me describe the cluster setup first for this upgrade.</p>
<ul>
<li>We have four database servers that are hosted in two data centers. Two nodes in each data centers.</li>
<li>All four nodes are part of same windows cluster group. two set of storage have been shared between two nodes to install SQL Server failover cluster.</li>
<li>Two SQL Server Failover Cluster Instances have been installed on these nodes of each data centers. One SQL Server failover cluster instance named <strong>FCIA</strong> is installed in data center 1 and another SQL Server cluster instance named <strong>FCIB</strong> is hosted in data center 2.</li>
<li>We have configured Availability Group between these two SQL Server failover cluster instances.</li>
<li>Each SQL Server cluster instance has two nodes. One active and one passive node in their respective data centers. Although active node in data center 2 is not active for connections but this will work as primary in case AOAG failover.</li>
<li>Databases are hosted on shared storage that is connected to their respective nodes in their data centers. You can see this configuration depicted in below image.</li>
</ul>
<p><img decoding="async" class="wp-image-2392 aligncenter" src="https://techyaz.com/wp-content/uploads/2018/06/AOAG-FCI-Patching-min-1024x333.jpg" alt="Patch SQL Server failover cluster instance running with AOAG" width="757" height="246" srcset="https://techyaz.com/wp-content/uploads/2018/06/AOAG-FCI-Patching-min-1024x333.jpg 1024w, https://techyaz.com/wp-content/uploads/2018/06/AOAG-FCI-Patching-min-300x98.jpg 300w, https://techyaz.com/wp-content/uploads/2018/06/AOAG-FCI-Patching-min-768x250.jpg 768w, https://techyaz.com/wp-content/uploads/2018/06/AOAG-FCI-Patching-min.jpg 1115w" sizes="(max-width: 757px) 100vw, 757px" /></p>
<p>Now we have to upgrade or patch this AOAG cluster instance configuration. Keep reading this article to understand step by step process to patch such complex AOAG configuration.</p>
<p>We can see above SQL Server cluster instances have Always on Availability Group so we will follow rolling upgrade process to perform upgrade or patch on these SQL Server cluster instances. The sequence to upgrade SQL Server cluster instances having AOAG configuration is to go from passive to active. We will upgrade the inactive nodes before upgrading the active nodes. Have a look at below step by step process.</p>
<ol>
<li>First upgrade or patch passive node of SQL Server cluster instance <strong>FCIB</strong> i.e. <em><strong>Node 4</strong></em>.</li>
<li>Once you will update node 4 of above image configuration then next step is to <em><strong>failover</strong></em> second SQL Server cluster instance FCIB to upgraded instance Node 4 that is hosted in data center 2.</li>
<li>Once you performed failover for cluster instance <strong>FCIB</strong> to node 4 then next step is to patch <em><strong>node 3</strong></em> that will be in passive state of this inactive SQL Server cluster instance. You can failback SQL Server cluster instance FCIB to node 3 again post patching. This failback is an optional step and not mandatory. Now you have applied latest patch level or upgraded your SQL Server cluster instance FCIB hosted in two cluster nodes in data center 2. Next, we will follow same process to apply patches in data center 1.</li>
<li>Apply patch on SQL Server cluster <em><strong>node 2</strong></em> or upgrade SQL Server cluster node installed on node 2 machine as it’s passive node of SQL Server cluster instance <strong>FCIA</strong>.</li>
<li>Once you have upgraded or patched node 2 in data center 1 next we will <em><strong>failover</strong></em> SQL Server cluster instance FCIA to node 2. Now node 2 will run active instance of SQL Server cluster setup. But If you have enabled change data capture feature or replication configured on your SQL Server cluster instance then you should run few additional steps as described here. Once you upgraded or patched all secondary replicas then fail over the Availability Group to an upgraded instance. Now run below command on your primary replica.</li>
</ol>
<pre style="padding-left: 60px;"><strong><span style="color: #0000ff;">EXECUTE [master].[sys].[sp_vupgrade_replication];</span></strong></pre>
<ol start="6">
<li>Go ahead after execution of above command and upgrade or patch SQL Server cluster instance that was originally the primary replica i.e. Node 1</li>
</ol>
<ol start="7">
<li>Now, patch SQL Server cluster instance that is hosted on <em><strong>node 1</strong></em> and was original primary replica that is now acting as passive in this cluster setup. Once done you can failback SQL Server cluster instance FCIA to again node 1 as active node. Here, you have patched or upgraded all SQL Server cluster instances hosted on these four nodes.</li>
</ol>
<p>Here, I have described how to upgrade or patch SQL Server failover cluster instance that is running with 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><span style="color: #800000;"><em><strong>Read More:</strong></em></span></p>
<ul>
<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/alwayson/change-failover-mode-of-availability-replica-in-always-on-availability-group/" target="_blank" rel="noopener">Change Failover Mode of Availability Replica in AOAG</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/add-database-availability-group/" target="_blank" rel="noopener">Add a New Database to Availability Group</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/upgrade-or-patch-sql-server-failover-cluster-instance-with-availability-group/">Upgrade or Patch SQL Server Failover Cluster Instance Running with 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/upgrade-or-patch-sql-server-failover-cluster-instance-with-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 loading="lazy" 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="auto, (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 1418: The server network address cannot be reached or does not exist.</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fix-error-1418-the-server-network-address-cannot-be-reached-or-does-not-exist/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fix-error-1418-the-server-network-address-cannot-be-reached-or-does-not-exist/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Tue, 27 Mar 2018 16:53:07 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[Database Mirroring]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[endpoints]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[SQL Server Configuration Manager]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1997</guid>

					<description><![CDATA[<p>We got error 1418 while configuring Database Mirroring on one of the SQL Server database instance. The error details are given below: The server network address “TCP://ServerName.abc.local:5022&#8243; cannot be reached or does not exist. Check the network address name and&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-1418-the-server-network-address-cannot-be-reached-or-does-not-exist/">Fix Error 1418: The server network address cannot be reached or does not exist.</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>We got error 1418 while configuring Database Mirroring on one of the SQL Server database instance. The error details are given below:</p>
<p><em><span style="color: #ff0000;">The server network address <strong>“TCP://ServerName.abc.local:5022&#8243;</strong> cannot be reached or does not exist. Check the network address name and that the ports for the local and remote endpoints are operational. (Microsoft SQL Server, Error: 1418)</span></em></p>
<h3><span style="color: #333399;">Reason behind Error 1418</span></h3>
<p>Main reason behind database mirroring error 1418 is because the specified server network address cannot be reached or does not exist. The server network address cannot be reached because of multiple reasons. Some of them are given below.</p>
<p><img loading="lazy" decoding="async" class="size-full wp-image-2000 alignright" src="http://techyaz.com/wp-content/uploads/2018/03/fix-error-1418.png" alt="fix error 1418" width="300" height="300" srcset="https://techyaz.com/wp-content/uploads/2018/03/fix-error-1418.png 300w, https://techyaz.com/wp-content/uploads/2018/03/fix-error-1418-150x150.png 150w, https://techyaz.com/wp-content/uploads/2018/03/fix-error-1418-160x160.png 160w, https://techyaz.com/wp-content/uploads/2018/03/fix-error-1418-320x320.png 320w" sizes="auto, (max-width: 300px) 100vw, 300px" /></p>
<ul>
<li>Principal, Mirror and Witness servers are not talking to each other.</li>
<li>Wrong network address name, mirror server instance name or port number.</li>
<li>Mirror database is not ready for mirroring.</li>
<li>Principal or mirror server instance is behind a firewall.</li>
<li>You are using local system account to run SQL Server services and not using certificates for authentication.</li>
<li>SQL Server services are running with different domain accounts on Principal and Mirror server and service accounts don&#8217;t have enough permission on endpoints.</li>
<li>Different endpoint encryption value set on Principal, Mirror and Witness server.</li>
<li>Endpoints are not started on the partner servers.</li>
<li>Principal server instance is not listening on the port assigned to its database mirroring endpoint.</li>
</ul>
<p>We need to verify each option mentioned above carefully to fix this error.</p>
<h3><span style="color: #333399;">Solution</span></h3>
<p>The solution of this issue may vary case to case depending on the nature of issue. To fix this issue we need to find out the main root cause behind error 1418. The root cause may be anything that is given in above section. Here I will describe each probable reason given above and its solution to fix this issue. Make sure to go through with each point given in this article.</p>
<h5><span style="color: #993300;">Principal, Mirror and Witness Servers Should be Accessible</span></h5>
<p>Make sure that SQL Server Instances installed on Principal, Mirror &amp; Witness servers are accessible to each other. If remote login for any SQL Server instance is not enabled then you might get this issue. You can enable remote connectivity by <strong><a href="http://techyaz.com/sql-server/troubleshooting/fix-error-40-network-related-instance-specific-error-occurred-establishing-connection/" target="_blank" rel="noopener">enabling TCP/IP and Named Pipes protocols in SQL Server Configuration Manager</a></strong>. Each system must access the ports of the other SQL Server instances over TCP. You can try telnet the SQL Server ports of other partners.</p>
<h5><span style="color: #993300;">Verify Correct System Details </span></h5>
<p>Sometimes we entered wrong details that end up with throwing errors. Make sure to verify the network address name, mirror server instance name and its port numbers are correct. You can recheck all the details whether you have entered them correctly or not.</p>
<h5><span style="color: #993300;">Mirror Database Preparation</span></h5>
<p>Verify that the mirror database is ready for database mirroring. We should prepare mirror database before configuring or during configuring database mirroring. It is suggested to keep identical drive path for mirror database files. Below are the steps you should take care for preparing your mirroring database.</p>
<ul>
<li>Run full backup and subsequent transactional log backup of the Principal database and copy it to the Mirror server.</li>
<li>Restore database with same name in norecovery state on Mirror server with the copied backup files from above step. You must ensure that restored database on mirror server should be in restoring mode before starting database mirroring configuration.</li>
</ul>
<h5><span style="color: #993300;">Firewall/Ports</span></h5>
<p>One of the probable reason to get error 1418 is partner servers are behind firewall. Make sure that the principal server instance and destination mirror server instance is not behind a firewall and they should talk to each other. Principal server, Mirror server and witness server should be accessible to each other.</p>
<p>Verify that SQL Server port and endpoint ports are enabled and accessible via telnet. If not or you are not able to telnet any of the partner instance from any server participating in mirroring then you should ask your network admins to open these ports to establish the connectivity over given port.</p>
<h5><span style="color: #993300;">Endpoints</span></h5>
<p>Make sure that endpoint has been created on principal, mirror and witness servers. Verify that the endpoints are started on each partner server instances. You can check endpoint status by running below T-SQL query on each instance.</p>
<pre><strong><span style="color: #0000ff;">SELECT state_desc FROM sys.database_mirroring_endpoints</span></strong></pre>
<p>If either endpoint is not started, execute below ALTER ENDPOINT statement to start it.</p>
<pre><span style="color: #008000;"><strong>#Change the name of your endpoints. Here endpoint name is Mirroring</strong></span>
<strong><span style="color: #0000ff;">ALTER ENDPOINT Mirroring</span></strong>
<strong><span style="color: #0000ff;">STATE = STARTED</span></strong>
<strong><span style="color: #0000ff;">AS TCP (LISTENER_PORT = &lt;port_number&gt;)</span></strong>
<strong><span style="color: #0000ff;">FOR database_mirroring (ROLE = ALL);</span></strong>
<strong><span style="color: #0000ff;">GO</span></strong></pre>
<p>Recheck that the principal server instance is listening on the port assigned to its database mirroring endpoint and the mirror server instance is listening on its port. If a partner is not listening on its assigned port, modify the database mirroring endpoint to listen on a different port.</p>
<p>Sometimes this issue got fixed by dropping the existing endpoint and recreate it again on partner servers.</p>
<h5><span style="color: #993300;">Service Accounts</span></h5>
<p>Do not use <em>local system</em> account to run SQL Server services. If you don’t have any choice and want to use local system then ensure to use certificates for authentications.</p>
<p>Make sure that service accounts that you are using to run SQL Server services must have CONNECT permission to mirroring endpoints. Also, if you are configuring database mirroring between two domains then the login of one account must be created in <strong>master</strong> database on the other computer, and that login must be granted CONNECT permissions on the endpoint.</p>
<p>It&#8217;s always advisable to use same service accounts to run SQL Server services on all three Instances on Principal, Mirror and Witness server.</p>
<p>You can comment us your experience about fixing this issue. We will update this article with your solution that you have used to fix this issue.</p>
<p>I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/" target="_blank" rel="noopener">Facebook</a> page and <a href="https://twitter.com/Tech_yaz" target="_blank" rel="noopener">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/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/" target="_blank" rel="noopener">Fix Error 15141: The server principal owns one or more endpoints and cannot be dropped</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/fix-alwayson-error-35250-joining-database-secondary-replica-resulted-error/" target="_blank" rel="noopener">Fix AOAG Error 35250: Joining database on Secondary Replica resulted in an error</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/upgrade-patch-availability-group-instances/" target="_blank" rel="noopener">How to Upgrade or Patch Availability Group Instances?</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/alwayson/sql-server-alwayson-interview-questions-answers/" target="_blank" rel="noopener">SQL Server Always On Interview Questions and Answers</a></strong></li>
</ul>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-1418-the-server-network-address-cannot-be-reached-or-does-not-exist/">Fix Error 1418: The server network address cannot be reached or does not exist.</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-1418-the-server-network-address-cannot-be-reached-or-does-not-exist/feed/</wfw:commentRss>
			<slash:comments>0</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>
<!-- #tablepress-3 from cache --></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>
	</channel>
</rss>
