Import JSON data to MongoDB on OpenShift
Openshift v2.0 has now reached End of Life and will be replaced by v3.0.
You will need a few things to get this project started. First you will need a JSON file, an account with Openshift as well as MongoDB and MongoRock.
Make sure your JSON data is delineated by
\n. This example file contains coordinates for the national parks within the U.S.
You will need to use
scp to upload your JSON file to your server. Openshift only allows you to upload data to
app-root/data. You will get the path to your sever from within the Openshift dashboard.
scp path/to/myfile.json firstname.lastname@example.org:app-root/data
The next step is to SSH into your server
You upload the JSON file from your server to MongoDB using
mongoimport --host 127.x.xx.xxx --db mydb -collection my-collection --username admin --password XXXXXXX --type json --file app-root/data/myfile.json
Double check your work using MongoRock.