Reader small image

You're reading from  MongoDB High Availability

Product typeBook
Published inJul 2014
Publisher
ISBN-139781783986729
Edition1st Edition
Tools
Right arrow
Author (1)
Afshin Mehrabani
Afshin Mehrabani
author image
Afshin Mehrabani

Afshin Mehrabani is an open source programmer. He is studying to be a computer software engineer. He started programming and web development when he was 12 years old, as well as starting with PHP. Later, he joined the Iran Technical and Vocational Training Organization. He secured the first place and received a gold medal in a competition which was conducted across the entire country in the area of web development. He became a member of the Iran National Foundation of Elite after producing a variety of new programming ideas. He was a software engineer at the Tehran Stock Exchange and is now the head of the web development team in the Yara Company. He cofounded the Usablica team in early 2012 to develop and produce usable applications. He is the author of IntroJs, WideArea, flood.js and some other open source projects. He has contributed to Socket.IO, Engine.IO, and some other open source projects. He is also interested in creating and contributing to open source applications, writing programming articles, and challenging himself with new programming technologies. He has written different articles about JavaScript, Node.js, HTML5, and MongoDB that have been published on different academic websites. Afshin has 5 years of experience in PHP, Python, C#, JavaScript, HTML5, and Node.js in many financial and stock trading projects.
Read more about Afshin Mehrabani

Right arrow

Utilizing MongoDB components


This section contains a brief description of the MongoDB components, file names, and the main purpose of each of them. We will further discuss each item in detail. The following diagram shows you the four main components of MongoDB:

MongoDB components can mainly be classified into the following categories:

  • Core components

  • Import and export tools

  • Diagnostic tools

  • File storage (GridFS) tools

Each file can be placed into one of the aforementioned categories. The core component files are used to run the MongoDB server and start it. The files are also used to manage the MongoDB server from the command-line interface or manage clustering tasks.

Using import and export tools, developers can create dump files from their database in different formats such as BSON, JSON or CSV and restore them into another database again. Certain tools are used to create or restore BSON files, and some tools are responsible for generating and importing other common formats such as JSON or CSV.

MongoDB has many built-in diagnostic tools to manage and control the currently running server. Finally, we can use GridFS tools to interact with filesystem and GridFS components. In the next section, we will give you more details for each category and the processes inside them.

Understanding the core components

Inside this category, you can find the core processes that are required to start the MongoDB server. The MongoDB engine uses these tools to accept requests from different clients.

The components and executable files in this group are as follows:

  • mongod

  • mongo

  • mongos

Understanding mongod

The mongod component is the primary process that is needed for MongoDB to start the server. It manages requests or queries and handles connections.

The following screenshot is the result of executing mongod from the command-line interface:

The preceding screenshot illustrates the result of running mongod from the command line, that is, you finally have a MongoDB server running on port 27017 and a web interface on port 28017, which is the default port.

Like other MongoDB commands, in order to see the parameters of the mongod process, you can simply run following command:

mongod --help 

Here, you can see the result of running the mongod command with the --help parameter. This is shown in the following screenshot:

Note

To read more about the command and figure out what each parameter does, you can visit the MongoDB documentation page at http://docs.mongodb.org/manual/reference/program/mongod/.

Utilizing mongo

After starting the database server, we need to interact with it to issue a command, run commands, run queries, or get reports. In the MongoDB structure, the mongo file is responsible for this task. This is an interactive JavaScript shell that you can utilize from your command-line environment.

Using this executable file, database administrators and also developers can manage the database server or get available databases and collections.

The following screenshot is the result of running the mongo command:

Fortunately, the mongo component provides internal help so that developers can use it to get more information for each command.

The following screenshot shows you the result of running the help command:

Note

To acquire more information about MongoDB and all its parameters, you can visit the MongoDB documentation page at http://docs.mongodb.org/manual/reference/program/mongo/.

Learning about mongos

The mongos instance is responsible for routing read/write commands to shards in a sharded cluster. In fact, all processes and applications will connect to this instance and run queries, then the mongos instance will route commands to available shards. The applications will not interact with shards directly. To run the mongos instance, we can provide sharded cluster configurations using a config file or command-line parameters.

In further chapters, we will discuss this process in detail.

Note

To gain more knowledge about the mongos command and its parameters, you can visit the MongoDB documentation page at http://docs.mongodb.org/manual/reference/program/mongos/.

Previous PageNext Page
You have been reading a chapter from
MongoDB High Availability
Published in: Jul 2014Publisher: ISBN-13: 9781783986729
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Afshin Mehrabani

Afshin Mehrabani is an open source programmer. He is studying to be a computer software engineer. He started programming and web development when he was 12 years old, as well as starting with PHP. Later, he joined the Iran Technical and Vocational Training Organization. He secured the first place and received a gold medal in a competition which was conducted across the entire country in the area of web development. He became a member of the Iran National Foundation of Elite after producing a variety of new programming ideas. He was a software engineer at the Tehran Stock Exchange and is now the head of the web development team in the Yara Company. He cofounded the Usablica team in early 2012 to develop and produce usable applications. He is the author of IntroJs, WideArea, flood.js and some other open source projects. He has contributed to Socket.IO, Engine.IO, and some other open source projects. He is also interested in creating and contributing to open source applications, writing programming articles, and challenging himself with new programming technologies. He has written different articles about JavaScript, Node.js, HTML5, and MongoDB that have been published on different academic websites. Afshin has 5 years of experience in PHP, Python, C#, JavaScript, HTML5, and Node.js in many financial and stock trading projects.
Read more about Afshin Mehrabani