Configure Always On and Availability group Part – 1

Enable AlwaysOn and Configure Availability Group with Primary Replica

# Check Always On  is enabled

--Powershell command
PS C:> Set-Location SQLServer:\SQL\SQL03\GOSGPRDSQL02 
PS SQLSERVER:\SQL\SQL03\GOSGPRDSQL02>Get-Item . |Select IsHadrEnabled|Format-Table -AutoSize
--

image

# Enable always on if not enabled.

--Powershell command
PS C:> Enable–SqlAlwaysOn –Path SQLSERVER:\SQL\SQL03\GOSGPRDSQL03
--

image

#SQL Server services should be recycled  (Stopped and started)

image

#Check AlwaysOn is Enabled.

image

#Create Database Mirroring Endpoint @ Primary SQL Instance

image

#Create Database Mirroring Endpoint @ Secondary SQL Instance

image

#Create Availability Group  with Primary Instance as Replica (Secondary Replica will be added later)

T-SQL

USE [master] 
GO 
CREATE AVAILABILITY GROUP [GOSGPRDAGSQL02SQL03] 
	WITH 
	(
		AUTOMATED_BACKUP_PREFERENCE = SECONDARY
	) FOR REPLICA ON N'SQL03GOSGPRDSQL02' 
		WITH (ENDPOINT_URL = N'TCP://SQL03.dbprox.local:5022', FAILOVER_MODE = AUTOMATIC, 
		      AVAILABILITY_MODE = SYNCHRONOUS_COMMIT, SESSION_TIMEOUT = 10, BACKUP_PRIORITY = 50, 
			  PRIMARY_ROLE(ALLOW_CONNECTIONS = ALL), SECONDARY_ROLE(ALLOW_CONNECTIONS = NO)); 
GO

Powershell

--
$primaryReplica = New-SqlAvailabilityReplica -Name 'SQL03GOSGPRDSQL02' 
                                             -EndpointURL 'TCP://SQL03.sqlcontent.com:5022' 
											 -AvailabilityMode 'SynchronousCommit' 
											 -FailoverMode 'Automatic' 
											 -Version 12 -AsTemplate 
New–SqlAvailabilityGroup -Name 'GLBAGSQL0203' -Path 'SQLSERVER:\SQL\SQL03\GOSGPRDSQL02' -AvailabilityReplica @($primaryReplica)
--

image

 

image

 

#Availability Group service is create and can be seen in the Windows Cluster

 

image

Leave a Reply

Your email address will not be published. Required fields are marked *