搭建ejabberd集群
(金庆的专栏 2016.8)
以2台机器搭建一个ejabberd集群。
2台机器都是外网一块网卡,内网另一块网卡。
新建一个域名,添加2台机器的外网IP.
分别用源码安装ejabberd,可以单机运行。
复制 .erlang.cookie, 使2台机器都同。
更改 /sbin/ejabberdctl
ERLANG_NODE=ejabberd@localhost 改为
[email protected]
即localhost改为内网IP
启动失败:
[error] <0.63.0>@ejabberd_app:start_elixir_application:245 Elixir application not started.
[critical] <0.63.0>@ejabberd_app:db_init:127 Node name mismatch: I'm [[email protected]], the database is owned by [ejabberd@localhost]
[critical] <0.63.0>@ejabberd_app:db_init:129 Either set ERLANG_NODE in ejabberdctl.cfg or change node name in Mnesia
[error] <0.62.0> CRASH REPORT Process <0.62.0> with 0 neighbours exited with reason: node_name_mismatch in ejabberd_app:db_init/0 line 131 in application_master:init/4 line 134
[info] <0.31.0> Application ejabberd exited with reason: node_name_mismatch in ejabberd_app:db_init/0 line 131
因为Mnesia库中使用了旧的节点名
[root@host-192-168-7-160 ~]# ejabberdctl mnesia
[{auto_repair,true},
{backup_module,mnesia_backup},
{db_nodes,[ejabberd@localhost]},
删除旧库。
[root@host-192-168-7-160 ejabberd]# pwd
/var/lib/ejabberd
[root@host-192-168-7-160 ejabberd]# ls
caps_features.DAT muc_registered.DCD pubsub_index.DCD sr_group.DCD
DECISION_TAB.LOG muc_room.DCD pubsub_item.DAT sr_user.DCD
irc_custom.DCD oauth_token.DCD pubsub_node.DCD vcard.DAT
last_activity.DCD offline_msg.DAT pubsub_state.DCD vcard_search.DCD
LATEST.LOG passwd.DCD roster.DCD
motd.DCD privacy.DCD roster_version.DCD
motd_users.DCD private_storage.DAT schema.DAT
[root@host-192-168-7-160 ejabberd]# rm -f *
[root@host-192-168-7-160 ejabberd]#
更改 ejabberd.yml:
hosts:
- "my_domain.cn"
# - "localhost"
先启动 [email protected],然后启动另一节点,并让该节点加入集群:
ejabberdctl join_cluster '[email protected]'
[root@host-192-168-7-159 ejabberd]# ejabberdctl list_cluster
'[email protected]'
'[email protected]'
[root@host-192-168-7-159 ejabberd]#