How to add new nodes after creating amnesia database

Hey, following @jmerriweather Elixir + Phoenix + Amnesia + Multi-node everything works awesome. However I just got one idea and I do not see any way to solve it. I would like to firstly setup amnesia only for n1@ node (following naming in example code) and later decide to add n2@ node and sync it with n1@

Note: When syncing I expect n2@ to not have any database even created, so there would be no data conflict. I just want to know how to run synced database copy on newly created node.

I would like to do so for example when I’m working on private project on one device and later decide to buy another one and connect it to first device in order to do more things at same time and sync results of all devices, so I can finally connect my PC, create database, sync it and fetch all results from all devices at once.

Maybe what you are looking for.

Mnesia dynamic node membership


@cohawk: Thank you very much!

Looks like amnesia does not implements or simply delegates :mnesia.change_config/2 function, so I did not found it in amnesia documentation. There is coming one small problem which I have already resolved. When doing that only :schema table is saved and it’s saved in memory only! In order to create a mnesia directory we need to:

  1. Amnesia.Table.copying(:schema, node(), :disk) which changes :schema table type and saves it on disc
  2. For each table (except :schema) we need to call Amnesia.Table.add_copy(table, node(), :disk)
1 Like