douqi1212 2012-03-30 06:41
浏览 833


How can I rename a collection in mongodb sharding? Because I tried in my production server, its thrown the following error just for your references.

My Requirement we have to add few more fields with value on existing collection. But In production we can't able to disrupt the traffic based collection and anytime request comes from member simultaneously. So we have planned to populate the entire records from sql to mongo in another collection and then rename the collection and make it as production. its our plan. But we cant able to take it further. Following error we got it.

db.clientdetails.renameCollection( "clientdetails_bkup" ); {
            "assertion" : "You can't rename a sharded collection",
            "assertionCode" : 13138,
            "errmsg" : "db assertion failure",
            "ok" : 0 }

If not possible in mongodb sharding, please share your suggestion or alternative way we can solve this issue.

Please suggest what we have to take it further?.

  • 写回答

2条回答 默认 最新

  • duanfang2708 2012-03-30 14:09

    There is no way to rename a sharded collection.

    You can copy all the docs to a new collection.

    Or create multiple collections based on a weekly/period date, and use as the current one. Then have your application always use the current one by name and change the name at each period break.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
  • dsqa6272 2019-01-25 11:55

    This is one of the worst limitations of MongoDB. we can not rename sharded collection. Mongodb Document says: db.collection.renameCollection() is not supported on sharded collections.

    We had the same situation where we created another temporary collection, loaded data into that temporary collection. Dropped the existing sharded collection and created new collection with new name and then again loaded back data in newly named collection. This process was very




  • ¥15 相同型号电脑与配置,发现主板有一台貌似缺少了好多元器件似的,会影响稳定性和使用寿命吗?
  • ¥15 要求编写稀疏矩阵A的转置矩阵的算法
  • ¥15 编写满足以下要求的停车场管理程序,设停车场只有一个可停放n辆车的狭窄通道且只有一个大门可供车辆进出。
  • ¥15 C语言:数据子序列基础版
  • ¥20 powerbulider 导入excel文件,显示不完整
  • ¥15 用keil调试程序保证结果进行led相关闪烁
  • ¥15 paddle训练自己的数据loss降不下去
  • ¥20 用matlab的pdetool解决以下三个问题
  • ¥15 单个福来轮的平衡与侧向滑动是如何做到的?
  • ¥15 嵌入式Linux固件,能直接告诉我crc32校验的区域在哪不,内核的校验我已经找到了,uboot没有