Linux under MongoDB installation

Source: Internet
Author: User
Tags mongodump mongorestore

2.

Unzip the file into a directory, and then rename it:

1.[[email protected] src]# TAR-XZVF Mongodb-linux-i686-1.8.1.tgz.tar

2.[[email protected] src]# mv mongodb-linux-i686-1.8.1/usr/local/mongodb/

3. View post-installation files:

1.[[email protected] src]# cd/usr/local/mongodb/

2.[[email protected] mongodb]# ls

3.bin

gnu-agpl-3.0

Readme

Third-party-notices

4.[[email protected] mongodb]# CD bin/

5.[[email protected] bin]# ls

6.bsondump

Dbbak

Mongo

Mongod

Mongodump

Mongoexport

Mongofiles

Mongoimport

Mongorestore

MONGOs

Mongosniff

Mongostat

The Mongod under the bin is the service-side process of MongoDB, MONGO is its client, and other commands are used for MongoDB for other purposes such as

MongoDB file export and so on.

4. Start MongoDB.

To set up a good MongoDB storage data files and log files directory, here is established under/data:

1.[[email protected] etc]# cd/data/

2.[[email protected] data]# ls

3.mongodb_data

Mongodb_log

Use Mongod to start MongoDB under the bin under the MongoDB installation directory,

>./mongod--dbpath=/data/mongodb_data/--logpath=/data/mongodb_log/mongodb.log--logappend&

After you wait for the startup to succeed, you can see if the boot was successful, the default port number is 27017, and you can also specify an unused port at startup.

Start by looking at the port number to see if MongoDB is started.

1.[[email protected] data]# NETSTAT-LANP | grep "27017"

You can see that it has started successfully and now uses

Mongo

The client accesses the database.

1.[[email protected] bin]# cd/usr/local/mongodb/bin/

2.[[email protected] bin]#./mongo

3.MongoDB Shell version:1.8.1

4.connecting To:test

5.>

This step indicates that the installation is successful.

5. Additional work.

Note that the above we started

Mongodb

are used manually

Mongod

To start, so shut down the computer, the next time it did not start, so it has to be manually started, so to avoid this tedious work, you can put

The Mongod is placed in the service self-starter, so that the computer starts up as soon as the Mongod service is turned on.

Edit

/etc/rc.local

, add the following code and save again.

1. #add mongondb Service

2.rm-rf/data/mongodb_data/* &&/usr/local/mongodb/bin/mongod--dbpath=/data/mongodb_data/--logpath=/data/ Mongodb_log/mongodb.log--logappend&

We restart the computer to see if MongoDB is started, restart can be directly using the MONGO command login, the final discovery can be successful.

In addition, we use the MONGO command to log in

MongoDB also goes to the directory where the MONGO command is located and executes./mongo, is this some kind of trouble? So

We can simplify this by making the command file

Copy to/usr/bin, so you can use the MONGO command in any directory.

1.[[email protected] bin]# ls

2.bsondump

Dbbak

Mongo

Mongod

Mongodump

Mongoexport

Mongofiles

Mongoimport

Mongorestore

MONGOs

Mongosniff

Mongostat

3.[[email protected] bin]# CP mongo/usr/bin/

Go to any directory try the MONGO command:

1.[[email protected] bin]# CD/

2.[[email protected]calhost/]# MONGO

3.MongoDB Shell version:1.8.1

4.connecting To:test

5.>

You can see that the login was successful, which means we can use the MONGO command just like the LS command.

    • This article is from: Linux Tutorial Network

Linux under MongoDB installation

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.