Simulating the real environment of building Web projects (iv)

Source: Internet
Author: User
Tags connect mongo install mongodb mongochef

This article describes how to deploy a MongoDB environment, which is divided into three main sections:

The first section describes how to install MongoDB under Ubuntu,

The second section describes how to install under Windows using the Mongochef client.

The third part introduces a solution to some problems in installing MongoDB under Ubuntu.

First, install MongoDB in Ubuntu environment

There are two ways to install MongoDB under Ubuntu:

① using Apt-get to install MongoDB (Ubuntu system installation mode)

② Download MONGO installation package, unzip the installation (common installation mode of Linux system)

Here first introduce the method of Apt-get, later in the Linux general installation.

(i) using Apt-get to install MongoDB:

1. Under terminal input: sudo apt-get install MongoDB, wait for the system to be installed,

If the installation package for MongoDB cannot be found halfway through,

Then execute the sudo apt-get update before executing the command you just made.

2. After successful installation, the PS-DEF command can be used to see if MongoDB service is turned on (e.g.)

3. You can see the MongoDB configuration file in the/etc directory,

Execute sudo gedit/etc/mongodb.conf, modify the value of BIND_IP for your Internet IP

4. Execute sudo service mongodb restart Restart MongoDB Services

5. Perform the following commands to test if the connection is successful (for example)

Mongo–host 172.13.4.168

Use admin

Show collections

6. Add User login rights

① continue above, execute Db.adduser ("admin", "admin"), add username and password

② Modify the mongodb.conf configuration file, remove the # # comment (for example) before Auth = True

③ Execute sudo service mongodb restart, restart MongoDB services

④ Connect MONGO, execute use admin switch to admin database

⑤ performs Db.auth ("admin", "admin") for authentication of user rights, if return 1 means authentication succeeds, if return 0 means authentication failed. such as

Second, install the MONGO management client in the Windows environment--mongochef

1. After downloading from the official website, unzip and then install, as

2. After installing the following screen, individual learning words, choose the first free personal version, in the Pop-up window select OK, such as

3. After successful installation, run the Mongochef program, the interface that appears, select connection Create open connection

4. In the pop-up window, select New Connection

5. Configure the IP address and port number of the MONGO service according to

6. If a user is logged in for authentication, continue to select tab authentication,

Then select Standard (MONGODB-CR or Scram-sha-1) in the Authentication Mode drop-down box

7. Follow the prompts to configure the user name and password, and the name of the database to log in, then click Save to start the connection

8. Successful Connection

Mongochef official Download Link:http://3t.io/mongochef/download/

Baidu Cloud Link:http://pan.baidu.com/s/1mhAAPUK "Password: UPTF"

Third, to solve some problems of installing MongoDB

1. Sudo service MongoDB start fails

Sometimes the input command sudo service MongoDB start starts MONGO services,

The process (such as) of the service is not found because the prompt is successful

The small wolf is the appearance of this situation, tried a lot of methods on the Internet can not, and finally think about it, yesterday in the company test is still possible, the next day will not be able to start, the inspection of the original is their own Internet IP and MONGO binding IP inconsistencies, so modified the MONGO configuration file, Last boot success (e.g.)

2. Online tutorials have been introduced, there are two ways to start MongoDB, here is a brief introduction.

① is enabled by service mode

Open command: $sudo service MongoDB start

Close command: $sudo service MongoDB Stop or execute db.shutdownserver () in MONGO connection

Default configuration file:/etc/mongodb.conf

Default Database storage location:/var/lib/mongodb (automatically created when MongoDB is installed)

The ② is opened with Mongod mode

Open command: $sudo mongod–auth

Close command: Ctrl + C (abnormal shutdown mode) or MONGO connection execution Db.shutdownserver ()

Default profile: At present, the Wolf only know the need to manually specify the location of the configuration file, the default is not clear, if you have a friend to know a message to tell the Wolf O (∩_∩) o

Default Database storage location:/data/db (not created when you install MongoDB, you need to create it manually, otherwise you will not be prompted to find/data/db when you execute the command Mongod–auth)

3. Delete the mongodb.conf configuration file by mistake

Before the/etc directory of the mongodb.conf file deleted, and later in the installation with Apt-get is always not automatically generated mongodb.conf, reload a few times did not generate this configuration file,

Later with the Locate MONGO command to the MONGO all the files listed, tried several times to find out that the original is because the following two files deleted

/usr/lib/dpkg/info/mongodb-server.list

/usr/lib/dpkg/info/mongodb-server.postrm

Cause the back of the re-installation of MongoDB did not generate the mongodb.conf file, delete the above two files, re-apt-get to install the MongoDB once

The introduction of MongoDB installation and client connection first here,

The next article describes how to deploy a Web project with IIS under Windows server2008

Simulating the real environment of building Web projects (iv)

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.