Mnesia Replication with local content

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Mnesia Replication with local content

Prakash Parmar-3
Hello All,

According to my project requirements, I have Two mnesia nodes namely 'node1@TH1574U' and 'node2@TH1574U'. I want to create a Mnesia table with local content and same table name on both nodes.

Here are the Steps I'm following :

In One Terminal  -  $ erl -sname node1 -setcookie abc

On another Terminal - $ erl -sname node2 -setcookie abc

=====================================================================================

(node1@TH1574U)1> net_adm:ping('node2@TH1574U').
pong
 
(node1@TH1574U)2> nodes().
[node2@TH1574U]

(node1@TH1574U)3> mnesia:create_schema(['node1@TH1574U', 'node2@TH1574U']).
ok

(node1@TH1574U)4> rpc:multicall(['node1@TH1574U', 'node2@TH1574U'], mnesia, start,[]).
{[ok,ok],[]}

(node1@TH1574U)5> mnesia:create_table( log_count,[{attributes, [counter, value]},{local_content, true},{disc_copies, ['node1@TH1574U','node2@TH1574U']}]).  
{atomic,ok}

(node1@TH1574U)6> mnesia:info().                                                                                                                      ---> Processes holding locks <---
---> Processes waiting for locks <---
---> Participant transactions <---
---> Coordinator transactions <---
---> Uncertain transactions <---
---> Active tables <---
log_count      : with 0        records occupying 298      words of mem
schema         : with 2        records occupying 530      words of mem
===> System info in version "4.14.3", debug level = none <===
opt_disc. Directory "/home/user/svn/mvpn-1.1/Mnesia.node1@TH1574U" is used.
use fallback at restart = false
running db nodes   = [node2@TH1574U,node1@TH1574U]
stopped db nodes   = []
master node tables = []
remote             = []
ram_copies         = []
disc_copies        = [log_count,schema]
disc_only_copies   = []
[{node1@TH1574U,disc_copies}] = [log_count]
[{node1@TH1574U,disc_copies},{node2@TH1574U,disc_copies}] = [schema]
4 transactions committed, 2 aborted, 0 restarted, 5 logged to disc
0 held locks, 0 in queue; 0 local transactions, 0 remote
0 transactions waits for other nodes: []
ok
=====================================================================================

Can anyone help me out why Table is not getting created on a 2ndnode?

When I removed option {local_content, true} that table getting created on a 2nd node.

Is there another way to achive this?

/Prakash Parmar


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Mnesia Replication with local content

Dan Gudmundsson-2
If you do mnesia:info() on node2@TH1574U, it will list the table 'log_count' there as well.
Each node have a "local" 'log_count' table that is not visible on the other nodes.



On Wed, May 16, 2018 at 2:37 PM Prakash Parmar <[hidden email]> wrote:
Hello All,

According to my project requirements, I have Two mnesia nodes namely 'node1@TH1574U' and 'node2@TH1574U'. I want to create a Mnesia table with local content and same table name on both nodes.

Here are the Steps I'm following :

In One Terminal  -  $ erl -sname node1 -setcookie abc

On another Terminal - $ erl -sname node2 -setcookie abc

=====================================================================================

(node1@TH1574U)1> net_adm:ping('node2@TH1574U').
pong
 
(node1@TH1574U)2> nodes().
[node2@TH1574U]

(node1@TH1574U)3> mnesia:create_schema(['node1@TH1574U', 'node2@TH1574U']).
ok

(node1@TH1574U)4> rpc:multicall(['node1@TH1574U', 'node2@TH1574U'], mnesia, start,[]).
{[ok,ok],[]}

(node1@TH1574U)5> mnesia:create_table( log_count,[{attributes, [counter, value]},{local_content, true},{disc_copies, ['node1@TH1574U','node2@TH1574U']}]).  
{atomic,ok}

(node1@TH1574U)6> mnesia:info().                                                                                                                      ---> Processes holding locks <---
---> Processes waiting for locks <---
---> Participant transactions <---
---> Coordinator transactions <---
---> Uncertain transactions <---
---> Active tables <---
log_count      : with 0        records occupying 298      words of mem
schema         : with 2        records occupying 530      words of mem
===> System info in version "4.14.3", debug level = none <===
opt_disc. Directory "/home/user/svn/mvpn-1.1/Mnesia.node1@TH1574U" is used.
use fallback at restart = false
running db nodes   = [node2@TH1574U,node1@TH1574U]
stopped db nodes   = []
master node tables = []
remote             = []
ram_copies         = []
disc_copies        = [log_count,schema]
disc_only_copies   = []
[{node1@TH1574U,disc_copies}] = [log_count]
[{node1@TH1574U,disc_copies},{node2@TH1574U,disc_copies}] = [schema]
4 transactions committed, 2 aborted, 0 restarted, 5 logged to disc
0 held locks, 0 in queue; 0 local transactions, 0 remote
0 transactions waits for other nodes: []
ok
=====================================================================================

Can anyone help me out why Table is not getting created on a 2ndnode?

When I removed option {local_content, true} that table getting created on a 2nd node.

Is there another way to achive this?

/Prakash Parmar

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

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