Question
Phillip Wu · Jan 20

How do I add a database to a mirror

I want to add a database to a mirror.

Is this the correct way to do so:

set status=##Class(SYS.Mirror).AddDatabase("/db/iknow")

Is the status=0 if it worked and anything else means it failed?

Thanks for any help

Product version: IRIS 2020.2
0
0 111
Discussion (7)1
Log in or sign up to continue

Assuming you have a sync mirror established, adding new db to mirror is as simple as:

  1. Create DB on Primary.
  2. Run SYS.Mirror:AddDatabase. It returns %Status, check that it's ok with $$$ISOK(sc). It should be equal to 1.
  3. Dismount database on Primary (using SYS.Database:DismountDatabase) OR Freeze IRIS (Backup.General:ExternalFreeze).
  4. Copy IRIS.DAT to Backup.
  5. Mount database on Primary (using SYS.Database:MountDatabase) OR Thaw IRIS (Backup.General:ExternalThaw).
  6. Mount database on Backup.
  7. Activate database on Backup (SYS.Mirror:ActivateMirroredDatabase).
  8. Catchup database on Backup (SYS.Mirror:CatchupDB).

Please note that some methods accept db name, most accept db directory, and others db sfn. Please keep that in mind.

set status=##Class(SYS.Mirror).AddDatabase("/db/iknow")

I get a syntax error when I do:
IF $$$ISOK(status) {w "OK"} else {w "not OK"}

Although this works OK:
IF status {w "OK"} else {w "not OK"}

Any idea why this is so?

I get a syntax error when I do:

Are you doing this in console/terminal? Macros are not available there.

To check if you got an error in a terminal execute:

if sc=1 {w "OK"} else {w $system.Status.DisplayError(sc)}

I was running this from terminal - understood.

Thanks again.