2012-05-16 76 views
1

運行包含上限集合的副本集時是否有問題?MongoDB限制集合複製和非常高的CPU使用率

出於某種原因,我的副本集上的其中一個輔助節點定期處於90%CPU幾小時。

闖入它gdb顯示以下堆棧跟蹤幾乎所有的時間:

#0 0x00000000008c3e3a in mongo::ps::Rolling::access(unsigned long, short, bool)() 
#1 0x00000000008c3bd6 in mongo::Record::accessed()() 
#2 0x000000000086eb03 in mongo::CoveredIndexMatcher::matches(mongo::BSONObj const&, mongo::DiskLoc const&, mongo::MatchDetails*, bool)() 
#3 0x000000000086ed78 in mongo::CoveredIndexMatcher::matchesCurrent(mongo::Cursor*, mongo::MatchDetails*)() 
#4 0x00000000009794dc in mongo::UpdateOp::next()() 
#5 0x00000000008c9a96 in mongo::QueryPlanSet::Runner::nextOp(mongo::QueryOp&)() 
#6 0x00000000008d9930 in mongo::QueryPlanSet::Runner::next()() 
#7 0x00000000008d9f86 in mongo::QueryPlanSet::Runner::runUntilFirstCompletes()() 
#8 0x00000000008ddc3e in mongo::QueryPlanSet::runOp(mongo::QueryOp&)() 
#9 0x00000000008df5f5 in mongo::MultiPlanScanner::runOpOnce(mongo::QueryOp&)() 
#10 0x00000000008dfaf0 in mongo::MultiCursor::nextClause()() 
#11 0x00000000008e1bcd in mongo::MultiCursor::MultiCursor(char const*, mongo::BSONObj const&, mongo::BSONObj const&, boost::shared_ptr<mongo::MultiCursor::CursorOp>, bool)() 
#12 0x000000000095f542 in mongo::_updateObjects(bool, char const*, mongo::BSONObj const&, mongo::BSONObj, bool, bool, bool, mongo::OpDebug&, mongo::RemoveSaver*)() 
#13 0x00000000009642d5 in mongo::updateObjects(char const*, mongo::BSONObj const&, mongo::BSONObj, bool, bool, bool, mongo::OpDebug&)() 
#14 0x00000000008339cf in mongo::applyOperation_inlock(mongo::BSONObj const&, bool)() 
#15 0x00000000008232cb in mongo::ReplSetImpl::syncApply(mongo::BSONObj const&)() 
#16 0x0000000000826f65 in mongo::ReplSetImpl::syncTail()() 
#17 0x00000000008283e5 in mongo::ReplSetImpl::_syncThread()() 
#18 0x0000000000828438 in mongo::ReplSetImpl::syncThread()() 
#19 0x00000000008288d0 in mongo::startSyncThread()() 
#20 0x0000000000aabd90 in thread_proxy() 
#21 0x00007effd9cd09ca in start_thread() from /lib/libpthread.so.0 
#22 0x00007effd927fcdd in clone() from /lib/libc.so.6 

有一些額外的法寶之一,需要以用得到封頂收藏複製嗎?

回答

3

您需要在_id上有一個唯一的索引以便快速複製(否則它必須對集合中的每個操作執行全表掃描,這是您在跟蹤中看到的內容)。 _id索引不會自動創建在上限集合上。在主服務器上創建索引,然後您可能需要重新同步輔助服務器:如果您有非唯一的_ids,它可能會導致複製。

確保您在_id上創建了唯一的索引。如果您創建了非唯一索引,則很難從中恢復:mongod「保護」此索引不會讓您丟棄它,也不會讓您在_id上創建任何其他索引。

請參閱http://www.mongodb.org/display/DOCS/Capped+Collections#CappedCollections-UsageandRestrictions的警告。

+0

謝謝。我已經添加了一個索引,但我不確定它是否是唯一的索引。我相信_id是自動生成的 - 我如何確保它在現有的加蓋集合上是唯一的? –

+0

當您添加它時,在索引選項中指定unique:true。 – kristina