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
Comments
Assuming you have a sync mirror established, adding new db to mirror is as simple as:
- Create DB on Primary.
- Run SYS.Mirror:AddDatabase. It returns %Status, check that it's ok with $$$ISOK(sc). It should be equal to 1.
- Dismount database on Primary (using SYS.Database:DismountDatabase) OR Freeze IRIS (Backup.General:ExternalFreeze).
- Copy IRIS.DAT to Backup.
- Mount database on Primary (using SYS.Database:MountDatabase) OR Thaw IRIS (Backup.General:ExternalThaw).
- Mount database on Backup.
- Activate database on Backup (SYS.Mirror:ActivateMirroredDatabase).
- 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.
Thanks for the fast reply
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.
Sorry, what is 'db sfn'?
Is there a way to avoid copying iris.dat? That is, can the two databases be created separately and then set up as mirrored?
Well, I have great news for you, Otto!
Starting from 2025.1, we have automatic database download from mirror member. Documentation. No copying required.
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.