MongoDB整理筆記の移除Shard Server

來源:互聯網
上載者:User

標籤:

    有些時候有於硬體資源有限,所以我們不得不進行一些回收工作,下面我們就要將剛剛啟用的Shard Server 回收,系統首先會將在這個即將被移除的Shard Server 上的資料先平均分配到其它的Shard Server 上,然後最終在將這個Shard Server 踢下線, 我們需要不停的調用db.runCommand({"removeshard" :"localhost:20002"});來觀察這個移除操作進行到哪裡了:

> use adminswitched to db admin> db.runCommand({"removeshard" : "localhost:20002"});{"msg" : "draining started successfully","state" : "started","shard" : "shard0002","ok" : 1}> db.runCommand({"removeshard" : "localhost:20002"});{"msg" : "draining ongoing","state" : "ongoing","remaining" : {"chunks" : NumberLong(44),"dbs" : NumberLong(0)},"ok" : 1}……> db.runCommand({"removeshard" : "localhost:20002"});{"msg" : "draining ongoing","state" : "ongoing","remaining" : {"chunks" : NumberLong(1),"dbs" : NumberLong(0)},"ok" : 1}> db.runCommand({"removeshard" : "localhost:20002"});{"msg" : "removeshard completed successfully","state" : "completed","shard" : "shard0002","ok" : 1}> db.runCommand({"removeshard" : "localhost:20002"});{"assertion" : "can‘t find shard for: localhost:20002","assertionCode" : 13129,"errmsg" : "db assertion failure","ok" : 0}
View Code

    最終移除後,當我們再次調用db.runCommand({"removeshard" : "localhost:20002"});的時候系統會報錯,已便通知我們不存在20002 這個連接埠的Shard Server 了,因為它已經被移除掉了。

> use testswitched to db test> db.users_2.stats(){"sharded" : true,"ns" : "test.users_2","count" : 500000,"size" : 48000000,"avgObjSize" : 96,"storageSize" : 95203584,"nindexes" : 1,"nchunks" : 92,"shards" : {"shard0000" : {"ns" : "test.users_2","count" : 248749,"size" : 23879904,"avgObjSize" : 96,"storageSize" : 61875968,"numExtents" : 11,"nindexes" : 1,"lastExtentSize" : 15001856,"paddingFactor" : 1,"flags" : 1,"totalIndexSize" : 13033472,"indexSizes" : {"_id_" : 13033472},"ok" : 1},"shard0001" : {"ns" : "test.users_2","count" : 251251,"size" : 24120096,"avgObjSize" : 96,"storageSize" : 33327616,"numExtents" : 8,"nindexes" : 1,"lastExtentSize" : 12079360,"paddingFactor" : 1,"flags" : 1,"totalIndexSize" : 10469376,"indexSizes" : {"_id_" : 10469376},"ok" : 1}},"ok" : 1}
View Code

    可以看出資料又被平均分配到了另外2 台Shard Server 上了!

 

MongoDB整理筆記の移除Shard Server

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.