processone / ejabberd

Robust, Ubiquitous and Massively Scalable Messaging Platform (XMPP, MQTT, SIP Server)
https://www.process-one.net/en/ejabberd/
Other
6.07k stars 1.51k forks source link

Feature Sync data of ejabberd installed on different stand-alone servers. #4145

Closed taqveemmalik closed 4 weeks ago

taqveemmalik commented 8 months ago

I have set up ejabberd services on two separate servers with the following IPs: 134.232.21.22 and 93.234.12.90. Each server has its own standalone ejabberd installation. Now, I'm looking to implement load balancing to ensure that when my application registers a new user, the load balancer can manage this process and both servers are aware of the new user. Could you guide me on how to achieve this synchronization, or suggest an alternative method?

licaon-kter commented 8 months ago

Read https://docs.ejabberd.im/admin/guide/clustering/#title

taqveemmalik commented 8 months ago

I follow this document. Is it possible for different servers?

taqveemmalik commented 8 months ago

?? @licaon-kter

badlop commented 8 months ago

I have set up ejabberd services on two separate servers with the following IPs: 134.232.21.22 and 93.234.12.90. Each server has its own standalone ejabberd installation. Now, I'm looking to implement load balancing to ensure that when my application registers a new user, the load balancer can manage this process and both servers are aware of the new user. Could you guide me on how to achieve this synchronization, or suggest an alternative method?

If you are reading https://docs.ejabberd.im/admin/guide/clustering/#title then you are following the correct page, and what you describe should work. There may be some problem in the setup.

Just to make sure:

Is it possible for different servers?

Yes, it is possible to have each ejabberd node in a different machine, but please take care: those two machines must a have a reliable, stable, quality connection between them, to ensure the mnesia database replication works correctly. If their connection get lost, then database replication will fail.

taqveemmalik commented 8 months ago

Yes, I am following the document provided by ejabberd. nodes are also shown in my admin panel and terminal, but when I try to add a user, it doesn't exist in both, just in the node where I run the command. There is no error in error logs or ejabberd logs file also.

'Follow "Adding a node to a cluster" to link the Mnesia database in both nodes Try to register an account in a node... it should immediately appear in the mnesia database of the other node, so clients can connect to any of them and login correctly to that account.'

badlop commented 7 months ago

The clustering process can be replicated easily using containers, for example with the docker-compose.yml mentioned in CONTAINER.md clustering example

The account is registered in the first node, called ejabberd. And later, when the second node called replica starts and joins the cluster, the account exists:

ejabberd  | :> ejabberdctl register admin localhost asd
ejabberd  | User admin@localhost successfully registered
...
replica   | :> ejabberdctl registered_users localhost
replica   | admin

I can double-check that the replica node considers itself to be in the cluster:

$ docker exec replica ejabberdctl list_cluster
ejabberd@main
ejabberd@replica

Considering that it works using ejabberd 23.10 using containers... I wonder what ejabberd version you are using, what other configuration differences may there be...