Ejabberd Cluster Based on EC2 Ubuntu Instance & LoadBalancer

  1. Install ejabberd on two ec2 instance. for me is
    > ip-11-248-167-196
    > ip-11-236-190-210
  2. add these port to ec2 instance’s security group.
    > 5222
    > 5223
    > 4369
    > 5269
    > 5280
    > 40000-40010
  3. modify /usr/sbin/ejabberdctl [on both tow instances]

    add this at head of /usr/sbin/ejabberdctl: FIREWALL_WINDOW=40000-40010

  4. modify /user/sbin/ejabberd [on both tow instances]

    add admin user —> {acl, admin, {user, “yafeng”, “jabber.example.com”}}.
    specify hostname —> {hosts, [“jabber.example.com”]}.

  5. register admin user on [ip-11-248-167-196] —> sudo ejabberdctl register yafeng jabber.example.com 123456

  6. replicate mniea database from [ip-11-248-167-196] to [ip-11-236-190-210]. This operation should be done on [ip-11-236-190-210]

    • open ejabberd debug erlang shell -> sudo ejabberdctl debug
    • replicate table schema:
      %this is erlang code. FirstNode = ‘ejabberd@ip-11-248-167-196’, mnesia:stop(), mnesia:delete_schema([node()]), mnesia:start(), mnesia:change_config(extra_db_nodes, [FirstNode]), mnesia:change_table_copy_type(schema, node(), disc_copies).
    • replicate table contents:
      % this is erlang code 2. mnesia:add_table_copy(pubsub_node,node(),disc_copies), mnesia:add_table_copy(muc_registered,node(),disc_copies), mnesia:add_table_copy(pubsub_state,node(),disc_copies), mnesia:add_table_copy(muc_room,node(),disc_copies), mnesia:add_table_copy(motd_users,node(),disc_copies), mnesia:add_table_copy(vcard_search,node(),disc_copies), mnesia:add_table_copy(pubsub_index,node(),disc_copies), mnesia:add_table_copy(acl,node(),disc_copies), mnesia:add_table_copy(motd,node(),disc_copies), mnesia:add_table_copy(roster_version,node(),disc_copies), mnesia:add_table_copy(last_activity,node(),disc_copies), mnesia:add_table_copy(roster,node(),disc_copies), mnesia:add_table_copy(irc_custom,node(),disc_copies), mnesia:add_table_copy(passwd,node(),disc_copies), mnesia:add_table_copy(privacy,node(),disc_copies), mnesia:add_table_copy(pubsub_subscription,node(),disc_copies), mnesia:add_table_copy(config,node(),disc_copies). mnesia:add_table_copy(pubsub_item,node(),disc_only_copies), mnesia:add_table_copy(private_storage,node(),disc_only_copies), mnesia:add_table_copy(offline_msg,node(),disc_only_copies), mnesia:add_table_copy(vcard,node(),disc_only_copies). mnesia:add_table_copy(muc_online_room,node(),ram_copies), mnesia:add_table_copy(temporarily_blocked,node(),ram_copies), mnesia:add_table_copy(iq_response,node(),ram_copies), mnesia:add_table_copy(session,node(),ram_copies), mnesia:add_table_copy(session_counter,node(),ram_copies), mnesia:add_table_copy(captcha,node(),ram_copies), mnesia:add_table_copy(s2s,node(),ram_copies), mnesia:add_table_copy(route,node(),ram_copies), mnesia:add_table_copy(pubsub_last_item,node(),ram_copies), mnesia:add_table_copy(bytestream,node(),ram_copies), mnesia:add_table_copy(reg_users_counter,node(),ram_copies).
    • ctrl+c,ctrl+c quit erlang shell, this may take a minute.
  7. check your cluster is ready or not

    user xmpp client(for me is RooyeeMessenger) login to [ip-11-248-167-196],[ip-11-236-190-210], if both of them can login. congratulations, you built a ejabberd cluster succ.

  8. Addtionally create a loadbalancer in ec2 dashbord, attach these two instance to it.Then transfer LB port 5222,5223,4369,5269,5280 to back-end instances.

  9. Reference

    http://www.process-one.net/docs/ejabberd/guide_en.html

你可能感兴趣的:(ubuntu,ec2,cluster,ejabberd)