How to remove database from Always On in Distributed Availability Group

Hi Mates,

This is very simple post and it helps you in removing Database from Distributed AG.

We have 3 replicas in one Data center and the other 3 in Different DC. As you know in Multi-subnet there will be one windows cluster that will be spanned across different networks. But in DAG we can have 2 different windows clusters and each of them will have it's own AG's .

I added a database to DAG and now my requirement is to remove it and then restore Database with fresh copy there after adding it back again to DAG.

Steps will differ here as we have the concept of forwarder replica in DAG.

1) On the forwarder replica we need to run the below command

    ALTER DATABASE [DBNAME] SET HADR OFF

    This will leave the database in restoring state on 3 replicas (forwarder and the secondary replicas)

2) Now connect to primary Replica of primary Availability Group and run the command

  ALTER AVAILABILITY GROUP [XXX] REMOVE DATABASE [XXX] 

This will work in similar norms to that of traditional AG which means online state on Primary and restoring on Secondary replicas

Finally we will have database in online state on primary replica of (primary AG) and remaining all(5 in my case) of them will be in restoring state

When I was adding the database to DAG I got the below error 

Msg 1408, Level 16, State 211, Line 3

The remote copy of database "XXXXXXX" is not recovered far enough to enable database mirroring or to join it to the availability group. 

You need to apply missing log records to the remote database by restoring the current log backups from the principal/primary database. 

This is a straight forward error and many people would like to go with log backups however just to let you know we can bridge the gap even with Differential as well.

In case if you want to know how the log backups works on DAG below is the link for the same.

https://www.chiranjeevivamsydba.com/2020/06/ola-hallengren-script-for-distributed.html

Thanks for Reading.

Comments