Вы находитесь на странице: 1из 11

2/14/2016

AlwaysOnAvailabilityGroupsCreation

Search...

TechCoffee

techabreak,haveacoffee:)

CLOUD

SECURITY

STORAGE

SQL SERVER

SYSTEM CENTER

WINDOWS SERVER

VIDEO CHANNEL

CONTACT

Home/SQLServer/AlwaysOnAvailabilityGroupsCreation

SOCIAL

AlwaysOn Availability Groups Creation


Postedby:GillesMonville inSQLServer May18,2014 0 37Views

SQLServer2012/2014AlwaysOnAvailabilityGroups:

ArticleSummary
Part1AlwaysOnIntroduction
Part2AlwaysOnDesign

WHITEPAPER
ImplementahighlyavailablePrivateCloudtohost
virtualmachines

Part3InstallandConfigureWindowsServer2012R2inCoremode
Part4WSFCClusterCreation
Part5InstallSQLCoreonWindowsCoreServer
Part6AlwaysOnAvailabilityGroupsCreation
Part7AlwaysOnAvailabilityGroupsCreation(Advanced,withdedicatedReplicationNetwork)
Part8MethodstoaddDatabaseonAvailabilityGroups(SCOMExample)
Part9AlwaysOnAvailabilityGroupsPowerShellMonitoring
ANNEX(Part6/7)ManageSQLEndpoint

UnderstandMicrosoftHyperConvergedSolution

NowthenextstepistocreateandconfigurethefirstAvailabilityGroups.
Therearethreemethodstodothis:
with Wizard through Management Studio
with PowerShell
with TransactSQL
IwillusetheWizardtocreatethefirsttwogroups(thispermittocreatealsotheTransactSQLscriptsthat
wecanreuselater).

Popular

Recent

Comments

SoftwareUpdatewithSCCMPART3Automatic
DeploymentRules
March8,2014

SCCMSoftwareUpdatePART1Introductionto
SCCMandWSUS
March7,2014

PrepareaDatabase

http://www.techcoffee.net/alwaysonavailabilitygroupscreation/

1/11

2/14/2016

AlwaysOnAvailabilityGroupsCreation

PrepareaDatabase

PrepareaVMTemplateforfast
deploymentinVMM2012R2

Forreminder,thefirstavailabilitygroupwillbenamedAAG1andreplicawillbehostoninstance:
MSQLA1\AOI1
MSQLA3\AOI3

June8,2014

SCCMSoftwareUpdatePART2SoftwareUpdate
Pointconfiguration

March7,2014

FortestIusetheMicrosoftAdventureWorksDatabasesample.DownloadAdventureWorks2012DataFile
(around200Mb)from:http://msftdbprodsamples.codeplex.com/releases/view/55330
CopyDatabasefileto:G:\MSSQL\AOREPLICA\MSSQL\Data.
IrenameittoAdvWorks1(IwillusesamemdfforothertestsDB)

SCCMSoftwareUpdatePART4Create
deploymentpackagesmanually
March9,2014

CATEGORIES
Backup
Cloud
AzureStack
MicrosoftAzure
WindowsAzurePack
Security

Adddatabasetofirstinstance(MSQLA1\AOI1):
ThereisonlyMDFfile.Soinordertobuildanewlogfile,usetheATTACH_REBUILD_LOGoptionwhen
attachingthedatabases.

SQLServer
Storage
QNAP
SoftwareDefinedStorage
Synology

USE [master]
GO
CREATE DATABASE [AdvWorks1]
ON (FILENAME = N'G:\MSSQL\AOREPLICA\Data\AdvWorks1.mdf')

SystemCenter
ConfigurationManager
DataProtectionManager
VirtualMachineManager

FOR ATTACH_REBUILD_LOG

TechEd14

GO

WindowsServer
HyperV

SELECT
DB_NAME(database_id) AS "Database Name",
type_desc AS "File Type",
name AS "Logical File Name",
physical_name AS "Physical File",
state_desc AS "State"
FROM sys.master_files WHERE database_id IN (DB_ID('AdvWorks1'));

ARCHIVES
Archives
SelectMonth

CheckBackupmodeofDB:

Anotherprerequisiteisthatyouhavetodoatleast1fullbackupofeachdatabasethatwillbepartofyour
AG:

# Make a Full Backup


$db = "AdvWorks1"
Backup-SqlDatabase -ServerInstance "M-SQLA1\AOI1" -Database $db -BackupAction Database -BackupFile "G:\MSSQL\MSSQL11.AOI1\MSSQL\Backup\$($db).bak"

http://www.techcoffee.net/alwaysonavailabilitygroupscreation/

2/11

2/14/2016

AlwaysOnAvailabilityGroupsCreation

OrfromSQL:

-- Make a Full Backup


USE master
GO
BACKUP DATABASE AdvWorks1 TO DISK = 'G:\MSSQL\MSSQL11.AOI1\MSSQL\Backup\AdvWorks1.bak'
GO

SonowDatabaseisreadywithafullbackup.

MirroringEndpointsNote
ThefirststepistocreateoneMirroringEndpointperInstance.
Forreminder,IhavepreparedadedicatenetworkforSQLInstancesCommunications:VLANReplication.
FortestsIwillconfiguretwoinstancesAOI2andAOI4tousethisNetworkandthetwoothertothe
defaultnetwork(Public):
Hostname

IPVLANPublic

IPVLANCLUSTER

IPVLANReplication

MSQLA1

10.0.1.21

10.0.10.21

n/a

MSQLA2

10.0.1.22

10.0.10.22

10.0.20.22

MSQLA3

10.0.1.23

10.0.10.23

n/a

MSQLA4

10.0.1.24

10.0.10.24

10.0.20.24

Explications:
BydefaulttheWizardcreateautomaticallyaMirroringEndpointforeachInstance(TheEndpoint
configurationdoesntcontainsanyNetworkparameter)andconfiguretheReplicaEndpointURLwiththe
serverFQDN.Example:TCP://MSQLA1.lab1.ad:5022.
WiththisconfigurationtheInstancecommunicationwillbedoneoverthePublicNetwork
ThispartwillbedonefortheAAG1andtheAAG2(InstanceAOI1andAOI3).
ToconfigureinstanceforcommunicateovertheReplicationNetwork,wehavetocreatetheEndpointand
specifyanIPaddressofthereplicationnetworkforeachinstanceandconfiguretheEndpointURLwiththis
IPforeachReplica.
ThispartwillbedonefortheAAG3andtheAAG4(InstanceAOI2andAOI4).
Forreminder,thereisonlyoneEndpointperInstance(canbeusedformultipleAvailabilityGroup).

CreateAAG1(InstanceAOI1&AOI3)
Ok,nowIcreatethefirstAAG(DBTest01istheAdvWorks1databaseaddedbefore)

http://www.techcoffee.net/alwaysonavailabilitygroupscreation/

3/11

2/14/2016

AlwaysOnAvailabilityGroupsCreation

Schema:AlwaysOnAvailabilityGroupsAAG1
FromMSQLA1,startManagementStudio,connecttoinstanceAOI1.
RightclickonAvailabilityGroupandselectNewAvailabilityGroupWizard:

SpecifytheAAGname(thiswillbetheWSFCResourceGroupname):

SelecttheDB:

SelectAddreplica

http://www.techcoffee.net/alwaysonavailabilitygroupscreation/

4/11

2/14/2016

AlwaysOnAvailabilityGroupsCreation

ConnecttotheAOI3instance:

EnableAutomaticFailover(SynchronousCommitmustbeenabled)andconfiguretheReadableSecondary
Option(FormoreinformationaboutparametersseechapterAvailabilityReplicasConfigurationin
Part2AlwaysOnLabDesign)

ConfigureEndpoints(DefaultURL=ServerFQDN=>CommunicationonthePublicnetwork):

ConfigureBackupPreferences(thisisthedefaultoption):

http://www.techcoffee.net/alwaysonavailabilitygroupscreation/

5/11

2/14/2016

AlwaysOnAvailabilityGroupsCreation

CreatetheListener:
(WhenyouconfigurelaterapplicationstohosttheirDatabasesintheAAGyouhavetospecifythisListener
DNSNameandthePort,thisistheonlyinformationknownbyapplications).
Note:TheListenerVCOandDNSrecordmustbeprestage(seechapterPrestageAvailabilityGroup
ListenerinarticlePart6CreateAAG)

SelectFullfortheinitialdatasynchronizatrion:

Note:IfthedefaultDatabasepaths(fileandlog)arenotthesameonallinstances,theFullmodewillnot
work.
FormoreinformationseeparagraphNoteforDatabases/LogspathonAAGinthechapterStorage
onPart2AlwaysOnLabDesign

MoreinformationonDataSynchronizationPage:
SelectInitialDataSynchronizationPage(AlwaysOnAvailabilityGroupWizards)
http://msdn.microsoft.com/enus/library/hh231021.aspx

ManuallyPrepareaSecondaryDatabaseforanAvailabilityGroup(SQLServer)
http://msdn.microsoft.com/enus/library/ff878349.aspx

http://www.techcoffee.net/alwaysonavailabilitygroupscreation/

6/11

2/14/2016

AlwaysOnAvailabilityGroupsCreation

ClickonScriptandsaveitandstartthecreation:

CheckAAG
NowyoucanstarttheDashboardtochecktheStatusofAAG:

Note:RequiresPermissionstouseDashboard:
CONNECT
VIEWSERVERSTATE
VIEWANYDEFINITION

http://www.techcoffee.net/alwaysonavailabilitygroupscreation/

7/11

2/14/2016

AlwaysOnAvailabilityGroupsCreation

AndviatheWSFCConsole,youcanshowtheavailabilitygroupresourcegroupstatus:
Note:NormallyyoushouldnotusetheWSFCConsoletoadministerAlwaysOnAvailabilityGroups.
Everything(failover)mustbedoneviatheDashboard,TransactSQLorPowerShell.TheWSFCConsole
providesaviewoftheclusterstate.

CreateAAG2(InstanceAOI1&AOI3)
SonowIwillcreatethesecondAvailabilityGroup(onthesamenodeasAAG1).
Attheend,therewillbeanactivedatabaseoneachinstancewithareplicaoneachotherside.Sotheloss
ofaninstancewillbesupported.

Schema:AlwaysOnAvailabilityGroupsAAG2
FromInstanceMSQLA3\AOI3

CreateatestDBwithonetable:

-- CREATE DATABASE DBTestAOI3 -------------------------------------------------------------USE master;


GO
CREATE DATABASE DBTestAOI3
ON
( NAME = DBTestAOI3_Data,
FILENAME = 'G:\MSSQL\AOREPLICA\Data\DBTestAOI3.mdf',
SIZE = 10MB,

http://www.techcoffee.net/alwaysonavailabilitygroupscreation/

8/11

2/14/2016

AlwaysOnAvailabilityGroupsCreation

MAXSIZE = 500MB,
FILEGROWTH = 1MB )
LOG ON
( NAME = DBTestAOI3_Log,
FILENAME = 'L:\MSSQL\AOREPLICA\Log\DBTestAOI3_log.ldf',
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 5MB ) ;
GO
USE DBTestAOI3
GO
CREATE TABLE Servers (SrvID int IDENTITY (100,1) PRIMARY KEY, Name nvarchar (50))
GO
-- Populate Table
INSERT INTO Servers ([Name]) VALUES ('ServerAOI3-01')
INSERT INTO Servers ([Name]) VALUES ('ServerAOI3-02')
INSERT INTO Servers ([Name]) VALUES ('ServerAOI3-03')
GO
select * from servers

Doafullbackup:

-- MAKE A FULL BACKUP ----------------------------------------------------------------------USE master


GO
BACKUP DATABASE DBTestAOI3 TO DISK = 'G:\MSSQL\MSSQL11.AOI3\MSSQL\Backup\DBTestAOI3.bak'
GO

CreatetheAAG2

EnterAAGname:

Selectthedatabase:

AddthereplicaMSQLA1\AOI1

http://www.techcoffee.net/alwaysonavailabilitygroupscreation/

9/11

2/14/2016

AlwaysOnAvailabilityGroupsCreation

NotethatyoucannotchangethenameorportofEndpoints(therewaspreviouslycreatedwiththefirst
AAG):

ConfigureBackupPreferences:

ConfiguretheListener:

SelectInitialsynchronizationoption:

StarttheAvailabilityGroupcreation:

Sonow,thetwoAAGarecreated:

NetworkNote:
WecanseethattheInstancescommunicationsareestablishedonthePublicNetwork(10.0.1.0),thisisdue
totheendpointsconfiguration:

ShareNote:
ThenetworksharespecifyintheInitialsynchronizationpagecontainsbackupofDatabasesaddedtothe
AG.Thesebackupscanberemoved,thereareusedonlyfortheinitialreplicacreation.

tweet

Taggedwith:

Share

ALWAYSON

AVAILABILITYGROUP

SQLSERVER2012/2014

http://www.techcoffee.net/alwaysonavailabilitygroupscreation/

10/11

2/14/2016

AlwaysOnAvailabilityGroupsCreation
Previous:

Next:

VMnetworkissueinVMM2012R2with
IPAMintegration

IPPoolinVirtualMachineManager
2012R2

ABOUT GILLES MONVILLE


GillesMonvilleisapassionateofITformanyyearsheworksforover10yearsonMicrosoftand
VMwareenvironments.InadditiontoVirtualizationandCloudcomputing,helovesautomation
(Orchestrator,PowerShell,Clouddeployment)

RELATED POSTS
WindowsAzurePackSQL
ServerinAlwaysOnasa
Service

Whitepaper:Implementa
highlyavailableprivatecloud
tohostvirtualmachines

January13,2015

December25,2014

AlwaysOnAvailabilityGroup
Introduction
April27,2014

LEAVE A REPLY
Enteryourcommenthere...

TAGS

RECENT POSTS

ADCS Altaro AlwaysOn

[Whitepaper]UnderstandMicrosoftHyperConvergedsolution

AlwaysOnAvailabilityGroup Automation Azure

February8,2016

BareMetalDeployment Certificate Cloud


DataProtectionManager Design DPM
DPMDataProtectionManager Highavailability
HyperV IaaS IPAM MicrosoftAzure

IssuewhendeployAzureStackTechnicalPreview1onlyonSSD
February5,2016

Monitoring NVGREGateway PKI PowerShell

Createanoffer,aplanandgetasubscriptioninAzureStackTechnicalPreview
1

Requirements ScaleOutFileServer SCCM

February1,2016

SCCM2012R2 Security
ServiceProviderFoundation

DeployAzureStackTechnicalPreview1
January30,2016

Softwaredefinedstorage SoftwareUpdatePoint
SQLServer Storage StorageSpacesDirect

StorageQualityofServiceinWindowsServer2016

SUP SystemCenter TechEd14 Update

January25,2016

VirtualMachineManager VMM VMRole


WebsiteClouds WindowsAzurePack
WindowsServer WindowsServer2016 WSUS

http://www.techcoffee.net/alwaysonavailabilitygroupscreation/

11/11

Оценить