Linux Environment Installation MongoDB

Source: Internet
Author: User
Tags mongodb commands install node

Introduced

This article describes the steps to install node. JS in a Linux environment, followed by the installation of MongoDB.
In addition, recommend me another article in the windows of MongoDB installation and configuration, first under Windows familiar with the next MongoDB, then see this article will be easier to understand.

Installation steps

corresponding to their own server system, to the official website to download the corresponding version of MongoDB, I am centos 7.4, because I did not find CentOS, I downloaded the mongodb-linux-x86_64-amazon-3.6.0.tgz

Upload Unzip

Will download the good installation package, upload to the server through the FTP tool, I still upload to the/root directory, upload, execute the decompression command:

tar -zxvf mongodb-linux-x86_64-amazon-3.6. 0. tgz

After decompression, there will be a no suffix file, that is, non-compressed file package, for convenience, I renamed it to: mongodb-linux .

Creating a configuration file

In the/root directory (where you install the package, optionally), there is a Mongodb-linux file, and then we create a new MongoDB folder:

mkdir MongoDB

Then move the Mongodb-linux file into this folder:

MV Mongodb-linux MongoDB

This is done to better manage MongoDB related files, do not mix with other files to install.

Create three folders in the MongoDB folder again:

mkdir Data   // used for database mkdir logs   / / for storing log files  mkdir etc    // for storing configuration files

Next, go to the Logs folder to create the mongo.log file:

Touch Mongo.log

Then create the file in the ETC folder mongo.conf :

Touch mongo.conf

viopen Edits by command mongo.conf :

VI mongo.conf

After entering the above command, enter edit mode, press I to enter, enter the content is:

dbpath=/root/mongodb/datalogpath=/root/mongodb/logs/mongo.loglogappend=true  Journal=trueQuiet=truePort=27017

For a description of the configuration file, you can refer to my introduction when installing under Windows.

When you are finished, press esc exit Edit and enter :wq return to save

At this point the entire folder is structured as follows:

|-MongoDB|  | -Data|  | -etc|  |  | -mongo.conf|  | -Logs|  |  | -mongo.log|  | -mongodb-linux

Create a soft link

Similarly, we also create soft links for MongoDB commands:

LN -s/root/mongodb/mongodb-linux/bin/mongo/usr/local/bin/MONGOLN -s/root/ Mongodb/mongodb-linux/bin/mongod/usr/local/bin/mongod

If the input command is not an error, the soft link is successful, you can also go to the/usr/local/bin directory to see:

cd/usr/local/binls -la

At this point you will see all the soft links you have created, such as mine:

Includes a soft link to the last node

Perform

You can test two windows because you can't go to the next one when you execute a command.

In the first window, enter any directory:

Mongod-f/root/mongodb/etc/mongo.conf

-fA configuration file was specified, under Windows--config

Now go to the second window and enter:

Mongo

At this time the familiar interface is out, you can perform database operations, input show dbs to detect it.

Linux Environment Installation MongoDB

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.