发布于 2015-09-14 14:56:17 | 175 次阅读 | 评论: 0 | 来源: 网络整理

Synopsis

This tutorial outlines the basic installation process for installing MongoDB on Debian systems. This tutorial uses .deb packages as the basis of the installation. 10gen publishes packages of the MongoDB releases as .deb packages for easy installation and management for users of Debian systems. While some of these distributions include their own MongoDB packages, the 10gen packages are generally more up to date.

This tutorial includes: an overview of the available packages, instructions for configuring the package manager, the process for installing packages from the 10gen repository, and preliminary MongoDB configuration and operation.

注解

If you’re running a version of Ubuntu Linux prior to 9.10 “Karmic,” use this tutorial. Other Ubuntu users will want to follow the 在Ubuntu上安装 tutorial.

也可以参考

The documentation of following related processes and concepts.

Other installation tutorials:

Package Options

The 10gen repository contains three packages:

  • mongodb-10gen

    This package contains the latest stable release. Use this for production deployments.

  • mongodb20-10gen

    This package contains the stable release of v2.0 branch.

  • mongodb18-10gen

    This package contains the stable release of v1.8 branch.

You cannot install these packages concurrently with each other or with the mongodb package that your release of Debian may include.

10gen also provides packages for “unstable” or development versions of MongoDB. Use the mongodb-10gen-unstable package to test the latest development release of MongoDB, but do not use this version in production.

Installing MongoDB

Configure Package Management System (APT)

The Debian package management tool (i.e. dpkg and apt) ensure package consistency and authenticity by requiring that distributors sign packages with GPG keys. Issue the following command to import the 10gen public GPG Key:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10

Create a the /etc/apt/sources.list.d/10gen.list file and include the following line for the 10gen repository.

deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen

Now issue the following command to reload your repository:

sudo apt-get update

Install Packages

Issue the following command to install the latest stable version of MongoDB:

sudo apt-get install mongodb-10gen

When this command completes, you have successfully installed MongoDB! Continue for configuration and start-up suggestions.

Configure MongoDB

These packages configure MongoDB using the /etc/mongodb.conf file in conjunction with the control script. You can find the control script at /etc/init.d/mongodb.

This MongoDB instance will store its data files in the /var/lib/mongodb and its log files in /var/log/mongodb, and run using the mongodb user account.

注解

If you change the user that runs the MongoDB process, you will need to modify the access control rights to the /var/lib/mongodb and /var/log/mongodb directories.

Controlling MongoDB

Starting MongoDB

Issue the following command to start mongod:

sudo /etc/init.d/mongodb start

You can verify that mongod has started successfully by checking the contents of the log file at /var/log/mongodb/mongodb.log.

Stopping MongoDB

Issue the following command to stop mongod:

sudo /etc/init.d/mongodb stop

Restarting MongoDB

Issue the following command to restart mongod:

sudo /etc/init.d/mongodb restart

Controlling mongos

As of the current release, there are no control scripts for mongos. mongos is only used in sharding deployments and typically do not run on the same systems where mongod runs. You can use the mongodb script referenced above to derive your own mongos control script.

Using MongoDB

Among the tools included with the MongoDB package, is the mongo shell. You can connect to your MongoDB instance by issuing the following command at the system prompt:

mongo

This will connect to the database running on the localhost interface by default. At the mongo prompt, issue the following two commands to insert a record in the “test” collection of the (default) “test” database.

> db.test.save( { a: 1 } )
> db.test.find()

也可以参考

mongo” and “mongo Shell JavaScript 快参

最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务