AlwaysOn Availability Groups Creation

Embed Size (px)

Citation preview

  • 8/18/2019 AlwaysOn Availability Groups Creation

    1/11

    2/14/2016 AlwaysOn Availability Groups Creation

    http://www.tech-coffee.net/alwayson-availability-groups-creation/

    ⌂ Home  / SQL Server / AlwaysOn Availability Groups Creation

    AlwaysOn Availability Groups Creation Posted by: Gilles Monville in SQL Server May 18, 2014 0 37 Views

    SQL Server 2012/2014  AlwaysOn Availability Groups:

     Article Summary

    Part 1 – AlwaysOn Introduction

    Part 2 – AlwaysOn Design

    Part 3 – Install and Configure Windows Server 2012 R2 in Core mode

    Part 4 – WSFC Cluster Creation

    Part 5 – Install SQL Core on Windows Core Server

    Part 6 – AlwaysOn Availability Groups Creation

    Part 7 – AlwaysOn Availability Groups Creation (Advanced, with dedicated Replication Network)

    Part 8 – Methods to add Database on Availability Groups (SCOM Example)

    Part 9 – AlwaysOn Availability Groups – PowerShell Monitoring

     ANNEX (Part 6/7) – Manage SQL Endpoint

     

    Now the next step is to create and configure the first Availability Groups.

    There are three methods to do this:

    – with Wizard through Management Studio 

    – with PowerShell

    – with Transact‐SQL

    I will use the Wizard to create the first two groups (this permit to create also the Transact-SQL scripts that

    we can reuse later).

     

    SOCIAL

    WHITEPAPER

    Implement a highly available Private Cloud to hostvirtual machines

    Understand Microsoft Hyper Converged Solution

    Software Update with SCCM PART 3 – Automatic

    Deployment Rules

    March 8, 2014

    SCCM Software Update PART 1 – Introduction to

    SCCM and WSUS

    March 7, 2014

    Popular Recent Comments

    Tech-Coffee tech a break, have a coffee :)

    CLOUD SECURITY STORAGE SQL SERVER SYSTEM CENTER WINDOWS SERVER VIDEO CHANNEL CONTACT

    http://www.tech-coffee.net/alwayson-part-8-methods-to-add-database-scom/http://www.tech-coffee.net/alwayson-part-8-methods-to-add-database-scom/http://www.tech-coffee.net/alwayson-part-8-methods-to-add-database-scom/http://www.tech-coffee.net/alwayson-part-8-methods-to-add-database-scom/http://www.tech-coffee.net/category/cloud/http://www.tech-coffee.net/category/security/http://www.tech-coffee.net/category/sto/http://www.tech-coffee.net/category/sql-server/http://www.tech-coffee.net/category/systemcenter/http://www.tech-coffee.net/category/windows-server/http://www.tech-coffee.net/video-channel/http://www.tech-coffee.net/http://www.tech-coffee.net/software-update-sccm-part-3-automatic-deployment-rules/https://gallery.technet.microsoft.com/Understand-Hyper-Converged-bae286ddhttp://-/?-http://-/?-https://github.com/SerreRom/TechCoffeehttps://fr.linkedin.com/in/romainserrehttps://twitter.com/RomSerrehttp://www.tech-coffee.net/feed/http://www.tech-coffee.net/about-tech-coffee/http://www.tech-coffee.net/video-channel/http://www.tech-coffee.net/category/windows-server/http://www.tech-coffee.net/category/systemcenter/http://www.tech-coffee.net/category/sql-server/http://www.tech-coffee.net/category/sto/http://www.tech-coffee.net/category/security/http://www.tech-coffee.net/category/cloud/http://www.tech-coffee.net/https://github.com/SerreRom/TechCoffeehttps://fr.linkedin.com/in/romainserrehttps://twitter.com/RomSerrehttp://www.tech-coffee.net/feed/http://www.tech-coffee.net/part-1-introduction-to-sccm-and-wsus/http://www.tech-coffee.net/software-update-sccm-part-3-automatic-deployment-rules/https://gallery.technet.microsoft.com/Understand-Hyper-Converged-bae286ddhttps://gallery.technet.microsoft.com/Understand-Hyper-Converged-bae286ddhttps://gallery.technet.microsoft.com/Implement-a-highly-4ba56f20/https://gallery.technet.microsoft.com/Implement-a-highly-4ba56f20/https://mvp.microsoft.com/en-us/PublicProfile/5001608?fullName=Romain%20%20Serrehttp://go.altaro.com/hyper-v-backup/?LP=techcof&utm_source=techcoffee&utm_medium=banner&utm_campaign=avm-freehttp://www.tech-coffee.net/alwayson-part-8-methods-to-add-database-scom/http://www.tech-coffee.net/alwayson-part-7-aag-with-dedicated-replication-network/http://www.tech-coffee.net/alwayson-availability-group-install-sql-server-core/http://www.tech-coffee.net/alwayson-availability-group-wsfc-cluster-creation/http://www.tech-coffee.net/alwayson-availability-group-install-ws2012-r2-core-server/http://www.tech-coffee.net/alwayson-availability-group-design/http://www.tech-coffee.net/alwayson-availability-group-introduction/http://www.tech-coffee.net/sql-server-2012-2014-alwayson-availability-group/http://www.tech-coffee.net/category/sql-server/http://www.tech-coffee.net/author/gilles-monville/http://www.tech-coffee.net/category/sql-server/http://www.tech-coffee.net/

  • 8/18/2019 AlwaysOn Availability Groups Creation

    2/11

    2/14/2016 AlwaysOn Availability Groups Creation

    http://www.tech-coffee.net/alwayson-availability-groups-creation/ 2

    Prepare a DatabaseFor reminder, the first availability group will be named “AAG-1” and replica will be host on instance:

    – M‐SQLA1\AOI1

    – M‐SQLA3\AOI3

    For test I use the Microsoft Adventure Works Database sample. Download “AdventureWorks2012 Data File” 

    (around 200Mb) from: http://msftdbprodsamples.codeplex.com/releases/view/55330

    Copy Database file to: G:\MSSQL\AOREPLICA\MSSQL\Data.

    I rename it to “AdvWorks1” (I will use same mdf for other tests DB)

     Add database to firs t instance (M-SQLA1\AOI1):

    There is only MDF file. So in order to build a new log file, use the  ATTACH_REBUILD_LOG option when

    attaching the databases.

    USE [master]

    GO

    CREATE DATABASE [AdvWorks1]

    ON (FILENAME = N'G:\MSSQL\AOREPLICA\Data\AdvWorks1.mdf')

    FOR ATTACH_REBUILD_LOG

    GO

    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'));

     

    Check Backup mode of DB:

     

     Another prerequisite is that you have to do at least 1 full backup of each database that will be part of your

     AG:

    # Make a Full Backup

    $db = "AdvWorks1"

    Backup-SqlDatabase -ServerInstance "M-SQLA1\AOI1" -Database $db -BackupAction Database -

    Prepare a VM Template for fast

    deployment in VMM 2012R2

    June 8, 2014

    SCCM Software Update PART 2 – Software Update

    Point configuration

    March 7, 2014

    SCCM Software Update PART 4 – Create

    deployment packages manually

    March 9, 2014

    CATEGORIES

    Backup

    Cloud

     Azure Stack 

    Microsoft Azure

    Windows Azure Pack 

    Security

    SQL Server

    Storage

    QNAP

    Software-Defined Storage

    Synology

    System Center

    Configuration Manager

    Data Protection Manager

     Virtual Machine Manager

    TechEd14

    Windows Server

    Hyper-V

    ARCHIVES

     Archives

    Select Month

    http://www.tech-coffee.net/prepare-vm-template-fast-deployment-vmm-2012r2/http://www.tech-coffee.net/category/windows-server/hyper-v/http://www.tech-coffee.net/category/windows-server/http://www.tech-coffee.net/category/teched14/http://www.tech-coffee.net/category/systemcenter/vmm/http://www.tech-coffee.net/category/systemcenter/dpm/http://www.tech-coffee.net/category/systemcenter/sccm-systemcenter/http://www.tech-coffee.net/category/systemcenter/http://www.tech-coffee.net/category/sto/syno/http://www.tech-coffee.net/category/sto/sds/http://www.tech-coffee.net/category/sto/qnap/http://www.tech-coffee.net/category/sto/http://www.tech-coffee.net/category/sql-server/http://www.tech-coffee.net/category/security/http://www.tech-coffee.net/category/cloud/wap/http://www.tech-coffee.net/category/cloud/microsoft-azure/http://www.tech-coffee.net/category/cloud/azure-stack/http://www.tech-coffee.net/category/cloud/http://www.tech-coffee.net/category/backup/http://www.tech-coffee.net/sccm-software-update-part-4-create-deployment-packages-manually/http://www.tech-coffee.net/part-2-software-update-point-configuration/http://www.tech-coffee.net/prepare-vm-template-fast-deployment-vmm-2012r2/http://msftdbprodsamples.codeplex.com/releases/view/55330

  • 8/18/2019 AlwaysOn Availability Groups Creation

    3/11

    2/14/2016 AlwaysOn Availability Groups Creation

    http://www.tech-coffee.net/alwayson-availability-groups-creation/ 3

     

    Or from SQL:

    -- Make a Full Backup

    USE master

    GO

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

    GO

     

    So now Database is ready with a full backup.

     

    Mirroring Endpoints – NoteThe first step is to create one Mirroring Endpoint per Instance.

    For reminder, I have prepared a dedicate network for SQL Instances Communications: VLAN Replication.

    For tests I will configure two instances “AOI2” and “AOI4” to use this Network and the two other to the

    default network (Public):

    H os tna me IP VLA N Public IP VLA N C LU STE R IP VLA N R eplic ation

    M-SQLA1 10.0.1.21 10.0.10.21   n/a

    M-SQLA2 10.0.1.22 10.0.10.22   10.0.20.22

    M-SQLA3 10.0.1.23 10.0.10.23   n/a

    M-SQLA4 10.0.1.24 10.0.10.24   10.0.20.24

    Explications:

    By default the Wizard create automatically a Mirroring Endpoint for each Instance (The Endpoint

    configuration doesn’t contains any Network parameter) and configure the Replica Endpoint URL with the

    server FQDN. Example: TCP://M-SQLA1.lab1.ad:5022.

    With this configuration the Instance communication will be done over the “Public” Network” 

    This part will be done for the AAG-1 and the AAG-2 (Instance AOI1 and AOI3).

    To configure instance for communicate over the Replication Network, we have to create the Endpoint and

    specify an IP address of the replication network for each instance and configure the Endpoint URL with this

    IP for each Replica.

    This part will be done for the AAG-3 and the AAG-4 (Instance AOI2 and AOI4).

    For reminder, there is only one Endpoint per Instance (can be used for multiple Availability Group).

     

    Create AAG-1 (Instance AOI1 & AOI3)Ok, now I create the first AAG (DBTest01 is the AdvWorks1 database added before)

  • 8/18/2019 AlwaysOn Availability Groups Creation

    4/11

    2/14/2016 AlwaysOn Availability Groups Creation

    http://www.tech-coffee.net/alwayson-availability-groups-creation/ 4

    Schema: AlwaysOn Availability Groups – AAG 1

    From M-SQLA1, start Management Studio, connect to instance AOI1.

    Right-click on “Availability Group” and select “New Availability Group Wizard”:

    Specify the AAG name (this will be the WSFC Resource Group name):

    Select the DB:

    Select “Add replica” 

    http://www.tech-coffee.net/wp-content/uploads/2014/05/Part-6-Availability-Group-1.png

  • 8/18/2019 AlwaysOn Availability Groups Creation

    5/11

    2/14/2016 AlwaysOn Availability Groups Creation

    http://www.tech-coffee.net/alwayson-availability-groups-creation/ 5

    Connect to the AOI3 instance:

    Enable “Automatic Failover” (Synchronous Commit must be enabled) and configure the “Readable Secondary

    Option” (For more information about parameters see chapter “ Availability Replicas Configuration” in

     “Part 2 – AlwaysOn – Lab Design “)

    Configure Endpoints (Default URL = Server FQDN => Communication on the Public network):

    Configure “Backup Preferences” (this is the default option):

  • 8/18/2019 AlwaysOn Availability Groups Creation

    6/11

    2/14/2016 AlwaysOn Availability Groups Creation

    http://www.tech-coffee.net/alwayson-availability-groups-creation/ 6

    Create the Listener:

    (When you configure later applications to host their Databases in the AAG you have to specify this Listener

    DNS Name and the Port, this is the only information known by applications).

    Note: The Listener VCO and DNS record must be prestage (see chapter “Prestage – Availability Group

    Listener” in article “Part 6 – Create AAG “)

    Select “Full” for the initial data synchronizatrion:

    Note: If the default Database paths (file and log) are not the same on all instances, the Full mode will not

    work.

    For more information see paragraph “Note for Databases/ Logs path on AAG” in the chapter “Storage” 

    on “Part 2 – AlwaysOn – Lab Design” 

    More information on Data Synchronization Page:

    Select Initial Data Synchronization Page (AlwaysOn Availability Group Wizards)

    http://msdn.microsoft.com/en-us/library/hh231021.aspx

     

    Manually Prepare a Secondary Database for an Availability Group (SQL Server)

    http://msdn.microsoft.com/en-us/library/ff878349.aspx

    http://msdn.microsoft.com/en-us/library/ff878349.aspxhttp://msdn.microsoft.com/en-us/library/hh231021.aspx

  • 8/18/2019 AlwaysOn Availability Groups Creation

    7/11

    2/14/2016 AlwaysOn Availability Groups Creation

    http://www.tech-coffee.net/alwayson-availability-groups-creation/ 7

    Click on “Script” and save it and start the creation:

    Check AAGNow you can start the Dashboard to check the Status of AAG:

    Note:  Requires Permissions to use Dashboard:

    – CONNECT

    –  VIEW SERVER STATE

    –  VIEW ANY DEFINITION

     

  • 8/18/2019 AlwaysOn Availability Groups Creation

    8/11

    2/14/2016 AlwaysOn Availability Groups Creation

    http://www.tech-coffee.net/alwayson-availability-groups-creation/ 8

     And via the WSFC Console, you can show the availability group resource group status:

    Note: Normally you should not use the WSFC Console to administer AlwaysOn Availability Groups.

    Everything (failover …) must be done via the Dashboard, Transact-SQL or PowerShell. The WSFC Console

    provides a view of the cluster state.

     

    Create AAG-2 (Instance AOI1 & AOI3)So now I will create the second Availability Group (on the same node as AAG-1).

     At the end, there will be an active database on each instance with a replica on each other s ide. So the loss

    of an instance will be supported.

     

    Schema: AlwaysOn Availability Groups – AAG 2

    From Instance M-SQLA3\AOI3

     

    Create a test DB with one table:

    -- CREATE DATABASE DBTestAOI3 ----------------------------------------------------------

    USE master;

    GO

    CREATE DATABASE DBTestAOI3

    ON

    ( NAME = DBTestAOI3_Data,

    FILENAME = 'G:\MSSQL\AOREPLICA\Data\DBTestAOI3.mdf',

    SIZE = 10MB,

    http://www.tech-coffee.net/wp-content/uploads/2014/05/Part-6-Availability-Group-2.png

  • 8/18/2019 AlwaysOn Availability Groups Creation

    9/11

    2/14/2016 AlwaysOn Availability Groups Creation

    http://www.tech-coffee.net/alwayson-availability-groups-creation/ 9

    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

     

    Do a full backup:

    -- MAKE A FULL BACKUP ------------------------------------------------------------------

    USE master

    GO

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

    GO

     

    Create the AAG-2

    Enter AAG name:

    Select the database:

     Add the replica M-SQLA1\AOI1

  • 8/18/2019 AlwaysOn Availability Groups Creation

    10/11

    2/14/2016 AlwaysOn Availability Groups Creation

    http://www.tech-coffee.net/alwayson-availability-groups-creation/ 10

    tweet

    Note that you cannot change the name or port of Endpoints (there was previously created with the first

     AAG):

    Configure Backup Preferences:

    Configure the Listener:

    Select Initial synchronization option:

    Start the Availability Grou pcreation :

    So now, the two AAG are created:

     

    Network Note:

    We can see that the Instances communications are established on the Public Network (10.0.1.0), this is due

    to the endpoints configuration:

     

    Share Note:

    The network share specify in the “Initial synchronization” page contains backup of Databases added to the

     AG. These backups can be r emoved, there are used only for the initial replica creation.

    Tagged with:  ALWAYSON    AVAILABILITY GROUP   SQL SERVER 2012/2014

    Share

    http://www.tech-coffee.net/tag/sql-server-20122014/http://www.tech-coffee.net/tag/availability-group/http://www.tech-coffee.net/tag/alwayson/https://twitter.com/share

  • 8/18/2019 AlwaysOn Availability Groups Creation

    11/11

    2/14/2016 AlwaysOn Availability Groups Creation

    Windows Azure Pack – SQLServer in AlwaysOn as aService

    January 13, 2015

    Whitepaper: Implement ahighly available private cloudto host virtual machines

    December 25, 2014

     AlwaysOn Availability GroupIntroduction

     April 27, 2014

    ABOUT GILLES MONVILLE

    Gilles Monville is a passionate of IT for many years; he works for over 10 years on Microsoft and

     VMware environments. In addition to Virtualization and Cloud computing, he loves automation

    (Orchestrator, PowerShell, Cloud deployment …)

    RELATED POSTS

    Previous:

     VM network issue in VMM 2012R 2 withIPAM integration«

      Next:

    IP Pool in Virtual Machine Manager2012R2 »

    LEAVE A REPLY

    Enter your comment here...

    https://github.com/SerreRom/TechCoffeehttps://fr.linkedin.com/in/romainserrehttps://twitter.com/RomSerrehttp://www.tech-coffee.net/feed/http://www.tech-coffee.net/storage-quality-service-windows-server-2016/http://www.tech-coffee.net/deploy-azure-stack-technical-preview-1/http://www.tech-coffee.net/create-offer-plan-get-subscription-azure-stack-technical-preview-1/http://www.tech-coffee.net/issue-deploy-azurestack-technical-preview-1-ssd/http://www.tech-coffee.net/whitepaper-understand-microsoft-hyper-converged-solution/http://www.tech-coffee.net/storage-quality-service-windows-server-2016/http://www.tech-coffee.net/deploy-azure-stack-technical-preview-1/http://www.tech-coffee.net/create-offer-plan-get-subscription-azure-stack-technical-preview-1/http://www.tech-coffee.net/issue-deploy-azurestack-technical-preview-1-ssd/http://www.tech-coffee.net/whitepaper-understand-microsoft-hyper-converged-solution/http://www.tech-coffee.net/tag/wsus/http://www.tech-coffee.net/tag/windows-server-2016/http://www.tech-coffee.net/tag/windows-server/http://www.tech-coffee.net/tag/windows-azure-pack/http://www.tech-coffee.net/tag/website-clouds/http://www.tech-coffee.net/tag/vm-role/http://www.tech-coffee.net/tag/vmm-2/http://www.tech-coffee.net/tag/virtual-machine-manager/http://www.tech-coffee.net/tag/update/http://www.tech-coffee.net/tag/teched14/http://www.tech-coffee.net/tag/system-center/http://www.tech-coffee.net/tag/sup/http://www.tech-coffee.net/tag/storage-spaces-direct/http://www.tech-coffee.net/tag/sto/http://www.tech-coffee.net/tag/sql-server/http://www.tech-coffee.net/tag/software-update-point/http://www.tech-coffee.net/tag/software-defined-storage/http://www.tech-coffee.net/tag/service-provider-foundation/http://www.tech-coffee.net/tag/security/http://www.tech-coffee.net/tag/sccm-2012-r2/http://www.tech-coffee.net/tag/sccm/http://www.tech-coffee.net/tag/scale-out-file-server/http://www.tech-coffee.net/tag/requirements/http://www.tech-coffee.net/tag/powershell/http://www.tech-coffee.net/tag/pki/http://www.tech-coffee.net/tag/nvgre-gateway/http://www.tech-coffee.net/tag/monitoring/http://www.tech-coffee.net/tag/microsoft-azure/http://www.tech-coffee.net/tag/ipam/http://www.tech-coffee.net/tag/iaas/http://www.tech-coffee.net/tag/hyper-v/http://www.tech-coffee.net/tag/high-availability/http://www.tech-coffee.net/tag/dpm-data-protection-manager/http://www.tech-coffee.net/tag/dpm-2/http://www.tech-coffee.net/tag/design/http://www.tech-coffee.net/tag/data-protection-manager/http://www.tech-coffee.net/tag/cloud/http://www.tech-coffee.net/tag/certificate/http://www.tech-coffee.net/tag/bare-metal-deployment/http://www.tech-coffee.net/tag/azure/http://www.tech-coffee.net/tag/automation/http://www.tech-coffee.net/tag/alwayson-availability-group/http://www.tech-coffee.net/tag/alwayson/http://www.tech-coffee.net/tag/altaro/http://www.tech-coffee.net/tag/adcs/http://www.tech-coffee.net/alwayson-availability-group-introduction/http://www.tech-coffee.net/whitepaper-implement-highly-available-private-cloud-host-virtual-machines/http://www.tech-coffee.net/windows-azure-pack-sql-server-in-alwayson-as-a-service/http://twitter.com/GillesMONVILLEhttp://www.tech-coffee.net/alwayson-availability-group-introduction/http://www.tech-coffee.net/whitepaper-implement-highly-available-private-cloud-host-virtual-machines/http://www.tech-coffee.net/windows-azure-pack-sql-server-in-alwayson-as-a-service/