Node not active but is connected

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Node not active but is connected

asdf asdf
Hello,

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.

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:

connect_all_nodes(Nodelist)
nodes() is now = Nodelist
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)
Start mnesia
mnesia:Create_table(device, [{attributes, record_info(fields, device)},
                                                {disc_copies, nodes()},
                                                {type, set}]).

— this last command fails with the error:{aborted,{not_active,iot_device,’emqttd@host’}}
—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.

How do I get them to truly recognize each other?


Thank you for your help!
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Node not active but is connected

asdf asdf
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:

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.

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.


I have tried copying tables to my emqtt instances using add_table_copy(device, '[hidden email]', ram_copies), but I get the error that my device table already exists, when it does not: Special Node:
------------------------------------------------------------------------------------------------------------------------------------------------------------
(ryan@127.0.0.1)35> mnesia:add_table_copy(device, '[hidden email]', ram_copies).

{aborted
,{already_exists,device,'[hidden email]'}}
Emqtt:

    (emqttd@127.0.0.1)2> mnesia:info().
------------------------------------------------------------------------------------------------------------------------------------------------------------
---> 
Processes
 holding locks <--- 
---> 
Processes
 waiting for locks <--- 
---> 
Participant
 transactions <--- 
---> 
Coordinator
 transactions <---
---> 
Uncertain
 transactions <--- 
---> 
Active
 tables <--- 
mqtt_admin     : with 
1        records occupying 326      words of
 mem
mqtt_retained  : with 
3        records occupying 194      words of
 mem
mqtt_route     : with 
0        records occupying 304      words of
 mem
mqtt_topic     : with 
0        records occupying 304      words of
 mem
mqtt_session   : with 
0        records occupying 304      words of
 mem
mqtt_trie_node : with 
0        records occupying 304      words of
 mem
mqtt_trie      : with 
0        records occupying 304      words of
 mem
schema         : with 
8        records occupying 1273     words of
 mem
===> 
System info in version "4.14.2",
 debug level = none <===
opt_disc
. Directory "/[hidden email]" is used.

use fallback at restart = false
running db nodes   = [
'[hidden email]'
]
stopped db nodes   = [] 
master node tables = []
remote             = []
ram_copies         = [mqtt_retained
,mqtt_route,mqtt_session,mqtt_topic,

                      mqtt_trie
,
mqtt_trie_node]
disc_copies        = [mqtt_admin
,
schema]
disc_only_copies   = []
[{
'[hidden email]',disc_copies}] = [schema,
mqtt_admin]
[{
'[hidden email]',ram_copies}] = [mqtt_trie,mqtt_trie_node,mqtt_session,

                                     mqtt_topic
,mqtt_route,
mqtt_retained]

10 transactions committed, 2 aborted, 0 restarted, 15
 logged to disc

0 held locks, 0 in queue; 0 local transactions, 0
 remote

0
 transactions waits for other nodes: []
ok
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
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!




On Jul 26, 2017, at 3:37 PM, code wiget <[hidden email]> wrote:

Hello,

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.

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:

connect_all_nodes(Nodelist)
nodes() is now = Nodelist
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)
Start mnesia
mnesia:Create_table(device, [{attributes, record_info(fields, device)},
{disc_copies, nodes()},
{type, set}]).

— this last command fails with the error:{aborted,{not_active,iot_device,’emqttd@host’}}
—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.

How do I get them to truly recognize each other?


Thank you for your help!


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Loading...