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

Sasmita Panda spanda at 3clogic.com
Wed Aug 24 08:56:58 UTC 2022


Hi Liviu ,

I have mapped a domain in AWS route53 primary-clsuter.xyz.com to mongodb
primary cluster connection string  .

Now my primary cluster goes down so my secondary cluster becomes primary .
I have updated the connection string against the domain in route53 . Now
*primary-cluster.xzy.com <http://primary-cluster.xzy.com>* is pointed to
the new primary custer connection string .

While creating a connection from the console through the mongo shell it's
getting connected . But opensips is not able to switch the connecting
string somehow . still it's trying to connect to the previous primary
connection string .

It seems like opensips has cached the connection string and is trying to
connect to the same even after I have updated the string from the backend .

Once I restart the opensips service everything starts working and the
connection string was updated to the latest primary cluster connection
string .


How will I manage this ?


*Thanks & Regards*
*Sasmita Panda*
*Senior Network Testing and Software Engineer*
*3CLogic , ph:07827611765*


On Tue, Aug 23, 2022 at 3:31 PM Liviu Chircu <liviu at opensips.org> wrote:

> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20220824/b1fcc4e6/attachment.html>


More information about the Users mailing list