Set up clustering in ejabberd

ESL Developer Blog - - September 30, 2008

I found clustering in ejabberd not so easy if you go strictly by the manual

ejabberd 2.0.1 Installation and Operation Guide

It does not really mention that Mnesia likes to create databases in the present working directory, and name them prefixed with Mnesia. This makes it hard to find out why two ejabberd nodes won’t connect to each others. Here is what we do:

  1. Configure and start ejabberd on “first”:
    • Edit ejabberdctl.cfg to have your FULL nodename in the last line (ejabberd@first.example.com)
    • Edit sbin/ejabberdctl to have the right nodename in NODE and HOST (lines 11 and 12)
    • Edit sbin/ejabberdctl to have $ERLANG_NODE at the end
    • sbin/ejabberdctl start
  2. Configure and start ejabberd on “second”:

    • Edit ejabberdctl.cfg to have your FULL nodename in the last line (ejabberd@second.example.com)
    • Edit sbin/ejabberdctl to have the right nodename in NODE and HOST (lines 11 and 12)
    • Edit sbin/ejabberdctl to have $ERLANG_NODE at the end
    • sbin/ejabberdctl start
  3. Stop ejabberd on “second”.
  4. Go to the database directory on “second” (i.e. /var/lib/ejabberd/db/)
  5. Delete or move away the directory that is named after your node (”ejabberd@second.example.com”)
  6. Start your remote erlang shell on “second”



    erl -name ejabberd@second.example.com -mnesia extra_db_nodes “[‘ejabberd@first.example.com’]” -s mnesia



    (You should now see this node in the list of nodes in the web admin on “first.example.com”, not quite usable though. This tells you that the Mnesia connection itself is running fine.)

  7. Syncronise databases



    mnesia:change_table_copy_type(schema, node(), disc_copies).

  8. Quit Mnesia



    q().

  9. Move the newly created directory (Mnesia.ejabberd@second.example.com) to the location of the directory that you deleted/moved before.



    mv Mnesia.ejabberd@second.example.com ejabberd@second.example.com

  10. Start ejabberd on “second” (sbin/ejabberdctl start)

You should now see both nodes in the web admin interface at http://first.example.com:5280/admin and the cluster should be up and running fine. Now you can set up the rest of the database replication through the web interface. Works fine for us…



Categories: Blogs  ESL Developer Blog  

Comments

No comments so far, you could be the first.

Add comment

Name:

Email:

URL:

Smileys

Remember my personal information

Notify me of follow-up comments?