Migrate MS SQL database to GCP cloud native - Cloud SQL MS SQL server (Part 2)

Migrate MS SQL database to GCP cloud native - Cloud SQL MS SQL server(Part 1) 

Set up Transactional Replication Publication

  1. In the VM Instance, Connect to On-Prem DB instance using SSMS.

Local Publication.JPG

We will now create a Publisher:

2. Expand the menu under your Instance in SSMS. Go to Replication -> Local Publications

raghavendras_0-1708935919641.png
 
3. Right Click on Local Publications and Click on “New Publication”
4. Select the Database to be Publisher.
5. On the Next Screen, Select “Transactional Publication”

raghavendras_1-1708935919661.png

6. On the next screen, you are given Objects to set up Transactional Publishing for.

raghavendras_2-1708935919127.png

7. Note the Application Changes required if any

raghavendras_3-1708935919654.png

8.You may choose to add Filtering on Table Rows in Next Window

9. On the Next screen, choose “Create Snapshot Immediately and keep the snapshot available to initialize subscription”. You can choose to run Snapshot Agent to run on schedule too

raghavendras_4-1708935919527.png

10. On the Next Page, there would be Snapshot Agent and Log Reader Agent. Give the Administrator Account to both.

raghavendras_5-1708935919083.png

 

raghavendras_6-1708935918877.png

11. On the next page, Give name to Publication and Click on Finish. Monitor the Logs to make sure there are no errors.

raghavendras_7-1708935919141.png

12. Check if Snapshot is an Agent running or not. Go to Your Publication and Right Click. If not, enable to service to start running

raghavendras_8-1708935919467.png

Set up Transactional Replication Subscription

  1. Go to your Publication and Right Click and go to Properties -> Publication Access List. Add administrator here if missing.
  2. Go to your Publication and Right Click and go to New Subscription
  3. On the next screen, select the Publication just created
  4. We need a PUSH Based Subscription. On the next window select this. There is also a PULL based subscription on Agent.

raghavendras_9-1708935919627.png

5. On the next screen, we will add Subscriber ie. our Cloud SQL Server Details. Click “Add Subscriber”.

raghavendras_10-1708935919538.png

6. On the Window that opens, give Public IP of Cloud SQL server and put authentication details for the user set.

raghavendras_11-1708935919570.png

7. Once this is created, we need to add Subscription DB. We can use “Create New DB” here.

raghavendras_12-1708935919522.png

8. Give DB information on the next screen

9. On the next screen, you will see Distribution Agent Security. For the Distribution Agent, the machine runs on-prem. So keep Windows Authentication for DOMAIN\administrator. For Connecting to Subscriber give Cloud SQL user details in “SQL Server Login”

10. Click on Finish and monitor for any errors.

raghavendras_13-1708935919683.png

Database Level Permissions

Make sure that the Database Owner is set and the user has the permissions.

This can be configured on the Database Properties

raghavendras_14-1708935919622.png

Monitoring the Subscription

Now let's have a look at the subscription status for the Replication.

  1. Go to Subscription and Right Click. Go to “Replication Monitor”. Check for any errors. There should be no authentication errors in Subscription. If there are errors, these are segregated into 3 categories.
    1. Publisher to Distributor History
    2. Distributor to Subscriber History
    3. Undistributed Command

raghavendras_15-1708935919743.png

2. For the current Example, Latency is 4 seconds

raghavendras_16-1708935919585.png

3. Connect to Cloud SQL Server using SSMS. You should be able to see the New Database with Tables being replicated.

raghavendras_17-1708935920318.png

Key Observations

  1. For Creating new Users and correcting Server Names, SQL Server Restart might be needed on the Node.
  2. Network Connectivity will be critical to make sure Cloud SQL is reachable from On-Prem
  3. We would need a DB User Account for logging in from Cloud SQL to On-Prem and handling credentials for that.
  4. To prevent overload of the server, this process should be done in OFF Hours.
  5. DB Owner for the set up Databases needs to be accessed and modified if required. This is required for Publisher to Distributor Flow.
  6. Snapshot Agent and Log Reader Agent should already be running and not stopped.
  7. Cloud SQL DB should be HA by default
  8. Authentication to Cloud SQL can also be done using AD accounts.

raghavendras_18-1708935919357.png

References

Contributors
Version history
Last update:
‎02-26-2024 01:12 AM
Updated by: