Clustering on two machines
-
Hi,
We have successfully deployed NodeBB on 1 machine with 3 NodeBB processes on the same machine at different and using nginx to load balance between the 3. We are using MongoDB as the database, and have also setup redis for inter-process communication.Now we plan to add another machine to further increase user capacity. Both machines will have 3 NodeBB processes each. We have the following questions:
- Do we start the NodeBB processes on the machine 2 and have the same redis server in the config so the processes can communicate?
- Do we set isCluster to true?
- How do we make a MongoDB replica? Do we add the IPs of both mongo instances in the config file of nodebb on both machines?
Any help will be appreciated. Thanks!
-
-
Do we start the NodeBB processes on the machine 2 and have the same redis server in the config so the processes can communicate?
Yes
Do we set isCluster to true?
You don't have to set
isCluster: true
since you are running more than one process on each machine, nodebb will detect it automatically. You should setjobsDisabled: true
on machine 2 so it doesn't run digests and other cronjobs.How do we make a MongoDB replica? Do we add the IPs of both mongo instances in the config file of nodebb on both machines?
You can use the
mongo:uri
property to define the mongodb replicaset. -
@baris Thanks alot! That clears up a lot of confusion.
Also, I wasn't able to find a guide on how to create a MongoDB replica for my nodebb database. If it's not too much trouble, could you explain the steps at a high level? Any direction would be highly appreciated.
Thanks again for the help!
-
https://www.mongodb.com/docs/manual/reference/connection-string/#replica-set-option
Once you deploy it you can use the
uri
property in nodebb config.json to use the replica set. -
Have successfully completed my setup. Thanks!
-
-
@baris One related question. I am aiming to make the system fault tolerant so if one of the servers go down, the other one can still server users. In this case, how would I go configuring redis in the NodeBB config file?
Currently redis is running on server 1 only and server 2's NodeBB config has it's server 1's IP for redis. -
@mutahar-ali You'd probably want to move the redis server to another machine in that case. Either a separate one, or on the same machine as the Mongo database.