Installing MongoDB under Linux

Source: Internet
Author: User
Tags install mongodb

MongoDB is a C + + written based on Distributed file Storage database, is a relationship between relational and non-relational database, of course, also belongs to the ranks of NoSQL, storage mode and Redis similar, is the JSON format of kav-value storage, but Redis is memory storage, And MongoDB is stored on the hard disk like a normal database directory.

The following is the deployment of a single node MongoDB on Linux, as follows:

First go to MongoDB official website download package, home is: https://www.mongodb.com/

  

Then, click on the top right corner of the download button to enter the download interface, is: Https://www.mongodb.com/download-center enter and then pull down will see the download options

  

You can see there are many versions, the default is to select the first community version, and then the following operating system is the default Windows, here to choose Linux and then according to the operating system is 32-bit or 64-bit download the corresponding version of the package can be downloaded here is mongodb-linux-x86_ 64-3.2.10.tgz, upload to Linux system after download is complete, start to perform installation

Here the scheduled installation directory for/usr/local/mongodb, in fact, you can determine, now execute the following command to install MongoDB to the specified location:

tar -xvzf mongodb-linux-x86_64-3.2. Ten . tgz MV mongodb-linux-x86_64-3.2. Ten /usr/local//usr/local/mongodb/

Now you have installed and entered the MongoDB directory, this time in order to facilitate the implementation, you can add the Bin directory absolute path to the environment variable, the specific process is no longer described

The default data directory of the MongoDB database is stored in/data/db so you can execute the command mkdir -p/data/db Build the directory, or you can manually set up other directories, but the data directory must be created manually, whether by default or custom. Otherwise MongoDB will error, now can start MongoDB service, the command is: ./bin/mongod service is performed by default in the foreground, if the data directory is not/data/db then you can manually specify the directory, the startup command is: ./bin/ the default port for the Mongod--dbpath=/usr/mongo_data MongoDB database service is 27017

In addition MongoDB provides a simple Web user interface, you can view the status of the service, etc., default does not open can be added when starting the service parameters, the command is: ./bin/mongod--rest

After startup, the default Web management port is 28017, and when you visit http://ip:28017 you can see the admin interface

  

If you want to keep the service running in the background, you can use nohup or screen

The command can be executed in the case that the MongoDB service is started ./bin/mongo into MongoDB's backend management Shell

The first time you enter the MongoDB shell, the test library is selected by default, but this is an empty library, and then enters the database that the user operates, when the execution show DBS can view the list of non-empty databases, you can see that the default is only local one, The rest of the data is not displayed, the execution db can view the currently selected database, if you want to switch to select a database can execute use name1 , here can switch to the NAME1 database, if the database exists then switch, if not exist directly created, So there is a significant feature in MongoDB, all databases and data sets (data tables) are created in use, the user does not have to specify the creation in advance, the exit MongoDB Shell can execute the command exit or quit () can

Here, the deployment of MongoDB under Linux and the simplest shell get-started operation is complete.

Installing MongoDB under 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.