Ejabberd clustering [closed]
开发者_开发知识库
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this questionI wanted to know if it s possible to set up an ejabberd cluster with a Postgres database ? (I found only ejbberd cluster documentation for mnesia DB)
I am running this configuration: ejabberd 2.1.2 (ubuntu package) Postgres 8.4
ejabberd is like any other erlang application. In order to understand how to cluster ejabberd you need some erlang clustering basics. The reason why you only found docs on setting up clustering with mnesia is because you are still using mnesia for a lot of ejabberd even when you configure some modules to work with postgres.
Mnesia is used to store core session and routing information. This information must be available everywhere in the cluster in native erlang data formats, hence the use of mnesia. Mnesia also maintains information about other mnesia nodes in the schema table which allows a node to remember who the other cluster members are when it starts up.
When you form an ejabberd cluster you still have to form the mnesia cluster relationship by following these steps. I am assuming that you have already worked out your erlang cookies so that net_adm:ping('ejabberd@node1') works from your ejabberd@node2 node and that you have the same ejabberd.cfg on both nodes.
/etc/init.d/ejabberctl live
Start the new node in 'live' mode.application:stop(ejabberd).
Stop the ejabberd application.mnesia:stop().
Stop the mnesia application.mnesia:delete_schema([node()]).
Delete the schema on the local node. This puts the node into a clean state where it is ready to join an mnesia based cluster.mnesia:start().
Start your empty and clean mnesia instance. Mnesia is now in a state where it can accept whatever table information is offered by your first ejabberd node when you ask them to join in the next step.mnesia:change_config(extra_db_nodes,['ejabberd@node1']).
Tell your new ejabberd node where to find its cluster neighbor.mnesia:change_table_copy_type(schema,node(),disc_copies).
Tell mnesia to remember its new cluster neighbor across a node restart by keeping a local copy of the 'schema' table.application:start(ejabberd).
Start the ejabberd application so that it creates all of the mnesia table copies that it really requires.q().
Quit out of the erlang vm, and restart to make sure the cluster formed properly. When I validate my cluster status I callmnesia:info().
and look at the running_db_nodes value.
You're probably wondering why I went through all that when your question is about clustering with PostgreSQL. It's because there is no such thing as clustering with PostgreSQL in ejabberd because the state of the application is still clustered with mnesia. When you use Postgres as your storage backend for things like users and offline messages you are still clustering with mnesia, you just happen to use Postgres as a datastore for certain services. It is for this reason that most guides you see on ejabberd clustering only address mnesia and fail to mention other database backends.
The detail of what SQL database you use is a matter for your ejabberd.cfg file which is a foregone conclusion for most writers of ejabberd clustering guides.
精彩评论