Archive

Posts Tagged ‘SQL Azure Replication’

Transactional Replication: Replicate On-Premise SQL Server databases to SQL Azure databases

October 27, 2017 Leave a comment

Transactional replication to SQL Azure Database is now available as of Oct 23, 2017, This feature will help us in replicating/migrating data from On-Premise SQL Server databases to SQL Azure databases with minimal impact and downtime

In this post we will see the following

1. Setup new publisher and configure new distributor

2. Add SQL Azure Database as Subscriber

For this demo we are using

Tools/Servers Used

On-Premise SQL Server 2017 Developer Edition

SQL Azure Database

SQL Server Management Studio 2017 v 17.3

How to Setup new publisher and configure new distributor

 

Step 1: Please connect to the On-Premise SQL Server on which we are planning to publish the data, Right click on Replication and click on New –> Publication

capture20171026125922682

 

Step 2: Click next to continue

capture20171025093756535

Step 3: We are going to configure the publisher to act as Distributor as well, but if you prefer to use a different server, use the 2nd option

After selecting, Please click Next to continue

capture20171025093802802

Step 4: By default SQL Server will create the ReplData folder under Data folder, but if you prefer to use a different folder, Please change it

Please make sure the Process account which you are planning to use and SQL Server service account has rights to Read/Write to this folder else you Replication Snapshot job will fail to generate scripts

capture20171025093808736

Step 5: Please select the database from which we need to publish data, In this demo we are using database “Demo”

After selecting the database click “Next” to proceed

capture20171025093817202

Step 6:  Please select “Transactional Publication” and click “Next” to proceed

capture20171025093823858

Step 7: Please select the required objects, you wish to replicate, we will use Customers table for this demo, after selecting the required objects, Please click “Next” to continue

capture20171025094712912

Step 8: This is an optional step, if you want only filtered data to be replication, Please click on “Add…” add relevant filters

In this demo, we are going to replicate the entire table, so we will skip this and click “Next” to continue

capture20171025093902119

Step 9: Please select the first option to create the initial snapshot and then use the 2nd option to setup the schedule in which the snapshot agent needs to run

Please click “Change…” to setup the schedule details

capture20171025094004761

For this demo, we are setting it up to 24 hours/day for every 30 minutes

capture20171025093958343

After configuring the schedule, Please click “Next” to proceed

Step 10: In this step we will be configuring the Snapshot and Log Reader Agent security settings

Click on “Security Settings…” to configure

If you want to use 2 different account for Snapshot agent and Log Reader agent, please unselect “Use the security settings from the Snapshot Agent” and use “Security Settings…” for Log Reader Agent

capture20171025094552399

Please provide the Windows User account to run the Snapshot Agent

capture20171025094537848

After providing the details, click “Ok” to close and then review the user name provided and click “Next” to continue

Step 11: By default “Create the publication” option will be selected, Please select “Generate a script file with steps to create the publication” if you prefer to run the script manually

capture20171025094603896

If you selected the 2nd option, Please specify the path where you want the script to be created and click “Next” to continue

capture20171025094612146

Step 12: Please provide the Publication Name and review the settings and click “Finish” to start the publisher/distributor configuration process

capture20171025094629258

We can see the progress for each steps

capture20171025094635981

After all steps are completed, we should see the Success message and click “Close” to continue

capture20171025094745397

Step 13: To verify the created publication, Please refresh the Local Publications node under Replication and you should see the newly created Publication

capture20171026124457112

We have successfully created the Publication now, you can verify the status of initial snapshot scripts creating by verifying the job status in SQL Server Agent – Job Activity Monitor

We can see the highlighted job as completed Successfully

capture20171026132659759

How to setup SQL Azure Database as Subscriber

We will now see how to create a new SQL Azure Database subscriber

Step 1: Right click on the Replication –> Local Publications –> Publication Name and click on “New Subscriptions…”

 

capture20171026124759159

 

Step 2: Click “Next” to continue

capture20171025094823157

 

Step 3: Please review the selected Publisher and Publication and click “Next” to continue

capture20171025094828599

Step 4: Please select “Run all agents at the Distributor” option and click “Next” to continue

capture20171025094835370

Step 5: Click on “Add Subscriber

capture20171025094903713

Click on “Add SQL Server Subscriber”

capture20171025094910631

Please provide the SQL Azure Database server name and select SQL Server Authentication and provide the user name and password and click “Connect” to continue

capture20171025095231591

 

Step 6: Please select the Subscription Database and click “Next” to continue

capture20171025143325718

Step 7: Please click  “…” button to configure the Distribution Agent security

capture20171025143431898

Please provide the windows user name to run the process account in Distributor Agent

For “Connect to the Subscriber”, Please provide the SQL Server Login account to connect

capture20171025143419741

Please click “Ok” and then review the selected settings and click “Next” to continue

Step 8: Please specify the Agent Schedule and click “Next” to continue

capture20171025143445700

Step 9: Please select “Initialize” and select “Immediately” for Initialize When, Please choose this accordingly if your snapshot agent job is completed or not

Click “Next” to continue

capture20171025143505239

Step 10: By default “Create the subscription(s)” will be selected, if you prefer to create the subscription manually using script, Please select Generate Script option and click “Next” to continue

capture20171025143513271

Please provide the script path and click “Next” to continue

capture20171025143518278

Step 11: Please review the settings and click “Finish” to start the process

capture20171025143522741

Once the process is complete, Please refresh the publication to see the Subscription

capture20171025144459332

After the Replication Distribution job is run, Please connect to SQL Azure database to see the Table is created in SQL Azure database

capture20171025144542960

In next post, we will see how to monitor the Replication, we will also make changes to local data and see the changes being replicated to SQL Azure

Hope you find this post helpful !!!

Synchronize or Replicate Databases in SQL Azure across Servers

May 9, 2011 Leave a comment

SQL Azure Data Sync is an incubation project in SQL Azure Labs, which provides Hub – Member model based to synchronize databases from one SQL Azure server to another. You can replicate data from one Hub server to multiple member servers.

You can sign up for free beta account in http://www.sqlazurelabs.com/

In this post, we will see how to use SQL Azure Data Sync to synchronize Northwind_DB from Server A to Server B

Step 1 : Once signed up and setup your account, click on “SQL Azure Data Sync” tab

image

Step 2: Click “Add New” to create a new Synchronization group

image

Enter Sync Group Name and click Next

Step 3: Click on “Register New Server” to add Hub Server

image

Repeat Step 3 to add Member Server

Step 4: Select the Hub Server and Member Server to participate in Sync Group and then select the database as well

image

Once defined the servers and database, click “Next” to proceed

For one Sync Group job, you can have only one Hub server, but you can define multiple jobs to use the Member server as Hub Server in another job

Step 5: Select the tables you want to Sync and click “Finish”

image

Now you have successfully defined the Sync Group job

image

Now you can manually run the Sync for first time by clicking on “Sync Now” button

To automatically setup the Sync job to run on specific schedules, click on “Schedule Sync” option

image

You can setup the job, to run Daily at specific time or Monthly on specific day and time, or Hourly or Weekly on specified days at specified time, once selected your preferred schedule, click “Ok” to proceed

If you double click on the “Sync Demo Group”, you can view the details and log of the job

image

Click “View Log” to see detailed log

Starting new job. Job ID = 2ccec979-3848-48f5-b0f6-73a90a8ae1d2

Retrieved ScopeName as 625dec91-cd29-465c-98de-e1fe4be221b9

Retrieved Hubendpoint as SERVERA.database.windows.net,Northwind_DB,625dec91-cd29-465c-98de-e1fe4be221b9

Retrieving DbSyncScopeDescription from Hub

Checking to see if Scope 625dec91-cd29-465c-98de-e1fe4be221b9 exists in endpoint SERVERB.database.windows.net,Northwind_DB

    Scope doesnt exist. Provisioning server.

Synchronizing Endpoint SERVERB.database.windows.net,Northwind_DB ==> HUB. Conflict Endpoint wins
    Total Changes Transferred = 0, Total Changes Failed = 0.
    Sync time (in seconds): 5.9.

Synchronizing HUB ==> Endpoint SERVERB.database.windows.net,Northwind_DB. Conflict HUB wins
    Total Changes Transfered = 217, Total Changes Failed = 0.
    Sync time (in seconds): 6.2.

I hope you all find this information useful. Please don’t use this yet for production, since its an incubation project.

%d bloggers like this: