MongoDB Administration using RockMongo and concept of GridFS in MongoDB

Last updated on May 30 2022
Satyen Sahu

Table of Contents

MongoDB Administration using RockMongo and concept of GridFS in MongoDB

Working with RockMongo

RockMongo is a MongoDB administration tool using which you can manage your server, databases, collections, documents, indexes, and a lot more. It provides a very user-friendly way for reading, writing, and creating documents. It is similar to PHPMyAdmin tool for PHP and MySQL.

Downloading RockMongo

You can download the latest version of RockMongo from here: https://github.com/iwind/rockmongo

Installing RockMongo

Once downloaded, you can unzip the package in your server root folder and rename the extracted folder to rockmongo. Open any web browser and access the index.php page from the folder rockmongo. Enter admin/admin as username/password respectively.

Working with RockMongo

We will now be watching at some basic operations that you can perform with RockMongo.

Creating New Database

To create a new database, click Databases tab. Click Create New Database. On the next screen, provide the name of the new database and click on Create. You’ll see a new database getting added in the left panel.

Creating New Collection

To create a new collection inside a database, click on that database from the left panel. Click on the New Collection link on top. Provide the required name of the collection. Do not worry about the other fields of Is Capped, Size and Max. Click on Create. A new collection will be created and you’ll be able to see it in the left panel.

Creating New Document

To create a new document, click on the collection under which you want to add documents. When you click on a collection, you’ll be able to see all the documents within that collection listed there. To create a new document, click on the Insert link at the top. You can enter the document’s data either in JSON or array format and click on Save.

Export/Import Data

To import/export data of any collection, click on that collection and then click on Export/Import link on the top panel. Follow the next instructions to export your data in a zip format and then import the same zip file to import back data.

MongoDB – GridFS

GridFS is that the MongoDB specification for storing and retrieving large files such as images, audio files, video files, etc. It is kind of a file system to store files but its data is stored within MongoDB collections. GridFS has the capability to store files even greater than its document size limit of 16MB.
GridFS divides a file into chunks and stores each chunk of data in a separate document, each of maximum size 255k.
GridFS by default uses two collections fs.files and fs.chunks to store the file’s metadata and the chunks. Each chunk is identified by its unique _id ObjectId field. The fs.files serves as a parent document. The files_id field in the fs.chunks document links the chunk to its parent.
Subsequent is a sample document of fs.files collection −
{
“filename”: “test.txt”,
“chunkSize”: NumberInt(261120),
“uploadDate”: ISODate(“2014-04-13T11:32:33.557Z”),
“md5”: “7b762939321e146569b07f72c62cca4f”,
“length”: NumberInt(646)
}
The document specifies the file name, chunk size, uploaded date, and length.
Subsequent is a sample document of fs.chunks document −
{
“files_id”: ObjectId(“534a75d19f54bfec8a2fe44b”),
“n”: NumberInt(0),
“data”: “Mongo Binary Data”
}
Adding Files to GridFS
Now, we will store an mp3 file using GridFS using the put command. For this, we will use the mongofiles.exe utility present in the bin folder of the MongoDB installation folder.
Open your command prompt, navigate to the mongofiles.exe in the bin folder of MongoDB installation folder and type the subsequent code −
>mongofiles.exe -d gridfs put song.mp3
Here, gridfs is that the name of the database in which the file will be stored. If the database is not present, MongoDB will automatically create a new document on the fly. Song.mp3 is that the name of the file uploaded. To see the file’s document in database, you can use find query −
>db.fs.files.find()
The above command returned the subsequent document −
{
_id: ObjectId(‘534a811bf8b4aa4d33fdf94d’),
filename: “song.mp3”,
chunkSize: 261120,
uploadDate: new Date(1397391643474), md5: “e4f53379c909f7bed2e9d631e15c1c41”,
length: 10401959
}
We can also see all the chunks present in fs.chunks collection related to the stored file with the subsequent code, using the document id returned in the previous query −
>db.fs.chunks.find({files_id:ObjectId(‘534a811bf8b4aa4d33fdf94d’)})
In my case, the query returned 40 documents meaning that the whole mp3 document was divided in 40 chunks of data.
So, this brings us to the end of blog. This Tecklearn ‘MongoDB Administration using RockMongo and concept of GridFS in MongoDB’ helps you with commonly asked questions if you are looking out for a job in MongoDB and No-SQL Database Domain.
If you wish to learn and build a career in MongoDB or No-SQL Database domain, then check out our interactive, MongoDB Training, that comes with 24*7 support to guide you throughout your learning period. Please find the link for course details:

MongoDB Training

MongoDB Training

About the Course

Tecklearn’s MongoDB Training helps you to master the NoSQL database. The course makes you job-ready by letting you comprehend schema design, data modelling, replication, and query with MongoDB through real-time examples. Along with this, you’ll also gain hands-on expertise in installing, configuring, and maintaining the MongoDB environment, including monitoring and operational strategies from this online MongoDB training. Upon completion of this online training, you will hold a solid understanding and hands-on experience with MongoDB.

Why Should you take MongoDB Training?

• MongoDB – a $36 billion to a $40 billion market growing at 8% to 9% annually – Forbes.com
• Average salary of a Mongo DB certified professional is $134k – Indeed.com
• MongoDB has more than 900 customers, including 27 Fortune 100 companies like Cisco, eBay, eHarmony, MetLife & Salesforce.com

What you will Learn in this Course?

Introduction to MongoDB and Importance of NoSQL
• Understanding the basic concepts of RDBMS
• What is NoSQL Database and its significance?
• Challenges of RDBMS and How NoSQL suits Big Data needs
• Types of NoSQL Database and NoSQL vs. SQL Comparison
• CAP Theorem and Implementing NoSQL
• Introduction to MongoDB and its advantages
• Design Goals for MongoDB Server and Database, MongoDB tools
• Collection, Documents and Key Value Pair
• Introduction to JSON and BSON documents
• MongoDB installation
MongoDB Installation
• MongoDB Installation
• Basic MongoDB commands and operations,
• Mongo Chef (MongoGUI) Installation
Schema Design and Data Modelling
• Why Data Modelling?
• Data Modelling Approach
• Data Modelling Concepts
• Difference between MongoDB and RDBMS modelling
• Challenges for Data Modelling
• Model Relationships between Documents
• Data Model Examples and Patterns
• Model Tree Structures
CRUD Operations
• MongoDB Architecture
• CRUD Introduction and MongoDB CRUD Concepts
• MongoDB CRUD Concerns (Read and Write Operations)
• Cursor Query Optimizations and Query Behaviour in MongoDB
• Distributed Read and Write Queries
• MongoDB Datatypes
Indexing and Aggregation Framework
• Concepts of Data aggregation and types and data indexing concepts
• Introduction to Aggregation
• Approach to Aggregation
• Types of Aggregation: Pipeline, MapReduce and Single Purpose
• Performance Tuning
MongoDB Administration
• Administration concepts in MongoDB
• MongoDB Administration activities: Health check, recovery, backup, database sharing and profiling, performance tuning etc.
• Backup and Recovery Methods for MongoDB
• Export and Import of Data from MongoDB
• Run time configuration of MongoDB
MongoDB Security
• Security Introduction
• MongoDB security Concepts and security approach
• MongoDB integration with Java and Robomongo
Got a question for us? Please mention it in the comments section and we will get back to you.

0 responses on "MongoDB Administration using RockMongo and concept of GridFS in MongoDB"

Leave a Message

Your email address will not be published. Required fields are marked *