【MongoDB】查看数据库集合的占用空间,清理集合的冗存空
发表于:2024-10-25 作者:千家信息网编辑
千家信息网最后更新 2024年10月25日,到库下面查看占用空间tables = db.getCollectionNames();tables.forEach( function (item) { stats=db.runCommand
千家信息网最后更新 2024年10月25日【MongoDB】查看数据库集合的占用空间,清理集合的冗存空
到库下面查看占用空间
tables = db.getCollectionNames();tables.forEach( function (item) { stats=db.runCommand({collStats:item}); sizeGB = stats.storageSize/1024/1024/1024; prettyGB = Math.round(sizeGB)+ 'GB'; print(item, prettyGB)})
清理冗余空间
// primarydb.runCommand({compact:'flow_down_stream_info',force:true})// secondarydb.runCommand({compact:'flow_down_stream_info'})
建议先在从库上运行,观察没问题后再在primary上运行
不建议使用repairDatabase()命令
有可能造成数据损坏
Just to clarify, please be careful about using repairDatabase on a replica set node. repairDatabase is meant to be used to salvage readable data i.e. after a disk corruption, so it can remove unreadable data and let MongoDB start in the face of disk corruption.If this node has an undetected disk corruption and you run repairDatabase on it, this could lead into that particular node having a different data content vs. the other node as a result of repairDatabase. Since MongoDB assumes all nodes in a replica set contains identical data, this could lead to crashes and hard to diagnose problems. Due to its nature, this issue could stay dormant for a long time, and suddenly manifest itself with a vengeance, seemingly without any apparent reason.WiredTiger will eventually reuse the empty spaces with new data, and the periodic checkpointing that WiredTiger does could potentially release space to the OS without any intervention on your part.If you really need to give space back to the OS, then an initial sync is the safest choice if you have a replica set. On a standalone, dump/restore will achieve the same result. Otherwise, compact is the safer choice vs. repairDatabase. Please backup your data before doing any of these, since in my opinion this would qualify as a major maintenance
MongoDB / WiredTiger: reduce storage size after deleting properties from documents
另外
repairDatabase命令对GridFS的库不起作用
空间
命令
建议
运行
数据
作用
冗余
问题
i.e.
观察
数据库
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
东阳义乌互联网科技
售后服务器维护类工作
上半年网络安全问题
杭州存臻互联网科技有限公司
关于健康的数据库表格
华为青岛软件开发云洗心得体会
协裕网络技术公司
软件开发项目质量管理方法
安装服务器怎么获取地址
wow2020联盟服务器推荐
网络安全漏洞一共有多少个
sql的数据库设计
屋顶花园平面图软件开发
软件开发选什么样的电脑
网络安全法治案例详细
lolpbe服务器是什么
在新氧做软件开发赚钱吗
计算机网络技术年薪
程寰软件开发过程管理系统
resset 高频数据库
没管理员密码改DNS服务器获取
oracle数据库锁死
软件开发简历未来展望
第三方需要提供域名和服务器吗
哪些学校有欧睿数据库
网络安全知识内容识别填充
2042无法连接到服务器
安全生产基础数据库
软件开发企业新收入准则
陕西医保动态数据库