Introduction to MongoDB
MongoDB is an open source document-based database that is built on an architecture of documents and collections. All the data is stored as documents that comprise sets of key-value pairs. Documents are grouped inside separate collections equivalent to the tables in relational databases. The documents are stored using a json-similar rich format called BSON. MongoDB provides high performance, availability and scalability. It uses the document data model which is more flexible than the relational model since it allows for more flexible representation of complex hierarchical relationships using embedded documents. MongoDB is also designed to scale out by supporting automatic scaling using sharding and replication. MongoDB is designed to be a general database offering many nice features such as generic secondary indexes, aggregation pipeline, and automatic failover. Therefore, we are using MongoDB as our operational data store to store everything related to the user, devices, rules, actions, etc.
In this blog, I plan to give a quick tutorial in how to run mongoDB as a container in IBM cloud platform "Bluemix".
Deploy mongodb as a docker container in Bluemix:
Below are the steps to deploy mongodb as a docker container in Bluemix:
- If it hasn't been done already, you need to sign up for Bluemix account and create an organization/space. There are plenty of tutorials in the internet to do so. It should be an easy straight-forward step.
- Login and select your organization/space that was created in the first step using the below terminal command:
cf login
- Install the bluemix container "cf ic" terminal plugin using the below terminal command:
cf install-plugin https://static-ice.ng.bluemix.net/ibm-containers-mac
cf ic namespace set <namespace_name>
- Prepare the container plugins "cf ic":
cf ic init
- Copy the mongodb official docker image to bluemix:
cf ic cpi mongo:latest registry.ng.bluemix.net/<namespace_name>/mongo:latest
- Confirm that the image copied:
cf ic images
- Run the mongodb docker container in bluemix:
cf ic run --name mongo -p 27017:27017 -d registry.ng.bluemix.net/<namespace_name>/mongo:latest
- Confirm that the container is running:
cf ic ps
- Request a public IP address from Bluemix:
cf ic ip request
- Bind the created IP address to the running mongodb container:
cf ic ip bind <IP_Address> mongo
- Confirm that mongodb container is up and running and test it with some queries using mongo shell:
cf ic exec -it mongo bash
mongo
- After executing all the above steps, you should be able to see the container running in bluemix as shown below:
No comments:
Post a Comment