Configuring MongoDB on Linux

Source: Internet
Author: User
Tags create mongodb

MongoDB is a product between a relational database and a non-relational database, and is the most versatile and most like relational database in a non-relational database. The data structure he supports is very loose and is a JSON-like Bson format, so you can store more complex data types. MONGO's biggest feature is that the query language he supports is very powerful, and its syntax is a bit like an object-oriented query language that almost implements most of the functionality of a relational database single-table query, and also supports indexing of data.

1. Download the Linux installation package

For example, put in a local corner, remember the location Oh ~
650) this.width=650; "src=" Http://www.linuxprobe.com/wp-content/uploads/2017/07/mongodb1.png "alt=" configured on Linux MongoDB configures MongoDB "width=" 651 "height=" 145 "class=" Alignnone size-full wp-image-78247 "title=" on Linux to configure MongoDB on Linux Configure MongoDB "style=" vertical-align:middle;height:auto;margin:10px Auto on Linux, "/>

2. Connect to your Server

SSH [email protected] Your IP//Enter the password

3. Install package Upload

Open the SSH window (command+n), if it is Windows opens a new CMD window, because we want to manipulate local files, the previous window we have logged the server. There are many ways to pass, I only show one of them.

CD "Install package folder"//go to the location where you just installed the package
SCP "local file" [email protected] Your IP//Enter the password to start the transfer

For example, I am transmitting to the root directory of the server. Actually not recommended, you can put in an intrinsic directory, such as/usr/local
650) this.width=650; "src=" Http://www.linuxprobe.com/wp-content/uploads/2017/07/mongodb2.png "alt=" configured on Linux MongoDB on Linux configuration MongoDB "width=" "height=" "class=" Alignnone size-full wp-image-78234 "title=" on Linux configuration MongoDB on Configure MongoDB "style=" vertical-align:middle;height:auto;margin:10px Auto on Linux, "/>
ls-lIn the form of a list, we can see that the download has been successful.
650) this.width=650; "src=" Http://www.linuxprobe.com/wp-content/uploads/2017/07/mongodb3.png "alt=" configured on Linux MongoDB configures MongoDB "width=" "height=" 269 "class=" Alignnone size-full wp-image-78235 "title=" on Linux to configure MongoDB on Linux Configure MongoDB "style=" vertical-align:middle;height:auto;margin:10px Auto on Linux, "/>

4. Unzip the installation package

TAR-ZXVF mongodb-linux-x86_64-3.4.6.tgz //Unzip different files have different decompression commands, their own Baidu can
650) this.width=650; "src=" Http://www.linuxprobe.com/wp-content/uploads/2017/07/mongodb4.png "alt=" configured on Linux MongoDB configures MongoDB "width=" "height=" 121 "class=" Alignnone size-full wp-image-78236 "title=" on Linux to configure MongoDB on Linux Configure MongoDB "style=" vertical-align:middle;height:auto;margin:10px Auto on Linux, "/>

5. A step in pits

Just said that everyone can put the contents of each installation into a fixed folder, so I moved the extracted files to the/usr/local/mongodb directory, if you have been placed in your favorite location, you can skip this step. If you don't know how to move, you can look at it.

Cd/user/local//Enter Local
mkdir MongoDB//Create MongoDB folder
CD///Enter the root directory
MV Mongodb-linux-x86_64-3.4.6/usr/local/mongodb/* Move the unpacking package into the/usr/local/mongodb*/

650) this.width=650; "src=" Http://www.linuxprobe.com/wp-content/uploads/2017/07/mongodb5.png "alt=" configured on Linux MongoDB configures MongoDB "width=" "height=" 209 "class=" Alignnone size-full wp-image-78237 "title=" on Linux to configure MongoDB on Linux Configure MongoDB "style=" vertical-align:middle;height:auto;margin:10px Auto on Linux, "/>

6. Configure the MONGODB operating environment

mkdir data//Create Data folder, hold database db file mkdir logs//Create logs folder, store log file CD logs//Enter logs touch Mongo.log//create log file CD. Back to mkdir etc//Create configuration Folder CD etc//Enter etc Vim mongo.conf//Edit simultaneously create mongo.conf file

The following is the code in the mongo.conf file, we are optimistic not to write wrong, enter the file after you click Keyboard I to start writing code.

dbpath = /usr/local/mongodb/data //path Be sure to enter an absolute   logpath = /usr/local/ mongodb/logs/mongo.log //path must be entered absolute   logappend = true  journal =  true  quiet = true  port = 27017 //Port 

Press ESC to exit, then press shift+: will appear at the bottom: then enter Wq, save and exit the meaning.
650) this.width=650; "src=" Http://www.linuxprobe.com/wp-content/uploads/2017/07/mongodb6.png "alt=" configured on Linux MongoDB configures MongoDB "width=" "height=" 476 "class=" Alignnone size-full wp-image-78238 "title=" on Linux to configure MongoDB on Linux Configure MongoDB "style=" vertical-align:middle;height:auto;margin:10px Auto on Linux, "/>
This is the end of the step.

7. Start MongoDB

cd mongodb/mongodb-linux-x86_64-3.4.6/bin //into the bin directory of the installation package  mongod -f /usr/local/ mongodb/etc/mongo.conf  //Start 1 method    or  ./mongod -f /usr/local/mongodb/etc/ mongo.conf  //Startup 2 Method 

If you enter this command, it appears as if, nothing changes, only the cursor flashes.
650) this.width=650; "src=" Http://www.linuxprobe.com/wp-content/uploads/2017/07/mongodb7.png "alt=" configured on Linux MongoDB on Linux configuration MongoDB "width=" "height=" "class=" Alignnone size-full wp-image-78239 "title=" on Linux configuration MongoDB on Configure MongoDB "style=" vertical-align:middle;height:auto;margin:10px Auto on Linux, "/>

8. Whether the local test was successful

I use the visualizer Robo 3t, new link, address input server addresses, port filled in your mongo.conf configuration, the basic is 27027.
650) this.width=650; "src=" Http://www.linuxprobe.com/wp-content/uploads/2017/07/mongodb8.png "alt=" configured on Linux MongoDB configures MongoDB "width=" "height=" 488 "class=" Alignnone size-full wp-image-78240 "title=" on Linux to configure MongoDB on Linux Configure MongoDB "style=" vertical-align:middle;height:auto;margin:10px Auto on Linux, "/>
Click Save, such as operation, to Connect.
650) this.width=650; "src=" Http://www.linuxprobe.com/wp-content/uploads/2017/07/mongodb9.png "alt=" configured on Linux MongoDB configures MongoDB "width=" "height=" 386 "class=" Alignnone size-full wp-image-78241 "title=" on Linux to configure MongoDB on Linux Configure MongoDB "style=" vertical-align:middle;height:auto;margin:10px Auto on Linux, "/>
If it comes to this step is basically a success.
650) this.width=650; "src=" Http://www.linuxprobe.com/wp-content/uploads/2017/07/mongodb10.png "alt=" configured on Linux MongoDB configures MongoDB "width=" "height=" 257 "class=" Alignnone size-full wp-image-78242 "title=" on Linux to configure MongoDB on Linux Configure MongoDB "style=" vertical-align:middle;height:auto;margin:10px Auto on Linux, "/>

9. Small pits warning

> The path I wrote earlier in the mongo.conf was relative, and the following question arose.
650) this.width=650; "src=" Http://www.linuxprobe.com/wp-content/uploads/2017/07/mongodb11.png "alt=" configured on Linux MongoDB configures MongoDB on Linux "width=" "height=" "class=" Alignnone size-full wp-image-78243 "title=" on Linux configuration MongoDB on Configure MongoDB "style=" vertical-align:middle;height:auto;margin:10px Auto on Linux, "/>

And that's the way it is.
650) this.width=650; "src=" Http://www.linuxprobe.com/wp-content/uploads/2017/07/mongodb12.png "alt=" configured on Linux MongoDB configures MongoDB "width=" "height=" 290 "class=" Alignnone size-full wp-image-78244 "title=" on Linux to configure MongoDB on Linux Configure MongoDB "style=" vertical-align:middle;height:auto;margin:10px Auto on Linux, "/>

10. Summary

There are many ways, I write only one of them, I am also the first time to install. which also a bit of pit, encountered problems do not concede, always solve, write the wrong place, I hope you are not hesitate to enlighten ~


Configuring MongoDB on Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.