MongoDB Environment Deployment

Source: Internet
Author: User

Deployment steps:
1. Download the installation package Https://www.mongodb.org/dl/linux
I chose it.

  

2. TAR-XZVF linux/mongodb-linux-x86_64-latest.tgz

3. Renaming
MV Mongodb-linux-x86_64-4.1.0-266-gc7451c0e11 MongoDB

4. Create a folder (in the MongoDB directory)
mkdir data
mkdir Log
mkdir etc
Such as:

Create a mongodb.conf file under the ETC directory
Vim mongodb.conf
Put the following configuration in the same manner:

dbpath=/usr/local/fb4/mongodb/data/# (Data directory, which changes according to its actual path)
logpath=/usr/local/fb4/mongodb/log/mongodb.log# (log directory, which changes according to its actual path)
Logappend = True
port=27017
Fork=true

5. Start MongoDB
./mongod--config/usr/local/fb4/mongodb/etc/mongodb.conf

------------------------------------------Problem Set-----------------
Question one:

Path problem: So the Conf configuration file must be configured correctly first check the following configuration file:
dbpath=/usr/local/fb4/mongodb/data/# (at first the data is not added "/")
Logpath=/usr/local/fb4/mongodb/log/mongodb.log
Logappend = True
port=27017
Fork=true

Workaround:
1. Delete mongo.lock files
RM-RF Mongod.lock

2,/usr/local/fb4/mongodb/bin/mongod--repair--dbpath=/usr/local/fb4/mongodb/data

./mongod--config/usr/local/fb4/mongodb/etc/mongodb.conf

Question two:

[Email protected] bin]#./mongo
MongoDB Shell version V4.1.0-266-gc7451c0e11
Connecting to:mongodb://127.0.0.1:27017
2018-06-11t14:44:16.435+0800 E QUERY [js] error:couldn ' t connect to server 127.0.0.1:27017, connection attempt failed:so Cketexception:error Connecting to 127.0.0.1:27017:: Caused by:: Connection refused:
[Email protected]/mongo/shell/mongo.js:251:13
@ (Connect): 1:6
Exception:connect failed


MongoDB state: Client failed to start
Workaround:
1, if the database appears as above can not connect the reason, may be the data directory Mongod.lock file problem, can be repaired with the following command:
[Plain] View plain copy
1. [Email protected] mongodb]#/bin/mongod--repair

or delete Mongod.lock directly
[Plain] View plain copy
1. Rm-f/usr/local/mongodb/data/db/mongod.lock

Then start MongoDB again.

2, if the first step can not be solved, then is the path setting problem, by re-set the path to solve the problem
[Plain] View plain copy
1. [Email protected] mongodb]#/bin/mongod--dbpath=/usr/local/mongodb/data/db/

Success:

MongoDB Environment Deployment

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.