I am trying to do export:
ilya@server ~]$ mongoexport --host localhost --port 27000 --collection system.users --db mydb --out profile.json
connected to: localhost:27000
exported 1 records
Works ok with system.users
But doesn't work with system.profile:
[ilya@server ~]$ mongoexport --host localhost --port 27000 --collection system.profile --db mydb --out profile.json
connected to: localhost:27000
exported 0 records
Collection is not empty:
[ilya@server ~]$ mongo localhost:27000/mydb
MongoDB shell version: 2.2.3
connecting to: localhost:27000/mydb
mongos> db.system.profile.count();
1044
I need these rows to export and work with them somewhere, for example as with normal collection(not capped as system.profile).
From database-profiling-and-sharding:
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.
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)
So try to mongoexport directly from the mongod instance that holds the system.profile collection you want.
**UPDATE**
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).
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());
}
then execute the following line from the bash shell:
mongo localhost:27000/mydb print-profile.js > profile.json
Wait a little and in profile.json you will have the data you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With