How to enable ReadConcernMajority in MongoDB 3.6.3

2020-04-21 03:10发布

问题:

I'm running a MongoDB 3.6.3 with pymongo. I would like to use watch on a collection but it returns the following error: ReadConcernMajorityNotEnabled. Can anyone tell me how to enable it please?

thanks

回答1:

Read concern majority should be enabled by default in MongoDB 3.6 but there are several requirements to note if you have upgraded from a prior major MongoDB release or changed default configuration values.

Server configuration settings to check:

  • Your deployment is using the WiredTiger storage engine

    db.serverStatus().storageEngine should include "name": "wiredTiger"

    If you need to change this, see: Change Replica Set to WiredTiger.

  • Replication is enabled with protocol version 1 (pv1)

    rs.conf().protocolVersion should be NumberLong("1")

    If you need to change this, see: Modify Replica Set Protocol Version.

  • 3.6 feature compatibility is enabled

    db.adminCommand({getParameter: 1, featureCompatibilityVersion: 1}) should include "version": "3.6"

    If you need to change this, see: Enable backwards-incompatible 3.6 features.