简体   繁体   中英

How to configure Pyramid to find MongoDB Primary replica

有没有办法配置Pyramid,以便当MongoDB故障转移到辅助副本时,Pyramid开始使用它?

Pyramid should be using the official python MongoDB drivers. The drivers are configured to do this "automatically", but they need the correct connection string.

See here for the connection strings.

One thing to keep in mind, the definition of "automatic fail-over" is not clear cut.

If you create a new connection to the DB that connection will point at the current primary.

If you use an existing connection from a pool, that connection may be pointing at the wrong server. In this case it will throw an exception the first time and should connect to the correct server the second time.

However, when a fail-over happens, there is a brief window where there is no primary ( typically 2-10 seconds ). If you use a connection during this period, no connection will be primary.

Note that this is not specific to python, it's the way Replica Sets function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM