<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I would like to refine my question a bit. The real problem that I am having is how to share an mnesia db between two nodes that already have their own databases:<div class=""><br class=""></div><div class="">I have 3 erlang nodes, 2 are emqtt brokers and 1 is a special node for setting up a key value store. The 2 emqtt brokers have instances of mnesia running that are disc copies, and they need to be able to get a copy of a table from the mnesia database running on the special node.<br class=""><br class="">I have read through all of the questions on stack pertaining to this but have yet to find a way to share a database across nodes from one central node.<br class=""><br class=""><br class="">I have tried copying tables to my emqtt instances using add_table_copy(device, '<a href="mailto:emqttd@127.0.0.1" class="">emqttd@127.0.0.1</a>', ram_copies), but I get the error that my device table already exists, when it does not: Special Node:<br class="">------------------------------------------------------------------------------------------------------------------------------------------------------------<br class=""><b class="">(ryan@127.0.0.1)35> mnesia:add_table_copy(device, '<a href="mailto:emqttd@127.0.0.1" class="">emqttd@127.0.0.1</a>', ram_copies).</b><div class=""><b class=""><br class=""></b></div><div class=""><b class="">{aborted</b></div><b class="">,{already_exists,device,'<a href="mailto:emqttd@127.0.0.1" class="">emqttd@127.0.0.1</a>'}}<br class="">Emqtt:<br class=""><br class="">    (emqttd@127.0.0.1)2> mnesia:info().</b><div class="">------------------------------------------------------------------------------------------------------------------------------------------------------------</div><div class=""><b class="">---> </b></div><b class="">Processes</b><div class=""><b class=""> holding locks <--- </b></div><div class=""><b class="">---> </b></div><b class="">Processes</b><div class=""><b class=""> waiting for locks <--- </b></div><div class=""><b class="">---> </b></div><b class="">Participant</b><div class=""><b class=""> transactions <--- </b></div><div class=""><b class="">---> </b></div><b class="">Coordinator</b><div class=""><b class=""> transactions <---</b></div><div class=""><b class="">---> </b></div><b class="">Uncertain</b><div class=""><b class=""> transactions <--- </b></div><div class=""><b class="">---> </b></div><b class="">Active</b><div class=""><b class=""> tables <--- </b></div><div class=""><b class="">mqtt_admin     : with </b></div><b class="">1        records occupying 326      words of</b><div class=""><b class=""> mem</b></div><div class=""><b class="">mqtt_retained  : with </b></div><b class="">3        records occupying 194      words of</b><div class=""><b class=""> mem</b></div><div class=""><b class="">mqtt_route     : with </b></div><b class="">0        records occupying 304      words of</b><div class=""><b class=""> mem</b></div><div class=""><b class="">mqtt_topic     : with </b></div><b class="">0        records occupying 304      words of</b><div class=""><b class=""> mem</b></div><div class=""><b class="">mqtt_session   : with </b></div><b class="">0        records occupying 304      words of</b><div class=""><b class=""> mem</b></div><div class=""><b class="">mqtt_trie_node : with </b></div><b class="">0        records occupying 304      words of</b><div class=""><b class=""> mem</b></div><div class=""><b class="">mqtt_trie      : with </b></div><b class="">0        records occupying 304      words of</b><div class=""><b class=""> mem</b></div><div class=""><b class="">schema         : with </b></div><b class="">8        records occupying 1273     words of</b><div class=""><b class=""> mem</b></div><div class=""><b class="">===> </b></div><b class="">System info in version "4.14.2",</b><div class=""><b class=""> debug level = none <===</b></div><div class=""><b class="">opt_disc</b></div><b class="">. Directory "/<a href="mailto:Users/ryanauger/repos/emq-relx/_rel/emqttd/data/mnesia/emqttd@127.0.0.1" class="">Users/ryanauger/repos/emq-relx/_rel/emqttd/data/mnesia/emqttd@127.0.0.1</a>" is used.</b><div class=""><b class=""><br class=""></b></div><div class=""><b class="">use fallback at restart = false</b></div><div class=""><b class="">running db nodes   = [</b></div><b class="">'<a href="mailto:emqttd@127.0.0.1" class="">emqttd@127.0.0.1</a>'</b><div class=""><b class="">]</b></div><div class=""><b class="">stopped db nodes   = [] </b></div><div class=""><b class="">master node tables = []</b></div><div class=""><b class="">remote             = []</b></div><div class=""><b class="">ram_copies         = [mqtt_retained</b></div><b class="">,mqtt_route,mqtt_session,mqtt_topic,</b><div class=""><b class=""><br class=""></b></div><div class=""><b class="">                      mqtt_trie</b></div><b class="">,</b><div class=""><b class="">mqtt_trie_node]</b></div><div class=""><b class="">disc_copies        = [mqtt_admin</b></div><b class="">,</b><div class=""><b class="">schema]</b></div><div class=""><b class="">disc_only_copies   = []</b></div><div class=""><b class="">[{</b></div><b class="">'<a href="mailto:emqttd@127.0.0.1" class="">emqttd@127.0.0.1</a>',disc_copies}] = [schema,</b><div class=""><b class="">mqtt_admin]</b></div><div class=""><b class="">[{</b></div><b class="">'<a href="mailto:emqttd@127.0.0.1" class="">emqttd@127.0.0.1</a>',ram_copies}] = [mqtt_trie,mqtt_trie_node,mqtt_session,</b><div class=""><b class=""><br class=""></b></div><div class=""><b class="">                                     mqtt_topic</b></div><b class="">,mqtt_route,</b><div class=""><b class="">mqtt_retained]</b></div><b class=""><br class="Apple-interchange-newline">10 transactions committed, 2 aborted, 0 restarted, 15</b><div class=""><b class=""> logged to disc</b></div><b class=""><br class="Apple-interchange-newline">0 held locks, 0 in queue; 0 local transactions, 0</b><div class=""><b class=""> remote</b></div><b class=""><br class="Apple-interchange-newline">0</b><div class=""><b class=""> transactions waits for other nodes: []</b></div><div class=""><b class="">ok</b></div>---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br class="">How would I go about sharing the tables from this database? Based on my research, it seems like it may not be possible with mnesia. If so, please suggest another tool that can integrate with erlang!</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jul 26, 2017, at 3:37 PM, code wiget <<a href="mailto:codewiget95@gmail.com" class="">codewiget95@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hello,<br class=""><br class="">For background, right now I have two instances of emqtt running on two separate computers on the same network. I have written an Erlang program to create an mnesia instance and a shared table between them, as I need to be able to access an important key value store from both instances.<br class=""><br class="">The problem is that I can use net_kernel:connect_node(‘emqttd@whatever’). to connect the nodes, which is successful, but then when I try to use amnesia:create table with disc copies on all of those nodes, I get an error that the nodes I am connecting to are not active. Below I will illustrate the flow:<br class=""><br class="">connect_all_nodes(Nodelist)<br class="">nodes() is now = Nodelist<br class="">mnesia:create_schema([node()]) — create a scheme on the local, non-emqtt instance (cannot add other nodes as they have their own mnesia DB’s running)<br class="">Start mnesia<br class="">mnesia:Create_table(device, [{attributes, record_info(fields, device)}, <br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">    </span><span class="Apple-tab-span" style="white-space:pre">    </span><span class="Apple-tab-span" style="white-space:pre">    </span><span class="Apple-tab-span" style="white-space:pre">    </span><span class="Apple-tab-span" style="white-space:pre">    </span>{disc_copies, nodes()},<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">    </span><span class="Apple-tab-span" style="white-space:pre">    </span><span class="Apple-tab-span" style="white-space:pre">    </span><span class="Apple-tab-span" style="white-space:pre">    </span><span class="Apple-tab-span" style="white-space:pre">    </span>{type, set}]).<br class=""><br class="">— this last command fails with the error:{aborted,{not_active,iot_device,’emqttd@host’}}<br class="">—How is it possible that my node thinks this device is not active if I have already connected the nodes, verified that nodes() has been populated, and I’ve even tested using net_admn ping and I get a pong.<br class=""><br class="">How do I get them to truly recognize each other?<br class=""><br class=""><br class="">Thank you for your help!</div></div></blockquote></div><br class=""></div></body></html>