MongoDB Installation and Startup

Source: Internet
Author: User
Tags failover

OneMongoDBSimple Introduction

MongoDB is a high performance, open source. Non-modal document database . is one of the more popular in the current NoSql database. It can be used in many scenarios to replace the traditional relational database or key/value storage methods.

MONGO is developed using C + +. MONGO's official site address is: http://www.mongodb.org/. Readers can get more specific information here.

Episode: What is NoSQL?

nosql, full name is not Only  sql , which refers to a non-relational database. The next generation of databases mainly solves several key points: non-relational, distributed, open-source, horizontally extensible. The original purpose is for large-scale web application, The campaign began in early 2009 and typically features applications such as freedom of mode, easy replication, simple APIs, finally consistent (non-acid), high-capacity data, and more.

NoSQL is stored as the number Key-value we use most. And of course there are document-type, Columnstore, graph-database, XML database, and so on.

Characteristics:

  • High performance, easy to deploy, easy to use, easy to store data. The main features are:
  • For collection storage. Data that stores object types easily.
  • Mode of freedom.
  • Supports dynamic queries.
  • Supports full indexing, including internal objects.
  • Support Queries.

  • Supports replication and recovery.
  • Use efficient binary data storage, including large objects such as video.
  • Proactively handle fragmentation to support scalability at the cloud level
  • Support for Python. PHP,Ruby. Drivers for Java,c,c#,javascript,perl and C + + languages, as well as drivers for platforms such as Erlang and. NET, are also available in the community.

  • The file storage format is Bson (an extension of JSON).
  • Internet access is available.

Function:

  • Collection-oriented storage: suitable for storing objects and data in JSON form.

  • Dynamic Query: The MONGO supports rich query expressions.

    Query directives use a JSON-style token. You can easily query the objects and arrays embedded in the document.

  • Full index support: includes embedded objects and arrays in the document.

    The query optimizer of MONGO parses the query expression and generates an efficient query plan.

  • Query monitoring: MONGO includes a monitoring tool for analyzing the performance of database operations.
  • replication and proactive failover: The MONGO database supports data replication between servers and supports replication between master-slave mode and server. The primary goal of replication is to provide redundancy and self-active failover.
  • Efficient Traditional storage: supports binary data and large objects (such as photos or pictures)
  • self-active sharding to support cloud-level scalability: self-active sharding supports a level of DB cluster, adding additional machines dynamically.

Applicable occasions:

    • Site data: MONGO is ideal for real-time insertion. Updates and queries, with replication and high scalability required for site real-time data storage.

    • Cache: Because of high performance. The MONGO is also suitable as a caching layer for the information infrastructure. After the system restarts, the persistent cache layer built by MONGO can avoid overloading the underlying data sources.

    • Large size. Low-Value data: It may be more expensive to store some data in a traditional relational database than before. Many times a program ape often chooses traditional files for storage.
    • Highly scalable scenario: The MONGO is ideal for databases consisting of dozens of or hundreds of servers.

      Built-in support for the MapReduce engine is already included in the roadmap for MONGO.

    • Storage for objects and JSON data: MONGO's Bson data format is ideal for storing and querying in a document format.

Second, download the installation and configuration

Install the MONGO database under Windows:

The latest version number officially provided at the time of publication is: 1.6.5. Assuming that you do not make a special declaration, the version number used in this tutorial will be the version number.

    1. First step: Download the installation package: Suppose it is a win system. Note If it is a 64-bit or 32-bit version number, select the correct version number.
    2. Step Two: Create a new Folder "D:\MongoDB" to extract the downloaded installation package. Locate all the following. exe files in the Bin folder. Copy to the folder you just created.
    3. The third step: Create a new "data" folder under the "D:\MongoDB" folder, which will be the root folder for data storage.

Note: official:http://www.mongodb.org/downloads

Configure the MONGO service side:

Open the cmd form and enter the command as follows:
> D:
> CD D:\MongoDB
> Mongod--dbpath D:\MongoDB\data

After the configuration is successful, you will see such as the following screen:

In the browser input: http://localhost:27017/, you can see for example the following prompt:
You is trying to access MongoDB on the native driver port. For HTTP diagnostic access, add the port number

So. The MongoDB database service has successfully started.

Installing and configuring MongoDB under LinuxStep One: Download the file
For 32-bit Linux
$ Curl http://downloads.mongodb.org/linux/mongodb-linux-i686-1.4.4.tgz > Mongo.tgz
$ tar xzf mongo.tgz
For 64-bit Linux
$ Curl http://downloads.mongodb.org/linux/mongodb-linux-x86_64-1.4.4.tgz > Mongo.tgz
$ tar xzf mongo.tgz
Assuming no curl is installed
Installing Apt-get Install Curl First
Step Two: Create a Data Catalog
By default, MongoDB stores data in the/data/db/directory, which needs to be created manually.


Created by the following way, for example:
$ adduser MongoDB
$ passwd MongoDB
$ sudo mkdir-p/data/db/
$ sudo chown ' id-u '/data/db
$ chown-r Mongodb:mongodb/data
Of course, you can specify MongoDB with the--dbpath command to store the data in a different folder.
Step Three: Let the database execute.
In the console:
$ nohup./mongodb-xxxxxxx/bin/mongod &
$./mongodb-xxxxxxx/bin/mongo
> Db.foo.save ({a:1})
> Db.foo.find ()
The result is:
{"_id": ObjectId ("4cd181a31415ffb41a094f43"), "a": 1}
The above three steps will be OK!

Such a simple MongoDB database can be implemented unimpeded.

MongoDB Installation and Startup

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.