Ejabberd 2.0 Clustering Problem

Hi guys was hoping someone could help me out. I have two machines dev-im1 and dev-im2. I tried following the instructions in the ejabberd manual but had no luck. I copied over the magic cookie which is fine. But when i try to run the command from dev-im2:

erl -sname ejabberd \
-mnesia extra_db_nodes "[’ejabberd@dev-im1’]" \
-s mnesia

I get the following error:

=ERROR REPORT==== 22-May-2008::16:13:39 ===
application_controller: bad term: [\222ejabberd@dev-im1\222]

I tried this w/ both dev-im1 running and not running but that didn't resolve the issue. I did a bit of digging around and found another person launched dev-im1 by running this command:

         erl -pa /var/lib/ejabberd/ebin \
             -name ejabberd \
             -s ejabberd \
             -ejabberd config \"/etc/ejabberd/ejabberd.cfg\" \
                       log_path \"/var/log/jabber/ejabberd.log\" \
             -sasl sasl_error_logger
\{file,\"/var/log/jabber/sasl.log\"\} \
             -mnesia dir \"/var/spool/jabber/ejabberd\" \
             -heart \
             -detached

I then run this command on dev-im2:
erl -sname ejabberd -mnesia extra_db_nodes "['ejabberd@dev-im1']" -s mnesia

when i run the mnesia:info(). i get this:

running db nodes   = ['ejabberd@dev-im2']
stopped db nodes   = ['ejabberd@dev-im1']
master node tables = []
remote             = []

For some reason the dev-im1 isnt listed as running. I think the problem is how I am starting the server. If anyone can please tell me how they start each server and configured the server it would be greatly appreciated.

Thanks
Andy

Simple example of mnesia setup

Anonymous wrote:
erl -sname ejabberd \
-mnesia extra_db_nodes "[’ejabberd@dev-im1’]" \
-s mnesia

I get the following error:

=ERROR REPORT==== 22-May-2008::16:13:39 ===
application_controller: bad term: [\222ejabberd@dev-im1\222]

Instead of

"[’ejabberd@dev-im1’]"

you should use

"['ejabberd@dev-im1']"
Anonymous wrote:

I did a bit of digging around and found another person launched dev-im1 by running this command:

         erl -pa /var/lib/ejabberd/ebin \
             -name ejabberd \
             -s ejabberd \
             -ejabberd config \"/etc/ejabberd/ejabberd.cfg\" \
                       log_path \"/var/log/jabber/ejabberd.log\" \
             -sasl sasl_error_logger
\{file,\"/var/log/jabber/sasl.log\"\} \
             -mnesia dir \"/var/spool/jabber/ejabberd\" \
             -heart \
             -detached

This is to start an erlang node with ejabberd running in it. Among other things, ejabberd will start mnesia.

Anonymous wrote:

I then run this command on dev-im2:
erl -sname ejabberd -mnesia extra_db_nodes "['ejabberd@dev-im1']" -s mnesia

And this is to start an erlang node with only mnesia running, and telling mnesia that there is another node.

Until here, all looks correct.

Anonymous wrote:

when i run the mnesia:info(). i get this:

running db nodes   = ['ejabberd@dev-im2']
stopped db nodes   = ['ejabberd@dev-im1']
master node tables = []
remote             = []

For some reason the dev-im1 isnt listed as running. I think the problem is how I am starting the server. If anyone can please tell me how they start each server and configured the server it would be greatly appreciated.

Oh, im1 should be listed in the 'running db nodes' list.

You can try a very simple setup, without using ejabberd at all, to verify the basic concepts. Maybe it gives you some idea of where your problem is.

For example, you can start two simple erlang nodes (don't care about ejabberd right now), in the same machine.

Console 1:

$ erl -sname serv1@localhost -s mnesia
Erlang (BEAM) emulator version 5.6.2 [source] [smp:2] [async-threads:0] [kernel-poll:false]

Eshell V5.6.2  (abort with ^G)
(serv1@localhost)1> mnesia:system_info(running_db_nodes).
[serv1@localhost]

Console 2:

$ erl -sname serv2@localhost  -mnesia extra_db_nodes "['serv1@localhost']" -s mnesia
Erlang (BEAM) emulator version 5.6.2 [source] [smp:2] [async-threads:0] [kernel-poll:false]

Eshell V5.6.2  (abort with ^G)
(serv2@localhost)1> mnesia:system_info(running_db_nodes).
[serv1@localhost,serv2@localhost]

Now again in console 1, to verify the first node also noticed the second is connected to it:

(serv1@localhost)2> mnesia:system_info(running_db_nodes).
[serv2@localhost,serv1@localhost]

Resolved: The Manual says

Resolved:

The Manual says that only port 4363 needs to be open to communicate with other erlang nodes. However, erlang uses EPMD for communication between nodes and it opens up random ports for communication. As soon as i opened up all ports between only the two nodes i was able to interconnect them. I think this should be added as either a footnote or put into a troubleshooting section for clustering. Also i was wondering if anyone knew how to open up only specific ports for the epmd? I don't like the idea of opening up all ports even thought it is only between these machines.

Thanks
Andy

Limit ports for internode connection

FindAndy wrote:

erlang uses EPMD for communication between nodes and it opens up random ports for communication. ... I think this should be added as either a footnote or put into a troubleshooting section for clustering. Also i was wondering if anyone knew how to open up only specific ports for the epmd?

This was added recently, maybe the guide you consulted doesn't yet include it:

Quote:

Once an Erlang node solved the node name of another Erlang node using EPMD and port 4369, the nodes communicate directly. The ports used in this case by default are random, but can be configured in the file ejabberdctl.cfg. The Erlang command-line parameter used internally is, for example:

erl ... -kernel inet_dist_listen_min 4370 inet_dist_listen_max 4375

You can check the ejabberd guide in ejabberd trunk SVN.

Syndicate content