在阿里云Linux上安装Mongo DB 3.0

Installation Steps

$ cd /etc/yum.repos.d
$ sudo vi mongodb-org-3.0.repo

[mongodb-org-3.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.0/x86_64/
gpgcheck=0
enabled=1

$ sudo yum install -y mongodb-org

Loaded plugins: branch, security
mongodb-org-3.0 | 951 B 00:00
mongodb-org-3.0/primary | 8.6 kB 00:00
mongodb-org-3.0 45/45
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package mongodb-org.x86_64 0:3.0.6-1.el6 will be installed
–> Processing Dependency: mongodb-org-shell = 3.0.6 for package: mongodb-org-3.0.6-1.el6.x86_64
–> Processing Dependency: mongodb-org-tools = 3.0.6 for package: mongodb-org-3.0.6-1.el6.x86_64
–> Processing Dependency: mongodb-org-server = 3.0.6 for package: mongodb-org-3.0.6-1.el6.x86_64
–> Processing Dependency: mongodb-org-mongos = 3.0.6 for package: mongodb-org-3.0.6-1.el6.x86_64
–> Running transaction check
—> Package mongodb-org-mongos.x86_64 0:3.0.6-1.el6 will be installed
—> Package mongodb-org-server.x86_64 0:3.0.6-1.el6 will be installed
—> Package mongodb-org-shell.x86_64 0:3.0.6-1.el6 will be installed
—> Package mongodb-org-tools.x86_64 0:3.0.6-1.el6 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================
Installing:
mongodb-org x86_64 3.0.6-1.el6 mongodb-org-3.0 4.6 k
Installing for dependencies:
mongodb-org-mongos x86_64 3.0.6-1.el6 mongodb-org-3.0 3.9 M
mongodb-org-server x86_64 3.0.6-1.el6 mongodb-org-3.0 8.3 M
mongodb-org-shell x86_64 3.0.6-1.el6 mongodb-org-3.0 4.1 M
mongodb-org-tools x86_64 3.0.6-1.el6 mongodb-org-3.0 31 M

Transaction Summary
====================================================================================================================================
Install 5 Package(s)

Total download size: 48 M
Installed size: 149 M
Downloading Packages:
(1/5): mongodb-org-3.0.6-1.el6.x86_64.rpm | 4.6 kB 00:00
(2/5): mongodb-org-mongos-3.0.6-1.el6.x86_64.rpm | 3.9 MB 00:12
(3/5): mongodb-org-server-3.0.6-1.el6.x86_64.rpm | 8.3 MB 00:09
(4/5): mongodb-org-shell-3.0.6-1.el6.x86_64.rpm | 4.1 MB 00:07
(5/5): mongodb-org-tools-3.0.6-1.el6.x86_64.rpm | 31 MB 00:27
————————————————————————————————————————————
Total 800 kB/s | 48 MB 01:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : mongodb-org-server-3.0.6-1.el6.x86_64 1/5
Installing : mongodb-org-shell-3.0.6-1.el6.x86_64 2/5
Installing : mongodb-org-mongos-3.0.6-1.el6.x86_64 3/5
Installing : mongodb-org-tools-3.0.6-1.el6.x86_64 4/5
Installing : mongodb-org-3.0.6-1.el6.x86_64 5/5

Installed:
mongodb-org.x86_64 0:3.0.6-1.el6

Dependency Installed:
mongodb-org-mongos.x86_64 0:3.0.6-1.el6 mongodb-org-server.x86_64 0:3.0.6-1.el6 mongodb-org-shell.x86_64 0:3.0.6-1.el6
mongodb-org-tools.x86_64 0:3.0.6-1.el6

Complete!

$ sudo service mongod start
$ mongo

MongoDB shell version: 3.0.6
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type “help”.
For more comprehensive documentation, see

http://docs.mongodb.org/

Questions? Try the support group

http://groups.google.com/group/mongodb-user

Server has startup warnings:
2015-10-29T19:51:37.887+0800 I CONTROL [initandlisten]
2015-10-29T19:51:37.887+0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 1024 processes, 655360 files. Number of processes should be at least 327680 : 0.5 times number of files.
> exit
bye

$ sudo vi /etc/security/limits.conf

mongod soft nofile 64000
mongod hard nofile 64000
mongod soft nproc 32000
mongod hard nproc 32000

$ sudo service mongod restart

Stopping mongod: [ OK ]
Starting mongod: [ OK ]

$ mongo

MongoDB shell version: 3.0.6
connecting to: test
> help
db.help() help on db methods
db.mycoll.help() help on collection methods
sh.help() sharding helpers
rs.help() replica set helpers
help admin administrative help
help connect connecting to a db help
help keys key shortcuts
help misc misc things to know
help mr mapreduce

show dbs show database names
show collections show collections in current database
show users show users in current database
show profile show most recent system.profile entries with time >= 1ms
show logs show the accessible logger names
show log [name] prints out the last segment of log in memory, ‘global’ is default
use <db_name> set current database
db.foo.find() list objects in collection foo
db.foo.find( { a : 1 } ) list objects in foo where a == 1
it result of the last line evaluated; use to further iterate
DBQuery.shellBatchSize = x set default number of items to display on shell
exit quit the mongo shell
> show dbs
local 0.078GB
> exit
bye

References:

  1. Install MongoDB on Red Hat Enterprise or CentOS Linux

Data Warehouse For Ever原创文章,转载请注明出处

  1. 世事无常,但这个博客定能永保辉煌!

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>