4

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:

  1. Then no request getting routed to slave.
  2. When trying to restart slave node its not getting start once it down.

I get stuck here, please help me out. Thanks

Mickaël Rémond
  • 9,035
  • 1
  • 24
  • 44
Dharmraj
  • 164
  • 1
  • 15

2 Answers2

6

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.

Mickaël Rémond
  • 9,035
  • 1
  • 24
  • 44
  • Thanks Michael, but what happened when master and slave both are running simultaneously and master goes down. In this case slave should work right? – Dharmraj Jan 11 '16 at 09:43
  • Yes, that's the purpose of clustering. Mnesia is multimaster. There is no real master, but it need to protect consistency of data and make sure it will not destroy the data. When one node goes down, there is no consistency issue for the remaining node. – Mickaël Rémond Jan 11 '16 at 17:28
  • Thanks Mickael, got that. When one node to goes down, the remain node need to set as master, because there is no consistency issue for remaining node. It will work independently. – Dharmraj Jan 12 '16 at 06:23
  • No, the remain node does not need to be manually set as master. This is handled automatically by Erlang / Mnesia. The only case when you need to set master manually is when there is an ambiguity about which node as the reference data. – Mickaël Rémond Jan 12 '16 at 11:39
  • Do you have a load balancer in front ? You need to route the traffic properly of course. And again: There is no master / slave concept in ejabberd. Mnesia and this ejabberd is multi masters. – Mickaël Rémond Jan 13 '16 at 08:01
  • Yes, we have load balancer in front. checking the things with team. Thanks – Dharmraj Jan 13 '16 at 08:50
  • If you have no traffic coming to second node, it must be a load balancer issue. – Mickaël Rémond Jan 13 '16 at 09:10
0

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.