公司的一台放多媒体文件的MONGODB要转成SHARD,在测试环境里面对gridfs里面的fs.chunks做sharding的时候。

在一段时间后报错如下 : 
warning: chunk is larger than 65203623200 bytes because of key { files_id: ObjectId('4e2ea40efa30e751113fc633') }
Tue Sep 27 12:27:11 [conn7] about to log metadata event: { _id: "db-xxx-xxx-xxx-xxx.sky-mobi.com.sh.nj-2011-09-27T04:27:11-4388", server: "db-xxx-xxx-xxx-xxx.sky-mobi.com.sh.nj", clientAddr: "xxx.xxx.xxx.xxx:10751", time: new Date(1317097631976), what: "moveChunk.from", ns: "digoal.fs.chunks", details: { min: { files_id: ObjectId('4e2ea40efa30e751113fc633') }, max: { files_id: ObjectId('4e2ea41afa30e751bd40c633') }, step1: 0, step2: 111, note: "aborted" } }
Tue Sep 27 12:28:34 [conn12] warning: can't move chunk of size (approximately) 97528508 because maximum size allowed to move is 67108864 ns: digoal.fs.chunks { files_id: ObjectId('4e2ea40efa30e751113fc633') } -> { files_id: ObjectId('4e2ea41afa30e751bd40c633') }
Tue Sep 27 12:28:45 [conn7] command admin.$cmd command: { moveChunk: "digoal.fs.chunks", from: "digoal001/xxx.xxx.xxx:xxxx,xxx.xxx.xxx:xxxx,xxx.xxx.xxx:xxxx", to: "digoal004/xxx.xxx.xxx:xxxx,xxx.xxx.xxx:xxxx,xxx.xxx.xxx:xxxx", min: { files_id: ObjectId('4e2ea40efa30e751113fc633') }, max: { files_id: ObjectId('4e2ea41afa30e751bd40c633') }, maxChunkSizeBytes: 67108864, shardId: "digoal.fs.chunks-files_id_ObjectId('4e2ea40efa30e751113fc633')", configdb: "xxx.xxx.xxx:xxxx,xxx.xxx.xxx:xxxx,xxx.xxx.xxx:xxxx" } ntoreturn:1 reslen:109 176ms

从日志中可以看到有一个chunk的SIZE是97528508字节,无法移动,because maximum size allowed to move is 67108864
查询了fs.chunks之后,发现有超过150MB的文件。不过这个警告信息是对的,这么大的CHUNK确实不应该被MOVE。应该先SPLIT到64M以下再被MOVE。否则BALANCE进程会带来严重的性能问题。
如果要修改64M的限制,可以进入mongos/config库
db.settings.find() 
{ "_id" : "chunksize", "value" : 64 } 

db.settings.update( {"_id" : "chunksize"}, { $set: {"value" : 200 } } ) 
这将改为200MB.
这个值修改后可能要重启mongos才能生效.

但是推荐还是不要修改。
处理这类事件的手段举例 : 
修改chunksize : 
> use config
> db.settings.update( {"_id" : "chunksize"}, { $set: {"value" : new_chunk_size_in_mb } } ) 
Note though that for an existing cluster, it may take some time for the collections to split to that size, if smaller than before, and currently
autosplitting is only triggered if the collection gets new documents or updates.
手工拆分chunk : 
The following command splits the chunk where the { _id : 99 }} resides (or would reside if present) in two. The key used as the split point is computed internally and is approximately the key which would divide the chunk in two equally sized new chunks.
> use admin
switched to db admin
> db.runCommand( { split : "test.foo"  , find : { _id : 99 } } ) 
...
The Balancer treats all chunks the same way, regardless if they were generated by a manual or an automatic split.
预split : 
In the example below the command splits the chunk where the _id 99 would reside using that key as the split point. Again note that a key need not exist for a chunk to use it in its range. The chunk may even be empty.
> use admin
switched to db admin
> db.runCommand( { split : "test.foo"  , middle : { _id : 99 } } ) 
...
split后的chunk值范围:
["$MinKey", "99")
["99", "$MaxKey")
预move chunk : 
> db.printShardingStatus("verbose")  找到属于哪个shard,需要移动到哪个shard
> db.runCommand({ moveChunk : "foo.bar" , find : { hash : "8000"  }, to : "shard0000"  })
预split和预move chunk的好处 : 
1. Chunks will not split until the data reaches a certain minimum amount in size (hundreds of megabytes). Until this occurs balancing and migration will not take place. When the data volume is this small, distributing data between multiple servers is not required anyway. When pre-splitting manually, many chunks can exist even if very little data is present for each chunk initially.
2. "db.runCommand( { split : "test.foo"  , middle : { _id : 99 } } ) " , This version of the command allows one to do a  data presplitting that is especially useful in a load. If the range and distribution of keys to be data presplitting inserted are known in advance, the collection can be split proportionately to the number of servers using the command above, and the (empty) chunks could be migrated upfront using the moveChunk command.
其他参考资料:
http://groups.google.com/group/mongodb-user/browse_thread/thread/aa73647be2ad9cbe

mongodb log ,warning: chunk is larger than 65203623200 bytes because of key相关推荐

  1. linux c 内核 warning: the frame size of 1040 bytes is larger than 1024 bytes

    问题描述: 在编译内核模块驱动时,如果出现如下警告信息: warning: the frame size of 1040 bytes is larger than 1024 bytes.主要是因为内核 ...

  2. warning: the frame size of 1040 bytes is larger than 1024 bytes

    问题描述: 在编译内核模块驱动时,如果出现如下警告信息: warning: the frame size of 1040 bytes is larger than 1024 bytes.主要是因为内核 ...

  3. POI在sax模式下读取xlsx报错 Characters larger than 4 bytes are not supported解决办法

    使用的POI版本为3.14 在sax模式下读取一个20万行的xlsx报错:org.apache.xmlbeans.XmlException: java.io.CharConversionExcepti ...

  4. Warning: Each record in table should have a unique `key` prop,or set `rowKey` to 解决方法

    在vue项目中,使用vue.ant.design中的Table组件会出现一下报错: 列表中的每个记录应该有唯一的"key"支持,或者将"rowKey"设置为唯一 ...

  5. springboot post 请求参数过长请求接口报错 An HTTP line is larger than 4096 bytes

    springboot项目post请求参数过长请求接口报错如下: 解决办法将post请求参数值调大: server:tomcat:max-http-form-post-size: 5MB

  6. MongoDB 日志切换(Rotate Log Files)实战

    MongoDB 日志切换(Rotate Log Files)实战 1. 在mongo shell下,执行logRotate命令: use admin db.runCommand({logRotate: ...

  7. MongoDB分片实战(三):性能和优化

    插入.查询和更新 插入:MongoDB会根据片键和conifg中的信息写入到指定的分片上. 读取:以下内容摘抄自<深入学习MongoDB> 关于读取:上一节故障恢复中已经有所验证. 更新: ...

  8. MongoDB分片实战

    1. 集群搭建 1.1环境准备 Linux环境 主机 OS 备注 192.168.32.13 CentOS6.3 64位 普通PC 192.168.71.43 CentOS6.2 64位 服务器,NU ...

  9. MongoDB 文档数据库

    文章目录 一.MongoDB 基本介绍 1.简介 2.应用场景 3.MongoDB的特点 4.MongoDB的优势 5.体系架构 二.MongoDB 索引 1.索引操作 2.索引结构 3.索引特性 4 ...

最新文章

  1. 太赞!Python和Excel终于可以互通了
  2. CentOS查看主板型号、CPU、显卡、硬盘等信息
  3. pwm控制舵机转动角度程序_01 舵机旋转控制基础
  4. == Equals ReferenceEquals 的区别
  5. ***检测与网络审计产品是孪生兄弟吗?
  6. [9]UITableView表视图1
  7. 【跃迁之路】【440天】刻意练习系列199(2018.04.21)
  8. QOMO Linux 4.0 正式版发布
  9. linux视频在windows播放器,适用于Windows和Linux的免费多媒体播放器SMPlayer 18.6.0发布 - 爱绿豆...
  10. mysqlreport
  11. python入门--动态绑定属性和方法
  12. 微信公众平台和微信开放平台的区别
  13. 分解动力学类有哪些最新发表的毕业论文呢?
  14. lpx寒假作业案例7
  15. 广告策略评估指标(算法实习day2)
  16. 谷歌正式推出 “密钥登录”,逐步取代传统密码登录
  17. itextpdf 5.5.6版本生成pdf文件 字体设置三种方式
  18. python获取虎牙弹幕_教你用20行代码爬取直播平台弹幕(附源码)
  19. 安卓虚拟键盘_安卓手机开启全局手势导航的方法,拯救老设备
  20. 带你实现女朋友欲罢不能的网易云音乐宇宙尘埃特效

热门文章

  1. Mysql4种方式避免重复插入数据!
  2. 详解JVM内存管理与垃圾回收机制2 - 何为垃圾
  3. 【干货】NLP中对困惑度感到困惑?
  4. 深度学习崛起那年,百度差点签下Hinton
  5. 中国最大AI预训练模型发布:113亿参数!北京智源研究院、阿里、清华等联手打造...
  6. 教育部:不得将研究生当作廉价劳动力!也不得故意拖延毕业时间!
  7. 干货 | 你的Paper阅读能力合格了吗(硕士生版)
  8. 在百度工作是一种什么样的体验?
  9. 让你的 IDEA 好用到飞起来的配置
  10. APP Store案例数据分析