采用官方工具导出mongo数据为json格式
文档:https://docs.mongodb.com/manual/reference/program/mongoexport/
可以远程导出,只要有host:port即可。
首先需要安装tools:
在redhat中:
文档:https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/
Create a /etc/yum.repos.d/mongodb-org-3.2.repo file so that you can install MongoDB directly, using yum.
[mongodb-org-3.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc
一共有以下几种选择
mongodb-org | A metapackage that will automatically install the four component packages listed below. |
---|---|
mongodb-org-server | Contains the mongod daemon and associated configuration and init scripts. |
mongodb-org-mongos | Contains the mongos daemon. |
mongodb-org-shell | Contains the mongo shell. |
mongodb-org-tools | Contains the following MongoDB tools: mongoimport bsondump, mongodump,mongoexport, mongofiles, mongooplog, mongoperf, mongorestore, mongostat, and mongotop. |
如果全部安装:
sudo yum install -y mongodb-org
如果只安装tools
sudo yum install -y mongodb-org-tools
sudo mongoexport -h $mongoDBUri --db $db_name -c $collection_name -q '{
$or:[
{"alerts.FamilyFriendly.completed":false},
{"alerts.GasAndSafety.completed":false},
{"alerts.Breakfast.completed":false},
{"alerts.SpokenLanguage.completed":false},
{"alerts.LocationHighlights.completed":false},
{"alerts.AccessibilityEnsure.completed":false},
{"alerts.AirportShuttle.completed":false},
{"alerts.RoomSize.completed":false},
{"alerts.Renovations.completed":false}
]
}' -f hotelId,alerts -o $OUTPUTDIR/contentScore-$(date +%F)-e.json --jsonArray
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有