Howto

Create cookie file

  • Set the same cookie on all the nodes. There are different ways to set the cookie in a node:
    • When starting Erlang, use this argument in the command line: erl -setcookie SFEWRG34AFDSGAFG35235 -name nodex
    • Store the cookie in the file $HOME/.erlang.cookie: SFEWRG34AFDSGAFG35235
    • Or, if you started Erlang with option -sname or -name, you can change the cookie in the erl console: erlang:set_cookie(node(), 'SFEWRG34AFDSGAFG35235').
  • Check that all the Erlang nodes use the same cookie. In the Erlang console: erlang:get_cookie().

Add a node

Make sure .erlang.cookie is the same on each node. On each extra node execute:

erl -name node1@node.com \
    -mnesia extra_db_nodes "['node2@node.com']" \
    -s mnesia

Execute in the erlang shell:

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

Live reinitialization

ejabberd_config:load_file("ejabberd.cfg").

Create certificates

openssl req -new -x509 -newkey rsa:1024 -days 3650 -keyout privkey.pem -out server.pem
openssl rsa -in privkey.pem -out privkey.pem
cat privkey.pem >> server.pem
rm privkey.pem

Files

ejabbardctl

exec erl -noinput -name ejabberdctl@something -s ejabberd_ctl -pa '/opt/ejabberd/var/lib/ejabberd/ebin' -extra $@

$HOME/.hosts.erlang

Add machines to connect to: machine2.example.com. Test with: net_adm:host_file().

Start ejabberd

erl -pa /opt/ejabberd/var/lib/ejabberd/ebin \
      -name node1@sever.com \
      -s ejabberd \
      -ejabberd config \"/opt/ejabberd/etc/ejabberd/ejabberd.cfg\" \
                log_path \"/opt/ejabberd/var/log/ejabberd/ejabberd.log\" \
      -sasl sasl_error_logger \{file,\"/opt/ejabberd/var/log/ejabberd/sasl.log\"\} \
      -kernel inet_dist_listen_min 4370 inet_dist_listen_max 4370 \
      -detached