Erlang reading remote mnesia node - erlang

I am trying to read the remote Mnesia node using an Erlang command. I am using Ubuntu 14.04 and I am running Erlang 17 OTP. I tried to start my local Mnesia node by issuing
mnesia:start().
And then I tried to connect to remote node with
mnesia.start([{extra_db_nodes, [:'abc#def.com']}]).
It returns true. Then I issue the mnesia:info(), however, it only returns the local Mnesia info. My question is how can I issue the Mnesia command to a remote node from my local node? I am wondering how I can get the Mnesia data of extra_db_nodes in my local node?

Related

Adding Hypervisor back to Failover Cluster

Somehow I removed my test hyper-visor from a two node cluster and now when i try to add it back to cluster it is not happening basically the Hyp is pointing towards CSV but not able to access it when I spin a VM and place it in a volume in that CSV. What could I be possibly doing wrong and when I try to connect to Failover Cluster which is already present from the same Hyp I am not able to connect to it with an error message that cites issues with network.
We first have to clear the cluster by running following command
Clear-ClusterNode -Name nodeName -Force
After the cluster is cleared you will be able to add the node back to the cluster.

Can one erlang VM read the data written to mnesia by another erlang VM

I am writing data to Mnesia from one erlang VM, now I started another erlang VM on same machine, can second VM read the data written to mnesia by first VM.
To share Mnesia tables the nodes must be part of the same distributed Erlang system.
The schema defines which nodes contain the data base, cf. http://erlang.org/doc/apps/mnesia/Mnesia_chap3.html#define-a-schema
Mnesia database replication is described here: http://erlang.org/doc/apps/mnesia/Mnesia_chap5.html#distribution-and-fault-tolerance.
You can use mnesia:set_master_nodes() to define where to find a table.
Ofcourse you can, here is some basic way to do it:
Start the two nodes - iex --name nodeA#127.0.0.1 and iex --name nodeB#127.0.0.1
From the terminal of node A - Node.connect :"nodeB#127.0.0.1"
From the terminal of node A - :mnesia.create_schema [node(), :"nodeB#127.0.0.1"]
For node A and node B - :mnesia.start
From the terminal of node A - create_table(Person, [attributes: [:id, :name]])
From the terminal of node B - :mnesia.dirty_write({Person, 1, "John"})
Now you can get the information that node B has written from node A through doing basic selection - :mnesia.dirty_read({Person, 1})
References:
https://elixirschool.com/en/lessons/specifics/mnesia/#
http://erlang.org/doc/apps/mnesia/

How to reconnect a crashed erlang mnesia node to cluster again?

I'm learning erlang and mnesia. I have a question: how to reconncet a "crashed" erlang mnesia node to cluster again?
Erlang/OTP 17 [erts-6.2]
What I did:
Two mnesia nodes: m11#deb83-11 and m12#deb83-12. They were connected
with each other well.
(m11#deb83-11)4> mnesia:system_info(running_db_nodes).
['m12#deb83-12','m11#deb83-11']
Then I teminated the erl shell of m12#deb83-12 by "Ctl-G" and "q"
without stopping mnesia.
After that, I restarted erl shell for m12#deb83-12 node with same
command line.
I found the restarted node m12#deb83-12 did not connect to
m11#deb83-11.
(m11#deb83-11)16> mnesia:system_info(running_db_nodes).
['m11#deb83-11']
Note 1. If i stopped mnesia in step#2, m12#deb83-12 would reconnect to m11#deb83-11 successfully after step#3)
Note 2. I did not create any table. There is only an empty schema in this cluster.
Thanks in advance!
Ming
Apparently all you need to do is connect to the other node (so that nodes(). returns the other node) and restart mnesia with mnesia:stop(). and mnesia:start()..

ejabberd clustering, Slave doesn't work when master goes down

I have setup ejabberd clustering, one is master and other is slave as described here.
I have copied .erlang.cookie and database files from master to slave.
Everything is working fine.
The issue is when I stop master node:
Then no request getting routed to slave.
When trying to restart slave node its not getting start once it down.
I get stuck here, please help me out.
Thanks
This is the standard behaviour of Mnesia. If the node you start was not the last one that was stopped in a cluster, then it does not have any way to know if it has the latest, most up to date data.
The process to start a Mnesia cluster is to start the node in reverse order in which they were shutdown.
In case the node that was last seen on Mnesia cluster cannot start or join the cluster, them you need to use a Mnesia command to force the cluster "master", that is tell it that you consider this node has the most up to date content. This is done by using Erlang command mnesia:set_master_nodes/1.
For example, from ejabberd Erlang command-line:
mnesia:set_master_nodes([node1#myhost]).
In most case, Mnesia clustering handles everything automatically. When a node goes down, the other nodes are aware and automatically keep on working transparently. The only case you need to set which node as the reference data (with set_master_nodes/1), is when this is ambiguous for Mnesia, that is either when starting only nodes that were down when there was still running nodes or when there is a netsplit.
Follow the step from below link:
http://chadillac.tumblr.com/post/35967173942/easy-ejabberd-clustering-guide-mnesia-mysql
and call the method join_as_master(NodeName) of the easy_cluster module.

How to run pman on a remote node in erlang?

I need debug my ejabberd server and I want use pman for this purpose. But I have only access via ssh and server worked in screen.
I do:
ssh mydoman#example.com
erl -sname test#localhost
(test#localhost)1> pman:start().
<0.123.0>
and it works but I need get access to 'ejabberd#localhost' node from same machine
now I press Ctrl+G
--> r'ejabberd#localhos'
--> c
(ejabberd#localhost)1> pman:start().
** exited: {startup_timeout,pman} **
And my question is - how do I run pman properly?
Pman needs access to the screen on which it runs. I understand that you are running distributed erlang on both nodes and that they are connected and know of each other. The easiest way is then to run pman locally on your node, pman:start(). There is a Nodes menu which should contain all known nodes and if you pick ejabbered#localhost you should see all the processes on that node.
Not sure about pman, but if you want to monitor a remote node I've create entop for that purpose. It might not work exactly like pman but should be close enough.
https://github.com/mazenharake/entop

Resources