2013-10-31 21 views
-1

我看到MongoDB documentation表示刪除索引是通過調用db.accounts.dropIndex({ "tax-id": 1 })。但它並沒有說明節點是否需要從副本集中刪除。MongoDB:如何刪除副本集上的索引?

我試圖讓副本服務器中的輔助節點脫機,並作爲獨立節點(在不同的端口中)重新啓動,並嘗試刪除索引。

但是,通過常規過程sudo service mongod start帶回副本集中的節點後,mongod進程正在死於說索引已損壞。

Thu Oct 31 19:52:38.098 [repl writer worker 1] Assertion: 15898:error in index possibly corruption consider repairing 382 
0xdddd81 0xd9f55b 0xd9fa9c 0x7edb83 0x7fb332 0x7fdc08 0x9d3b50 0x9c796e 0x9deb64 0xac45dd 0xac58df 0xa903fa 0xa924c7 0xa71f6c 0xc273d3 0xc26b18 0xdab721 0xe26609 0x7ff4d05f0c6b 0x7ff4cf9965ed 
/usr/bin/mongod(_ZN5mongo15printStackTraceERSo+0x21) [0xdddd81] 
/usr/bin/mongod(_ZN5mongo11msgassertedEiPKc+0x9b) [0xd9f55b] 
/usr/bin/mongod() [0xd9fa9c] 
/usr/bin/mongod(_ZN5mongo11checkFailedEj+0x143) [0x7edb83] 
/usr/bin/mongod(_ZNK5mongo12BucketBasicsINS_12BtreeData_V1EE11basicInsertENS_7DiskLocERiS3_RKNS_5KeyV1ERKNS_8OrderingE+0x222) [0x7fb332] 
/usr/bin/mongod(_ZNK5mongo11BtreeBucketINS_12BtreeData_V1EE10insertHereENS_7DiskLocEiS3_RKNS_5KeyV1ERKNS_8OrderingES3_S3_RNS_12IndexDetailsE+0x68) [0x7fdc08] 
/usr/bin/mongod(_ZNK5mongo30IndexInsertionContinuationImplINS_12BtreeData_V1EE22doIndexInsertionWritesEv+0xa0) [0x9d3b50] 
/usr/bin/mongod(_ZN5mongo14IndexInterface13IndexInserter19finishAllInsertionsEv+0x1e) [0x9c796e] 
/usr/bin/mongod(_ZN5mongo24indexRecordUsingTwoStepsEPKcPNS_16NamespaceDetailsENS_7BSONObjENS_7DiskLocEb+0x754) [0x9deb64] 
/usr/bin/mongod(_ZN5mongo11DataFileMgr6insertEPKcPKvibbbPb+0x123d) [0xac45dd] 
/usr/bin/mongod(_ZN5mongo11DataFileMgr16insertWithObjModEPKcRNS_7BSONObjEbb+0x4f) [0xac58df] 
/usr/bin/mongod(_ZN5mongo14_updateObjectsEbPKcRKNS_7BSONObjES4_bbbRNS_7OpDebugEPNS_11RemoveSaverEbRKNS_24QueryPlanSelectionPolicyEb+0x2eda) [0xa903fa] 
/usr/bin/mongod(_ZN5mongo27updateObjectsForReplicationEPKcRKNS_7BSONObjES4_bbbRNS_7OpDebugEbRKNS_24QueryPlanSelectionPolicyE+0xb7) [0xa924c7] 
/usr/bin/mongod(_ZN5mongo21applyOperation_inlockERKNS_7BSONObjEbb+0x65c) [0xa71f6c] 
/usr/bin/mongod(_ZN5mongo7replset8SyncTail9syncApplyERKNS_7BSONObjEb+0x713) [0xc273d3] 
/usr/bin/mongod(_ZN5mongo7replset14multiSyncApplyERKSt6vectorINS_7BSONObjESaIS2_EEPNS0_8SyncTailE+0x48) [0xc26b18] 
/usr/bin/mongod(_ZN5mongo10threadpool6Worker4loopEv+0x281) [0xdab721] 
/usr/bin/mongod() [0xe26609] 
/lib64/libpthread.so.0(+0x7c6b) [0x7ff4d05f0c6b] 
/lib64/libc.so.6(clone+0x6d) [0x7ff4cf9965ed] 
Thu Oct 31 19:52:38.106 [repl writer worker 1] ERROR: writer worker caught exception: error in index possibly corruption consider repairing 382 on: 

XXXXXXXX - 刪除相關數據的內容... XXXXXXXXXXXXX

Thu Oct 31 19:52:38.106 [repl writer worker 1] Fatal Assertion 16360 
0xdddd81 0xd9dc13 0xc26bfc 0xdab721 0xe26609 0x7ff4d05f0c6b 0x7ff4cf9965ed 
/usr/bin/mongod(_ZN5mongo15printStackTraceERSo+0x21) [0xdddd81] 
/usr/bin/mongod(_ZN5mongo13fassertFailedEi+0xa3) [0xd9dc13] 
/usr/bin/mongod(_ZN5mongo7replset14multiSyncApplyERKSt6vectorINS_7BSONObjESaIS2_EEPNS0_8SyncTailE+0x12c) [0xc26bfc] 
/usr/bin/mongod(_ZN5mongo10threadpool6Worker4loopEv+0x281) [0xdab721] 
/usr/bin/mongod() [0xe26609] 
/lib64/libpthread.so.0(+0x7c6b) [0x7ff4d05f0c6b] 
/lib64/libc.so.6(clone+0x6d) [0x7ff4cf9965ed] 
Thu Oct 31 19:52:38.108 [repl writer worker 1] 

***aborting after fassert() failure 


Thu Oct 31 19:52:38.108 Got signal: 6 (Aborted). 

這是由於在次級離線模式刪除索引?任何建議,以正確的方式刪除索引是高度讚賞。

回答

2

從副本集中刪除索引的正確方法是將其放在主節點上。副本的想法是具有相同的數據副本(時間滯後很小)。所以每當你做了一些主要的事情被複制到二手。因此,如果您在主服務器上完成任何操作,則在完成此過程後,該進程會傳播到輔助服務器。

如果您要從主要索引中刪除索引,索引也將在輔助索引中刪除。

+0

然而這並不是推薦的將索引添加到副本集的方法。 http://docs.mongodb.org/manual/tutorial/build-indexes-on-replica-sets/ –

+0

@SalvadorDali感謝您的建議。將嘗試作爲最後一個選項,因爲涉及大量數據,並且擔心在此期間複製對象上的寫入鎖定會使整個複製對象被阻塞,直到完成下降索引。 – oliTwist

+0

@AsyaKamsky對於我們來說,將索引放入副本集(除了如上所述從主節點發布索引)之外,它的工作方式是停止寫入流量,停止主節點並在所有節點上執行下降索引,並將每個節點回到副本集。這涉及到我們寫入流量的中斷。 – oliTwist