位置: 编程技术 - 正文

Mongodb 删除添加分片与非分片表维护(mongodb如何删除)

编辑:rootadmin

推荐整理分享Mongodb 删除添加分片与非分片表维护(mongodb如何删除),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:mongodb如何删除,mongodb删除数据释放空间,mongodb删除文档命令,mongodb增删改查,mongodb删除文档命令,mongodb如何删除,mongodb增删改查,mongodb如何删除,内容如对您有帮助,希望把文章链接给更多的朋友!

MongoDB 是一个基于分布式文件存储的数据库。由 C++ 语言编写。旨在为 WEB 应用提供可扩展的高性能数据存储解决方案。

MongoDB 是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的。

一、如何移除分片

1、确认balancer已经开启

mongos> sh.getBalancerState()true

2、移除分片

注:在admin db下执行命令。

3、检查迁移的状态

同样执行

remaining中的chunks表示还有多少数据块未迁移。

Mongodb 删除添加分片与非分片表维护(mongodb如何删除)

4、移除未分片数据

In a cluster, a database with unsharded collections stores those collections only on a single shard.That shard becomes the primary shard for that database. (Different databases in a cluster can have different primary shards.)WARNINGDo not perform this procedure until you have finished draining the shard.1)To determine if the shard you are removing is the primary shard for any of the cluster's databases, issue one of the following methods:sh.status()db.printShardingStatus()In the resulting document, the databases field lists each database and its primary shard.For example, the following database field shows that the products database uses mongodb0 as the primary shard:{ "_id" : "products", "partitioned" : true, "primary" : "mongodb0" }2)To move a database to another shard, use the movePrimary command. For example, to migrate all remaining unsharded data from mongodb0 to mongodb1, issue the following command:use admindb.runCommand( { movePrimary: "products", to: "mongodb1" }) --products为db nameThis command does not return until MongoDB completes moving all data, which may take a long time. The response from this command will resemble the following:{ "primary" : "mongodb1", "ok" : 1 }If you use the movePrimary command to move un-sharded collections, you must either restart all mongos instances,or use the flushRouterConfig command on all mongos instances before writing any data to the cluster. This action notifies the mongos of the new shard for the database.If you do not update the mongos instances' metadata cache after using movePrimary, the mongos may not write data to the correct shard. To recover, you must manually intervene.

根据上面所说,迁移非分片表 时 最好停机,在运行db.runCommand( { movePrimary: "products", to: "mongodb1" }) 命令完成之后,刷新所有mongos后(所有mongos上运行db.runCommand("flushRouterConfig")),再对外提供服务。当然也可以重新启动所有mongos实例 。

5、完成迁移

如果state为 completed,表示已完成迁移。

二、添加分片

1、首先确认balancer已经开启

mongos> sh.getBalancerState()true

2、执行添加分片的命令

如果出现以下错误,删除目标shard3上的test1数据库,再次执行命令

最后运行sh.status()命令确认迁移是否成功,可能会花比较长的时间。

以上内容是给大家介绍了Mongodb 删除添加分片与非分片表维护的全部叙述,希望对大家有所帮助。

MongoDB索引使用详解 索引就像书的目录,如果查找某内容在没有目录的帮助下,只能全篇查找翻阅,这导致效率非常的低下;如果在借助目录情况下,就能很快的定位具体

使用aggregate在MongoDB中查询重复数据记录的方法 MongoDB中聚合(aggregate)主要用于处理数据(诸如统计平均值,求和等),并返回计算后的数据结果。有点类似sql语句中的count(*)。aggregate()方法MongoDB中聚合的方

mongodb使用心得简单总结 1.mongodb特性1)mongo是一个面向文档的数据库,它集合了nosql和sql数据库两方面的特性。2)所有实体都是在首次使用时创建。3)没有严格的事务特性,但

标签: mongodb如何删除

本文链接地址:https://www.jiuchutong.com/biancheng/312100.html 转载请保留说明!

上一篇:Ubuntu系统中安装MongoDB及其启动命令mongod的教程(ubuntu系统安装教程)

下一篇:MongoDB索引使用详解(mongodb索引使用正则表达式)

  • 取得投资款属于什么过程
  • 收到投资款要交企业所得税吗为什么
  • 销售额是含税价还是不含税价
  • 饭店开业几年后可以申请升级
  • 企业保持存货的必要性是什么
  • 终止经营净利润计算公式
  • 合资公司注册成立流程
  • 去税务局申报需要带营业执照吗
  • 企业清算过程中应收应付的处置
  • 无货源发货如何填写物流单
  • 通信服务费包括哪些
  • 在建工程明细科目
  • 现金抵用券购买怎么用
  • 个人出租房屋税率表2023年
  • 离婚房屋权属变动怎么办
  • 未取得合法票据费用怎么算
  • 预提 冲销
  • 投资收益年底结转怎么算
  • 技术转让收入属于主营业务收入吗
  • 购买设备属于经营性现金流出吗
  • 工会财务总结报告
  • 企业代扣员工社保怎样做分录
  • 期初建账分录
  • 2020最新win10密钥
  • wp网站迁移
  • 验签失败发票如何撤销
  • vue3+vite+typescript出现does not provide an export named ‘xxx‘ 解决方法
  • 商业企业营业收入
  • 购买电脑如何入账
  • 如何判断自己风寒还是风热
  • 季度盈利弥补亏损利润表
  • 现代c++教程
  • opencv+python
  • 会计中财务费用为负
  • 员工办理健康证需要什么材料
  • 印花税的征税范围及税率
  • 筹建期间发生的开办费用
  • 母公司和子公司可以一起投标吗
  • 单位向职工出租房子
  • 增值税专票不认证后果
  • python np数组
  • rbac权限管理设计
  • 冲销以前年度费用会计分录
  • 公司购进设备会计分录
  • 原始凭证分割单可以入账么
  • 水电费进项税额转出情形
  • sqlserver附加数据库语句
  • 交易性金融资产属于流动资产
  • SQL Server实时同步更新远程数据库遇到的问题小结
  • 差旅费抵扣增值税税率
  • 交易性金融资产公允价值变动怎么算
  • 外出经营必须办理外管证吗
  • 出口应纳增值税
  • 公司与股东的往来款
  • 研发费用属于哪类会计科目
  • 银行利息收入的会计分录怎么写
  • 佣金开什么发票内容?
  • mysql安装详细步骤
  • sqlserver数据库备份
  • xboxone怎么设置中文
  • win7清理系统垃圾的方法
  • Windows Remote Shell(WinRM)使用介绍
  • linux文件目录的含义
  • administrator帐户已锁定
  • 如何改变linux终端界面的颜色
  • linux整理磁盘
  • qt底层绘图引擎
  • linux中查看命令怎么使用
  • vue中拦截器
  • xcopy /s /e
  • 微信内置浏览器怎么清除缓存
  • u3d unity3d
  • json初学
  • 浅谈一下新冠的好处
  • jquery找父级
  • 中国税务定额发票怎么开
  • 北京第三税务所咨询电话
  • 买车险代收车船税合法吗
  • 如何打印更正申请
  • 地方公安局归谁管
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设