MongoDB installation, configuration, and extranet access on CentOS

Source: Internet
Author: User
Tags install mongodb mongodb

Because I think there is no need to waste time in such a broken link, so the specific steps and the problems encountered in the list.

Lest MongoDB novice +linux novice Encounter such a problem when wasting too much meaningless time.

Objective

For a note, if there is any problem, please feedback.

In order to be able to have a simple troubleshooting ideas, I briefly describe the following commonly used in several files:

1,/etc/mongod.conf

Mongod configuration file functions such as: Configure the Rights Management mode, configure the location of the DB, configure the location of the log, and so on.

2,/usr/lib/systemd/system/mongod.service

Mongod Start the service configuration file, such as: Configure the startup parameters, run the user and group, etc. Can be used to create a start-up service.

3,/var/log/mongodb/mongod.log

Mongod log files, general errors will be here to find the cause and workaround.

1, installing MongoDB

1.1, go to official website: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/

1.2, no confidence in English, or reading should be ultra-slow, see the following operation

1.2.1, execute the Linux command: Vim/etc/yum.repos.d/mongodb-org-3.6.repo. The goal is to create a file and edit

1.2.2, execute the linux command: Yum install-y mongodb-org. The purpose is to download and install MongoDB

1.2.3, execute the linux command: Mongod-f/etc/mongod.conf. Purpose, run the Mongod service directly to verify that MongoDB is installed successfully

1.2.4, execute the Linux command: vim/etc/mongod.conf. The purpose is to edit the configuration file of the Mongod service so that the extranet can be accessed (vim will not, direct Baidu)

1.2.4.1, modify Bindid to 0.0.0.0 (note that there must be a space after the colon, otherwise it will parse the error)

1.2.4.2, modify authorization to Enabled (note the words do not misspell)

1.2.4.3, execute command ps-eaf | grep Mongod, find the Mongod service being executed and kill with kill.

1.2.4.4, perform mongod-f/etc/mongod.conf, restart Mongod service.

1.2.5, execute the Linux command: MONGO localhost:27017, the purpose is to log into the MongoDB shell.

1.2.6, execute use databaseName, and then make a random record to create a database that you want to work with.

1.2.7, execute the linux command: Db.createuser ({User: "UserName", pwd: "Password", Roles:[{role: "DbAdmin", DB: "DatabaseName"}]}). The goal is to create a user

1.2.8, execute the Linux command: Exit to exit the current window and log in with the newly created account.

1.2.9, execute the Linux command: MONGO localhost:27017/databasename-u username-p password. Note Replace the Databasename,username,password with the actual data. The goal is to log into the MongoDB window.

1.2.10, if the login is successful, you can try remote login, should be no problem. (If you have to have a public network ip/domain name)

(Above, once the error occurs, the first time to view the error, view the log, multiple authentication.) Don't be intimidated by the problem. There should be no logic in the matter itself, no place to be figured out, and no need to tangle. )

View Log script: Cat/var/log/mongodb/mongod.log

Encounter the Pit

1,address already in use Linux

Cause: Port occupancy

WORKAROUND: PS command, view the appropriation program, kill off

2,loaderexceptions

Cause: Configuration file with a space after the colon

Workaround: In the configuration file, modify, restart the service is good

3, unable to lock the lock file:/var/lib/mongo/mongod.lock

Cause: The file is locked and cannot be copied

Workaround: Just delete it.

MongoDB installation, configuration, and extranet access on CentOS

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.