douqi1212 2012-03-30 06:41
浏览 840
已采纳

MongoDB在Sharding中重命名集合

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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置