MongoDB Linux Universal Binary Package installation

Source: Internet
Author: User

Monfodb is an open source document database that provides common performance, high availability, auto-scaling, and more

A record in MongoDB is a document, which is a pair of fields and values that make up the structure. A MongoDB document resembles a JSON object, and the value of a field can contain an array of other documents, arrays, and documents. Records are organized into collection, which are equivalent to tables. Reference:



The advantages of using a document are:
documentation for native data objects in many programming languages
inline documents and arrays reduce the cost of joins
Dynamic schema supports smooth polymorphism

Key Features:
Performance:
MongoDB provides high performance data persistence. Especially:
Support for inline data model reduces I/O for database systems
Indexes support quick queries and inline documents and arrays can contain keys

High Availability:
MongoDB offers high availability is replica sets
Auto Fail switch
Data redundancy
Replica set is a set of MONGODB servers that maintain the same data set, provide redundancy, and increase data availability.

Automatic Horizontal scaling:
Horizontal scaling is the kernel feature of MongoDB.
Automatically share distributed data on a cluster
The replica sets provides final consistent reads for low-latency, high-throughput applications.


Installation:

0
Environment
[Email protected] ~]# uname-a
Linux host2 2.6.32-504.3.3.el6.x86_64 #1 SMP Wed Dec 01:55:02 UTC x86_64 x86_64 x86_64 gnu/linux
[Email protected] ~]# cat/etc/issue
CentOS Release 6.5 (Final)
Kernel \ r on an \m

1
Download:
Curl-o http://downloads.mongodb.org/linux/mongodb-linux-x86_64-2.6.7.tgz

2
[Email protected] mongodb]# TAR-ZXVF mongodb-linux-x86_64-2.6.7.tgz
Mongodb-linux-x86_64-2.6.7/readme
Mongodb-linux-x86_64-2.6.7/third-party-notices
mongodb-linux-x86_64-2.6.7/gnu-agpl-3.0
Mongodb-linux-x86_64-2.6.7/bin/mongodump
Mongodb-linux-x86_64-2.6.7/bin/mongorestore
Mongodb-linux-x86_64-2.6.7/bin/mongoexport
Mongodb-linux-x86_64-2.6.7/bin/mongoimport
Mongodb-linux-x86_64-2.6.7/bin/mongostat
Mongodb-linux-x86_64-2.6.7/bin/mongotop
Mongodb-linux-x86_64-2.6.7/bin/mongooplog
Mongodb-linux-x86_64-2.6.7/bin/mongofiles
Mongodb-linux-x86_64-2.6.7/bin/bsondump
Mongodb-linux-x86_64-2.6.7/bin/mongoperf
Mongodb-linux-x86_64-2.6.7/bin/mongod
Mongodb-linux-x86_64-2.6.7/bin/mongos
Mongodb-linux-x86_64-2.6.7/bin/mongo
[Email protected] mongodb]#

3
The planned folder for the copy
[Email protected] mongodb]# MV Mongodb-linux-x86_64-2.6.7/opt/mongodb

4
Configuring Environment variables
[Email protected] ~]# Vi. bash_profile
Path= $PATH:/opt/mongodb/bin

5
The folder where the data resides
[Email protected] mongodb]# mkdir dbdata

6
Enables user Mongod to read and write data in the same folder
[Email protected] mongodb]# useradd-r Mongod
[Email protected] mongodb]# chown Mongod:mongod dbdata/

7
Start
[Email protected] mongodb]# Mongod--dbpath dbdata
2015-02-13t17:56:23.704+0800 [Initandlisten] MongoDB starting:pid=2035 port=27017 dbpath=dbdata 64-bit host=mgdbsvr
2015-02-13t17:56:23.708+0800 [Initandlisten] DB version v2.6.7
2015-02-13t17:56:23.708+0800 [Initandlisten] git version:a7d57ad27c382de82e9cb93bf983a80fd9ac9899
2015-02-13t17:56:23.708+0800 [Initandlisten] Build info:linux build7.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC x86_64 boost_lib_version=1_49
2015-02-13t17:56:23.708+0800 [Initandlisten] Allocator:tcmalloc
2015-02-13t17:56:23.708+0800 [Initandlisten] options: {storage: {dbPath: ' Dbdata '}}
2015-02-13t17:56:23.738+0800 [Initandlisten] Journal Dir=dbdata/journal
2015-02-13t17:56:23.741+0800 [Initandlisten] recover:no journal files present, no recovery needed
2015-02-13t17:56:24.520+0800 [Initandlisten] preallocateisfaster=true 13.46
2015-02-13t17:56:25.273+0800 [Initandlisten] Preallocateisfaster=true 12.5
2015-02-13t17:56:27.166+0800 [Initandlisten] preallocateisfaster=true 8.76
2015-02-13t17:56:27.166+0800 [Initandlisten] preallocateisfaster check took 3.423 secs
2015-02-13t17:56:27.167+0800 [Initandlisten] preallocating a journal file dbdata/journal/prealloc.0
2015-02-13t17:56:30.089+0800 [Initandlisten] File preallocator progress:891289600/1073741824 83%
2015-02-13t17:56:31.216+0800 [Initandlisten] preallocating a journal file dbdata/journal/prealloc.1
2015-02-13t17:56:34.070+0800 [Initandlisten] File preallocator progress:629145600/1073741824 58%
2015-02-13t17:56:35.779+0800 [Initandlisten] preallocating a journal file dbdata/journal/prealloc.2
2015-02-13t17:56:38.054+0800 [Initandlisten] File preallocator progress:859832320/1073741824 80%
2015-02-13t17:56:39.630+0800 [Initandlisten] allocating new ns file Dbdata/local.ns, filling with zeroes ...
2015-02-13t17:56:39.762+0800 [Fileallocator] Allocating new datafile dbdata/local.0, filling with zeroes ...
2015-02-13t17:56:39.763+0800 [fileallocator] Creating directory Dbdata/_tmp
2015-02-13t17:56:39.797+0800 [Fileallocator] Done allocating datafile dbdata/local.0, SIZE:64MB, took 0.002 secs
2015-02-13t17:56:39.832+0800 [Initandlisten] Build Index On:local.startup_log properties: {v:1, key: {_id:1}, Name: "_id_", ns: "Local.startup_log"}
2015-02-13t17:56:39.855+0800 [Initandlisten] added index to empty collection
2015-02-13t17:56:39.894+0800 [initandlisten] command Local. $cmd command:create {create: "Startup_log", size:10485760, Capped:true} ntoreturn:1 keyupdates:0 numyields:0 reslen:37 281ms
2015-02-13t17:56:39.897+0800 [Initandlisten] waiting for connections on port 27017

8
Connection, simple to use
[Email protected] ~]# MONGO
MongoDB Shell version:2.6.7
Connecting To:test
#查看当前数据库
> DB
Test
#切到数据库 MyDB
> Use MyDB
Switched to DB MyDB
> DB
MyDB
#用javascript创建两个文档
> j = {name: "MONGO"}
{"Name": "MONGO"}
> k = {x:3}
{"X": 3}
#创建mydb数据库和testdata Collection
> Db.testdata.insert (j)
Writeresult ({"ninserted": 1})
> Db.testdata.insert (k);
Writeresult ({"ninserted": 1})
> Show Collections
System.indexes
TestData
> Db.testdata.find ()
{"_id": ObjectId ("54ddd717d692cfe0bd20d983"), "name": "MONGO"}
{"_id": ObjectId ("54ddd728d692cfe0bd20d984"), "X": 3}
>
>
> Show DBS
Admin (empty)
Local 0.078GB
MyDB 0.078GB
>
> Use HAHADB
Switched to DB hahadb
> Show DBS
Admin (empty)
Local 0.078GB
MyDB 0.078GB
> DB
Hahadb
> j = {name: "MONGO"}
{"Name": "MONGO"}
> Show DBS
Admin (empty)
Local 0.078GB
MyDB 0.078GB
> Db.testdata.insert (j)
Writeresult ({"ninserted": 1})
> Show DBS
Admin (empty)
HAHADB 0.078GB
Local 0.078GB
MyDB 0.078GB
>
> Use MyDB
Switched to DB MyDB
> Show Collections
System.indexes
TestData
>
> Db.testdata.insert (j)
Writeresult ({"ninserted": 1})
> Db.testdata.find ()
{"_id": ObjectId ("54ddd717d692cfe0bd20d983"), "name": "MONGO"}
{"_id": ObjectId ("54ddd728d692cfe0bd20d984"), "X": 3}
{"_id": ObjectId ("54ddda64d692cfe0bd20d986"), "name": "MONGO"}
> Db.testdata.insert (k)
Writeresult ({"ninserted": 1})
>
>
> Db.testdata.find ()
{"_id": ObjectId ("54ddd717d692cfe0bd20d983"), "name": "MONGO"}
{"_id": ObjectId ("54ddd728d692cfe0bd20d984"), "X": 3}
{"_id": ObjectId ("54ddda64d692cfe0bd20d986"), "name": "MONGO"}
{"_id": ObjectId ("54ddda7dd692cfe0bd20d987"), "X": 3}
>
> Db.testdata.find ({x:3})
{"_id": ObjectId ("54ddd728d692cfe0bd20d984"), "X": 3}
{"_id": ObjectId ("54ddda7dd692cfe0bd20d987"), "X": 3}
>
>
> exit;
[Email protected] ~]#





Reference:

docs.mongodb.org/manual/tutorial/install-mongodb-on-linux/


-----------------

Reprint Please specify the source:
Blog.csdn.net/beiigang

MongoDB Linux Universal Binary Package 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.