我正在尝试导出:
ilya@server ~]$ mongoexport --host localhost --port 27000 --collection system.users --db mydb --out profile.json connected to: localhost:27000 exported 1 records与 system.users
但不适用于 system.profile:
[ilya@server ~]$ mongoexport --host localhost --port 27000 --collection system.profile --db mydb --out profile.json connected to: localhost:27000 exported 0 records集合不为空:
[ilya@server ~]$ mongo localhost:27000/mydb MongoDB shell version: 2.2.3 connecting to: localhost:27000/mydb mongos> db.system.profile.count(); 1044我需要将这些行导出并在某处使用它们,例如与普通集合一样(不限制为 system.profile).
I need these rows to export and work with them somewhere, for example as with normal collection(not capped as system.profile).
推荐答案来自 数据库分析和分片:
您不能在 mongos 实例上启用分析.启用分析在分片集群中,您必须为每个 mongod 实例启用分析在集群中.
You cannot enable profiling on a mongos instance. To enable profiling in a shard cluster, you must enable profiling for each mongod instance in the cluster.
另见mongoexport 只导出一个分片的数据(虽然这个bug已修复从 1.9.1 开始,您使用的是更高版本)
Also see mongoexport only exports one shard's worth of data (although this bug is fixed since 1.9.1 and you use a much later version)
所以尝试直接从 mongod 实例中 mongoexport 保存你想要的 system.profile 集合.
So try to mongoexport directly from the mongod instance that holds the system.profile collection you want.
**UPDATE**
第二种方法是不使用 mongoexport,而是直接从 mongo shell 获取集合(因为您可以从 mongo shell 内部看到该集合).
A second approach is to not use mongoexport but to take the collection directly from the mongo shell (since you are able to see the collection from inside the mongo shell).
首先编写以下脚本并将其保存到 print-profile.js
To do that first write the following script and save it to print-profile.js
c = db.system.profile.find(); while(c.hasNext()) { printjson(c.next()); }然后从 bash shell 执行以下行:
then execute the following line from the bash shell:
mongo localhost:27000/mydb print-profile.js > profile.json稍等片刻,在 profile.json 中,您将获得所需的数据.
Wait a little and in profile.json you will have the data you need.
更多推荐
从 MongoDB 导出 system.profile 不起作用
发布评论