[OpenSIPS-Users] Need some clarification in opensips cachedb_mongo db configutaion .

Liviu Chircu liviu at opensips.org
Tue Aug 23 10:01:51 UTC 2022


On 22.08.2022 08:44, Sasmita Panda wrote:
>
> When I am configuring 2 connectionstrings here , that means
> 1. Opensips will always honor the 1st one as primary and 2nd one as 
> secondary ?
>
> 2. If the 1st one will get down and 2nd one becomes primary , what 
> will happen to opensips ? Will that keep the 2nd one as primary 
> automatically or I have to switch the domain in the config ?
>
> 3. How does opensips decide which one is primary and which is secondary ?
>
> Please help me out . I am stuck in the middle of something here .

Hi Sasmita,

This has more to do with the libmongoc library behavior, rather than 
OpenSIPS.  First, the multi-host replica set syntax is part of the 
MongoDB connection string syntax[1], so everything that you can read on 
the Mongo website also applies to the "cachedb_mongodb" module.

1. This means that once you include the "replicaSet=rs0" component, the 
library will automatically establish who is the PRIMARY node on each 
query.  If the PRIMARY should ever change (either due to system failure, 
manual switch, etc.), the library will be able to switch to the new 
PRIMARY, whichever that may become (imagine you have a 5-node replica set).

2. no need to change the config string. The library will always know 
which is the PRIMARY (writer) node.

3. I cannot say... I image the library will connect to each node and run 
an "isMaster()"[2] command?  I suggest you do an ngrep or even a PCAP 
capture - that should give you more info on libmongoc behavior.

[1]: https://www.mongodb.com/docs/v5.2/reference/connection-string/
[2]: https://www.mongodb.com/docs/v4.2/reference/command/isMaster/

Best regards,

-- 
Liviu Chircu
www.twitter.com/liviuchircu | www.opensips-solutions.com
OpenSIPS Summit 2022 Athens, Sep 27-30 | www.opensips.org/events




More information about the Users mailing list