$ rhc app create MyApp python-3.3
$ rhc cartridge add mongodb-2.4 -a MyApp
The mongodb cartridge provides MongoDB on OpenShift. MongoDB is a document-oriented NoSQL database, using JSON-style documents with dynamic schemas. With OpenShift you can easily deploy and run applications backed by MongoDB using your favorite servers and frameworks. OpenShift Online currently supports MongoDB 2.4.
The mongodb cartridge provides several environment variables to reference for ease of use:
| Variable | Description |
|---|---|
OPENSHIFT_MONGODB_DB_HOST |
The MongoDB IP address |
OPENSHIFT_MONGODB_DB_PORT |
The MongoDB port |
OPENSHIFT_MONGODB_DB_USERNAME |
The MongoDB username |
OPENSHIFT_MONGODB_DB_PASSWORD |
The MongoDB password |
OPENSHIFT_MONGODB_DB_URL |
The MongoDB connection URL (e.g. mongodb://<username>:<password>@<hostname>:<port>/) |
OPENSHIFT_MONGODB_DB_LOG_DIR |
The path to the MongoDB log directory |
Getting a Python app with a MongoDB backend deployed onto OpenShift is as easy as executing two commands:
$ rhc app create MyApp python-3.3
$ rhc cartridge add mongodb-2.4 -a MyApp
These two commands create your "server" and install and configure Python, MongoDB, and a git repository on the server. You can now visit your application on the web at:
http://MyApp-MyDomain.rhcloud.com/