MongoDB replica set replica set status check

background

副本集状态命令检查

Write in front
摘录自https://www.cnblogs.com/lijiaman/p/13215533.html
link

View replica set status

rs.status()

检查"health" : 1,

 "ok" : 1,

Check replication lag

rs.printSlaveReplicationInfo()

source: 192.168.68.61:27017
        syncedTo: Tue Dec 22 2020 08:29:49 GMT+0000 (UTC)
        0 secs (0 hrs) behind the primary 
source: 192.168.68.62:27017
        syncedTo: Tue Dec 22 2020 08:29:49 GMT+0000 (UTC)
        0 secs (0 hrs) behind the primary 

Reasons for lag:

1. Network delay. Check the network routing between members of the replica set to ensure that there is no data packet loss or network routing problems. You can use ping or traceroute to confirm.
2. Disk throughput. Use iostat or vmstat to evaluate disk status.
3. Large transaction operations. Long-running operations on the primary node may block the replication of the secondary node.
4. Reasonable write concern. If a large number of writes are required to the primary database and a large-scale data load operation is performed, the secondary database cannot keep up with the primary node.

Test the connection between all members

副本集的所有成员必须能够连接到该集合的每一个其它成员以支持复制。如果节点复制异常,可以排查节点之间的连通性。

在节点68.60上测试能否正常连接到其它2个节点
mongo --host 192.168.68.61 --port 27017
mongo --host 192.168.68.62 --port 27017

Check the size of oplog

较大的oplog可以使副本集对延迟的容忍度更高,要检查oplog大小,请在当前节点执行 rs.printReplicationInfo() 方法。

rs.printReplicationInfo()   >=990M

操作日志应该足够大,至少能够保存24小时的日志。

This article explains that the main technical content comes from the sharing of Internet technology giants, as well as some self-processing (only for the role of annotations). If related questions, please leave a message after the confirmation, the implementation of infringement will be deleted

Guess you like

Origin blog.csdn.net/baidu_34007305/article/details/111560896