SQL Server AlwaysOn AG automatic Initialization (iii)

Source: Internet
Author: User

to create an availability group with automatic seeding


1. Create an Endpoint

Each replica requires a mirroring endpoint for communication, and the default TCP port is 5022.

CREATE ENDPOINT [Hadr_endpoint]state=startedas TCP (Listener_port = 5023, listener_ip = All) for data_mirroring (ROLE = All , authentication = WINDOWS negotiate,encryption = REQUIRED algorithm AES) GO


2. Create an availability group

Executes on the primary replica

Create availability group [app1on]for database app1customers, app1salesreplica  onn ' test-gs-zhxt1\sql2017 '  -- primaryWITH  (endpoint_url = n ' tcp:// test-gs-zhxt1.jztest.com:5023 ', Failover_mode = automatic,availability_mode = synchronous_ Commit,backup_priority = 50,primary_role (Allow_connections = all), SEEDING_MODE =  automatic), N ' test-gs-zhxt2\sql2017 '  -- secondaryWITH  (endpoint_url = n ' tcp:// test-gs-zhxt2.jztest.com:5023 ', Failover_mode = automatic,availability_mode = synchronous_ Commit,backup_priority = 50,secondary_role (Allow_connections = all), SEEDING_MODE =  automatic), N ' test-gs-zhxt3\sql2017 '  -- secondaryWITH  (endpoint_url = n ' tcp:// test-gs-zhxt3.jztest.com:5023 ', Failover_mode = manual,availability_mode = asynchronous_ Commit,backup_priority = 50,secoNdary_role (Allow_connections = all), seeding_mode = automatic), N ' TEST-GS-ZHXT4\SQL2017 '  -- secondaryWITH  (endpoint_url = n ' tcp://test-gs-zhxt4.jztest.com:5023 ', failover_ MODE = MANUAL,AVAILABILITY_MODE = ASYNCHRONOUS_COMMIT,BACKUP_PRIORITY = 50, Secondary_role (Allow_connections = all), seeding_mode = automatic); GO

The above script creates the availability group App1on, and joins the database App1customers and App1sales.

From the Create Availability group syntax

CREATE Availability GROUP Group_name

With (<with_option_spec> [,... n])

for [DATABASE database_name [,... N]]

REPLICA on <add_replica_spec> [,... N]

You can omit database database_name [,... n], create an availability group, and then add the specific databases in the 4th step.


3. Join the secondary server instance to the availability group and grant the availability group permission to create the database.

Execute on each secondary replica

ALTER Availability Group App1on joingoalter availability Group App1on GRANT CREATE any Databasego


4. Add the database to the availability group.

Executes on the primary replica

ALTER availability GROUP app1on ADD DATABASE app2customers; GO

SQL Server will automatically create a copy of the database on the secondary server. If the database is large, it may take some time to complete the database synchronization.

SQL Server AlwaysOn AG automatic Initialization (iii)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.