搭建ejabberd集群
(金慶的專欄 2016.8)
以2臺機器搭建一個ejabberd集群。
2臺機器都是外網一塊網卡,內網另一塊網卡。
新建一個域名,添加2臺機器的外網IP.
分別用源碼安裝ejabberd,可以單機運行。
復制 .erlang.cookie, 使2臺機器都同。
更改 /sbin/ejabberdctl
ERLANG_NODE=ejabberd@localhost 改為
ERLANG_NODE=ejabberd@192.168.7.160
即localhost改為內網IP
啟動失?。?br />[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 [ejabberd@192.168.7.160], 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"
先啟動 ejabberd@192.168.7.160,然后啟動另一節點,并讓該節點加入集群:
ejabberdctl join_cluster 'ejabberd@192.168.7.160'
[root@host-192-168-7-159 ejabberd]# ejabberdctl list_cluster
'ejabberd@192.168.7.160'
'ejabberd@192.168.7.159'
[root@host-192-168-7-159 ejabberd]#
(金慶的專欄 2016.8)
以2臺機器搭建一個ejabberd集群。
2臺機器都是外網一塊網卡,內網另一塊網卡。
新建一個域名,添加2臺機器的外網IP.
分別用源碼安裝ejabberd,可以單機運行。
復制 .erlang.cookie, 使2臺機器都同。
更改 /sbin/ejabberdctl
ERLANG_NODE=ejabberd@localhost 改為
ERLANG_NODE=ejabberd@192.168.7.160
即localhost改為內網IP
啟動失?。?br />[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 [ejabberd@192.168.7.160], 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"
先啟動 ejabberd@192.168.7.160,然后啟動另一節點,并讓該節點加入集群:
ejabberdctl join_cluster 'ejabberd@192.168.7.160'
[root@host-192-168-7-159 ejabberd]# ejabberdctl list_cluster
'ejabberd@192.168.7.160'
'ejabberd@192.168.7.159'
[root@host-192-168-7-159 ejabberd]#