MongoDB Replica Set Troubleshooting

Source: Internet
Author: User
Tags disk usage ping and traceroute

1. Check the status of the replica set

Use Db.runcommand ({"Replsetgetstatus": 1}), or rs.status ();


2. Check replication delay Time

source:m1.example.net:30001 syncedto:tue Oct 11:33:40 GMT-0400 (EDT) = 7475 secs ago (2.08hrs) source : m2.example.net:30002 syncedto:tue Oct 11:33:40 GMT-0400 (EDT) = 7475 secs ago (2.08hrs)

Possible causes for replication latency are:

Network Latency

You can use the ping and Traceroute commands to detect network conditions

Disk throughput

If the secondary disk does not flush the data to disk as quickly as the primary disk, it will not be able to synchronize updates with primary. You can use Iostat or vmstat to check disk usage


Concurrent Volume

In some cases, if there is a long-term operation on the primary, the secondary copy operation may be blocked. You can consider write concern . The other is to see if there are slow queries.

appropriate Write Concern         

    • Replica Acknowledge Write Concern

    • Replica Set Write Concern



3. Connectivity testing among all members

The members between the Replica set need to be able to connect to each other and check the firewall settings.


4. Restarting multiple Secondar socket exceptions issues

When restarting multiple members in the replica set, make sure you can select a primary. If the program has a socket connection error during maintenance, you can check the TCP keepalive settings.

Cat/proc/sys/net/ipv4/tcp_keepalive_time

The default setting for Linux is tcp_keepalive_time 7,200 seconds, or two hours. You can set this value to 300 seconds for all the servers on which the MongoDB instance resides.

echo >/proc/sys/net/ipv4/tcp_keepalive_time

This setting will disappear after reboot and need to be modified again. You can modify /etc/sysctl.conf directly and then execute Sysctl-p



5. Check the size of the Oplog

The larger the Oplog, the greater the delay that can be accepted.

Use Db.printreplicationinfo (); View the size of the Oplog

Db.printreplicationinfo (); configured Oplog Size:50278.6203125mblog length start to End:143109secs (39.75hrs) Oplog firs                      T event time:wed Mar 00:36:53 gmt+0800 (CST) Oplog last event Time:thu Mar-16:22:02 gmt+0800 (CST) Now: Thu Mar 17:32:42 gmt+0800 (CST)

If you reset the size of the oplog, you need to set all the members to the same size


6.Oplog Entry Timestamp Error

If the following error appears in the log

Replset error fatal couldn ' t query the local local.oplog.rs collection. Terminating Mongod after the seconds.<timestamp> [Rsstart] bad Replset oplog entry?



Resources:

http://docs.mongodb.org/v2.4/tutorial/troubleshoot-replica-sets/

http://john88wang.blog.51cto.com/2165294/1564543

http://docs.mongodb.org/v2.4/faq/diagnostics/#faq-keepalive



This article is from the Linux SA John blog, so be sure to keep this source http://john88wang.blog.51cto.com/2165294/1622324

MongoDB Replica Set Troubleshooting

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.