Install mongodb in linux universal Binary Package, mongodblinux

Source: Internet
Author: User
Tags install mongodb

Install mongodb in linux universal Binary Package, mongodblinux
MonfoDB is an open-source document database that provides common performance, high availability, and automatic scaling.

The record in MongoDB is a document, which is a structure consisting of fields and values. Mongodb documents are similar to JSON objects. Field Values can contain arrays of other documents, arrays, and documents. Records are organized into collections, which is equivalent to tables. Refer:



The advantages of using documents are:
Documents correspond to endogenous Data Objects in many programming languages
Embedded documents and arrays reduce join overhead
Dynamic schema supports smooth Polymorphism

Key features:
High performance:
Mongodb provides high-performance data persistence. In particular:
Supports embedded data models to reduce the I/O of the Database System
Indexes support quick queries and embedded documents and arrays can contain keys.

High Availability:
Mongodb provides highly available replica sets.
Automatic failover failure
Data redundancy
Replica set is a group of mongodb servers that maintain the same dataset, provide redundancy, and increase data availability.

Automatic horizontal scaling:
Horizontal scaling is the kernel function of mongodb.
Automatically share distributed data on the Cluster
Replica sets can provide eventual consistent reads for applications with low latency and high throughput.


Installation:

0
Environment
[Root @ host2 ~] # Uname-
Linux host2 2.6.32-504.3.3.el6.x86 _ 64 #1 SMP Wed Dec 17 01:55:02 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
[Root @ host2 ~] # 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
[Root @ mgdbsvr 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/export Export
Mongodb-linux-x86_64-2.6.7/bin/Export Import
Mongodb-linux-x86_64-2.6.7/bin/Scanner stat
Mongodb-linux-x86_64-2.6.7/bin/items top
Mongodb-linux-x86_64-2.6.7/bin/mongooplog
Mongodb-linux-x86_64-2.6.7/bin/Program Files
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
[Root @ mgdbsvr mongodb] #

3
Copy the planned folder
[Root @ mgdbsvr mongodb] # Music mongodb-linux-x86_64-2.6.7/opt/mongodb

4
Configure Environment Variables
[Root @ mgdbsvr ~] # Vi. bash_profile
PATH = $ PATH:/opt/mongodb/bin

5
Folder where data is located
[Root @ mgdbsvr mongodb] # mkdir dbdata

6
Enable mongod to read and write data in the folder
[Root @ mgdbsvr mongodb] # useradd-r mongod
[Root @ mgdbsvr mongodb] # chown mongod: mongod dbdata/

7
Start
[Root @ mgdbsvr 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 2014 x86_64 BOOST_LIB_VERSION = Limit 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: 64 MB, 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 281 ms
2015-02-13T17: 56: 39.897 + 0800 [initandlisten] waiting for connections on port 27017

8
Connection, easy to use
[Root @ mgdbsvr ~] # Mongo
MongoDB shell version: 2.6.7
Connecting to: test
# View the current database
> Db
Test
# Switch to database mydb
> Use mydb
Switched to db mydb
> Db
Mydb
# Create two documents using javascript
> J = {name: "mongo "}
{"Name": "mongo "}
> K = {x: 3}
{"X": 3}
# Create a mydb database and 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.078 GB
Mydb 0.078 GB
>
> Use hahadb
Switched to db hahadb
> Show dbs
Admin (empty)
Local 0.078 GB
Mydb 0.078 GB
> Db
Hahadb
> J = {name: "mongo "}
{"Name": "mongo "}
> Show dbs
Admin (empty)
Local 0.078 GB
Mydb 0.078 GB
> Db. testdata. insert (j)
WriteResult ({"nInserted": 1 })
> Show dbs
Admin (empty)
Hahadb 0.078 GB
Local 0.078 GB
Mydb 0.078 GB
>
> 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;
[Root @ mgdbsvr ~] #





Refer:

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


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

Please refer to the following source for reprinting:
Blog.csdn.net/beiigang

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.