Cluster ejabberd

来源:互联网 发布:长得肥影响恋爱知乎 编辑:程序博客网 时间:2024/05/18 00:07

2007-12-4

 

Cluster ejabberd

for example, we want to do a cluster for two machines.

1. Ejabberd server name
we must have one name of ejabberd server, Fox example “cluster.com”

diagram1


2. Node name
we need to know what is the node name.
For example, this node name is
ejabberd@li_chao_PC
remark : node name can't be changed after installation. In general, node name is same as machine name.

diagram2
3. Erlang cookie
Shutdown the two machines, and  make sure the content of file /root/.erlang.cookie are same between two machines. Of cause, you can modify it, for example, change the content to “BYJY”
vim /root/.erlang.cookie
BYJY
so, the first machine's erlang cookie is “BYJY” and the second machines's erlang cookie is “BYJY” too.

 

4. Connect nodes
Start ejabberd at one machine. For example :
one node name is
“ejabberd@li_chao_PC
another node name is
“ejabberd@wei-jun

we assume you start node “ejabberd@li_chao_PC”, start node mean start ejabberd.
You want to connect node
“ejabberd@wei-jun”, then enter below command :
erl -sname ejabberd -mnesia extra_db_nodes “['ejabberd@wei-jun']” -s mnesia

you will see the below information
running db nodes = [ejabberd@wei-jun,
ejabberd@li_chao_PC ]
if you don't see the information above then mean failure.
Now run the following command in the same 'erl' session:
mnesia:change_table_copy_type(schema, node(), disc_copies).

Run below command to exit from the Erlang shell.
Init:stop().

Restart node ejabberd@li_chao_PC, finished.

diagram3
5. Test cluster
open the administarte webiste

diagram4
if the two machine's ip is
10.135.192.7
10.135.192.37

you can modify file /etc/hosts in the others machine.
10.135.192.7 cluster.com
or
10.135.192.37 cluster.com

that's ok!
There are two machine named “cluster.com” , you can use XMPP client to connect any one which you like to.

Of cause, you'd better configure DNS to accomplish load balance.

原创粉丝点击