Ubuntu under MongoDB Installation

Source: Internet
Author: User
Tags install mongodb

1. Download:

Mongodb.org/download

2. Compress the downloaded compressed file to/usr/lib

3. Create a soft link

Ln-s/usr/lib/mongodb-linux-i686-2.6.7/bin/mongod/usr/bin/mongodln-s/usr/lib/mongodb-linux-i686-2.6.7/bin/mongo /usr/bin/mongo

This allows the Mongod and MONGO instructions to be lowered at the command line.


Of course, it can be installed by Apt-get install Mongodb-server, but the version may be a bit older.

---The following optional----

4. Start the default service

Mongod--dbpath/usr/lib/mongodb-linux-8686-2.6.7/db

But this is not running in the background, it needs to be run in the background.

What should we do about it?

Solution: Create a script Mongod under/ETC/INIT.D and delete the/usr/bin/mongod. As follows:

#!/bin/shservice mongodb-server Start

  

Set as startup item at the same time:

UPDATE-RC.D Mongod Defaults

Create a new script file/etc/init.d/mongodb-server and set permissions as follows:

#!/bin/shdaemon=/usr/bin/mongodb-linux-i686-2.6.7/bin/mongoddaemon_opts= "--dbpath/usr/lib/ mongodb-linux-i686-2.6.7/db "name=mongodb-serverdesc=mongodb-serverpidfile=/var/run/$NAME. PidUSER = tommycase" ${1 } "in case     start"         echo "Starting ${desc}:"            start-stop-daemon--start--quiet--pidfile ${pidfile}                                          -- Chuid $ (USER}--background--make-pidfile                                          --exec ${deamon}--${deamon_opts}         echo "[OK]"     ;;     Case stop)           echo "Stopping ${desc}:"           start-stop-daemon--stop--quiet--pidfile ${pidfile}                                          --oknodo           echo "[OK]"     ;; Esacexit 0

 

Need to create Pidfile, and set permissions, process slightly.

The above configuration, each boot, automatically start MongoDB default service, database for/usr/lib/mongodb-...../db

You can simply type MONGO at the command line to connect to the default db.

----Split--------------

The following development-related:

(such as the case of Mongoengine)

From Mongoengin import *connect (' local ') class Test (Document):     name = Stringfield (max_length=100) # ...    

  

Ubuntu 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.