Re-establish one database in an Availability group

  • I've got an availability group with multiple databases, replicating to multiple secondary servers. On one of the secondary servers, some of the databases are not synchronising, and when we try re-establish the sync we get an LSN error. I can't see any obvious way to re-establish only one database on one secondary without affecting all databases on that secondary or affecting that database on all secondary nodes. Am I missing something?

    The options I seem to have are to either remove the database and then re-add it, in which case this affects all secondary replicas, or to remove the secondary replica and add it, in which case all the DBs are added.

    Does anyone have an answer?

    Leo

    Leo
    Nothing in life is ever so complicated that with a little work it can't be made more complicated.

  • You can easily remove a single DB from an AG secondary replica, and then add it back. I've mostly used SSMS GUI for this, but I'm sure the TSQL is simple if you prefer that route.

    Once removed you can add it back the same way you initially added your DBs to this secondary replica.

    To add DBs to the secondary replica I usually do this: temporarily suspend txlog backups, restore DB on the secondary replica from a full backup with recovery, set the replica DB's dbowner, trustworthy, and chaining settings, recover from the same backup again this time with norecovery, then use SSMS GUI to join the replica DB to the AG (or use ALTER DATABASE [your db] SET HADR AVAILABILITY GROUP = [your ag]), and finally resume normal txlog backups. If you don't use chaining or care about DB ownership you can skip the multiple restores, and just restore with norecovery the first time.

  • what I added above applies to a single replica, not all replicas.

    If you removed the DB from the AG on the primary...that would remove it from all replicas.

    But you are free to remove a DB from a single replica without affecting other replicas.

  • This was removed by the editor as SPAM

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply