Reading all write statements on a secondary

Everyone,

Is there any mechanism (without enabling logging) to read all the written statements on a MongoDB secondary?

I would like to thank you for your help!

Sincerely,

Mariella

Hi @marielladigiacomov,

Firstly let us talk about reading documents from a secondary Node.
By default, any client application will direct its read to the primary member of the replica set. However, client application can specify a read preference to send read operations to secondaries.

However, check the counter indications for setting read preference to secondary or secondaryPreferred.

Lastly, about statements in oplogs, when logLevel is set to 0 , MongoDB records slow operations to the diagnostic log at a rate determined by slowOpSampleRate . Starting in MongoDB 4.2, the secondaries of replica sets log all oplog entry messages that take longer than the slow operation threshold to apply regardless of the sample rate.

You can also refer to the following blog post for more details:

I hope it helps!!

Please let me know, if you have any questions.

Thanks,
Sonali

1 Like

Sonali,

First of all, I would like to thank you for your help!
Next, I would like to let you know that I was searching for a mechanism equivalent to the ‘MySQL Binary Logging’ (https://dev.mysql.com/doc/refman/8.0/en/binary-log.html).
To be more precise, I would like a mechanism that records on a secondary EVERY "WRITE ((inserts/delete/update/create) OPERATION, ALSO THROUGH REPLICATION.

Is it fair to say that the recording/logging of writes (inserts/delete/update/create) operations, also through replication, on a secondary can be achieved setting the logLevel to high values?
If that would not cover all the cases, could you, please, be so kind in giving some examples that would be logged and those that would not be logged?

From
https://docs.mongodb.com/manual/reference/configuration-options/#operationProfiling.slowOpSampleRate
"
At higher logLevel settings, all operations appear in the diagnostic log regardless of their latency with the following exception: the logging of slow oplog entry messages by the secondaries. The secondaries log only the slow oplog entries; increasing the logLevel does not log all oplog entries.
"

I would like to thank you for your help!

I look forward to hearing from you whenever feasible,

Mariella