I created a Mnesia database / Schema on machine1. The node was named mypl@machine1. I then moved all files to machine2, because machine1 broke down. Everything runs fine as long as the code is running with the name "mypl@machine1". Obviously this is somewhat confugsing, because it is now running on machine2.
If I start Erlang with the node name "mypl@machine2" the Mnesia Database appears being empty.
How do I rename the node in a Mnesia Database from machine1 to machine2?
Workaround is migration. Just start mnesia cluster and migrate all your tables and schema to other node. Than remove from original and forgot.
I don't think this can be done online on a single node(anyone?), but it is possible to do via a backup/restore in addition to running two nodes and adding table copies. In the Mnesia User's guide section 6.9.1 you'll find some code that uses mnesia:traverse_backup to alter the node names in the schema table (Shown below) in an mnesia backup file. The module name you should probably use is
mnesia_backup
.With this code you'll need to:
I'm not sure if you need to create the schema first on
mypl@machine2
.The change node name code from the user's guide: