Written by

Question Phillip Wu · Jan 20, 2023

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

Comments

Eduard Lebedyuk · Jan 20, 2023

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.

0
Phillip Wu  Jan 20, 2023 to Eduard Lebedyuk

Thanks for the fast reply

0
Phillip Wu  Jan 20, 2023 to Eduard Lebedyuk

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?

0
Eduard Lebedyuk  Jan 20, 2023 to Phillip Wu

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)}
0
Phillip Wu  Jan 20, 2023 to Eduard Lebedyuk

I was running this from terminal - understood.

Thanks again.

0
Phillip Wu  Jan 24, 2023 to Eduard Lebedyuk

Sorry, what is 'db sfn'?

0
Otto Medin  May 5, 2025 to Eduard Lebedyuk

Is there a way to avoid copying iris.dat? That is, can the two databases be created separately and then set up as mirrored?

0
Eduard Lebedyuk  May 6, 2025 to Otto Medin

Well, I have great news for you, Otto!

Starting from 2025.1, we have automatic database download from mirror member. Documentation. No copying required.

0
Scott Roth  Jun 6, 2025 to Eduard Lebedyuk

I dismounted, secure copied the IRIS.dat to my backup/DR and mount the Database, but when I attempt to Activate Mirror Database on the backup, I am getting the following error...

sc="0 "_$lb($lb(2073,"/ensemble/TEST/DB/TESTING/",,,,,,,,$lb(,"%SYS",$lb("e^ActivateMirroredDatabase+3^SYS.Mirror.1^2","e^^^0"))))/* ERROR #2073: Mirrored Database '/ensemble/TEST/DB/TESTING/' is not found on this system */
 

but it shows that the database has been mounted in the Terminal.

0