CentOS6.5中安装MongoDB

1、下载MongoDB

下载Mongodb linux32二进制发行版本

http://downloads.mongodb.org/linux/mongodb-linux-i686-2.6.0.tgz

下载Mongodb linux64二进制发行版本

https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.0.0.tgz

2、安装MongoDB

(1)解压MongoDB

[root@bogon softwares]# tar -zxvf mongodb-linux-i686-2.6.0.tgz

(2)修改环境变量PATH

[root@bogon mongodb-linux-i686-2.6.0]# vi /etc/profile
PATH=/softwares/mongodb-linux-i686-2.6.0/bin
[root@bogon mongodb-linux-i686-2.6.0]# source /etc/profile 

(3)验证环境变量是否生效

[root@bogon mongodb-linux-i686-2.6.0]# mongod -version
db version v2.6.0
2015-03-09T21:24:05.552+0800 git version: 1c1c76aeca21c5983dc178920f5052c298db616c

(4)创建目录/data/db并且给予读写权限

[root@bogon bin]# cd /
[root@bogon /]# mkdir data
[root@bogon /]# chmod 777 data
[root@bogon /]# cd data
[root@bogon data]# mkdir db
[root@bogon data]# chmod 777 db

3、启动mongodb

[root@bogon bin]# pwd
/softwares/mongodb-linux-i686-2.6.0/bin
[root@bogon bin]# ls
bsondump  mongo  mongod  mongodump  mongoexport  mongofiles  mongoimport  mongooplog  mongoperf  mongorestore  mongos  mongostat  mongotop
[root@bogon bin]# mongod
mongod --help for help and startup options
2015-03-09T21:33:19.765+0800 
2015-03-09T21:33:19.765+0800 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
2015-03-09T21:33:19.765+0800 
2015-03-09T21:33:19.784+0800 [initandlisten] MongoDB starting : pid=2487 port=27017 dbpath=/data/db 32-bit host=bogon
2015-03-09T21:33:19.784+0800 [initandlisten] 
2015-03-09T21:33:19.784+0800 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.
2015-03-09T21:33:19.784+0800 [initandlisten] **       32 bit builds are limited to less than 2GB of data (or less with --journal).
2015-03-09T21:33:19.784+0800 [initandlisten] **       Note that journaling defaults to off for 32 bit and is currently off.
2015-03-09T21:33:19.784+0800 [initandlisten] **       See http://dochub.mongodb.org/core/32bit
2015-03-09T21:33:19.784+0800 [initandlisten] 
2015-03-09T21:33:19.784+0800 [initandlisten] db version v2.6.0
2015-03-09T21:33:19.784+0800 [initandlisten] git version: 1c1c76aeca21c5983dc178920f5052c298db616c
2015-03-09T21:33:19.785+0800 [initandlisten] build info: Linux ip-10-114-47-109 2.6.18-194.32.1.el5xen #1 SMP Mon Dec 20 11:08:09 EST 2010 i686 BOOST_LIB_VERSION=1_49
2015-03-09T21:33:19.785+0800 [initandlisten] allocator: system
2015-03-09T21:33:19.785+0800 [initandlisten] options: {}
2015-03-09T21:33:19.824+0800 [FileAllocator] allocating new datafile /data/db/local.ns, filling with zeroes...
2015-03-09T21:33:19.824+0800 [FileAllocator] creating directory /data/db/_tmp
2015-03-09T21:33:19.831+0800 [FileAllocator] done allocating datafile /data/db/local.ns, size: 16MB,  took 0.002 secs
2015-03-09T21:33:19.867+0800 [FileAllocator] allocating new datafile /data/db/local.0, filling with zeroes...
2015-03-09T21:33:19.870+0800 [FileAllocator] done allocating datafile /data/db/local.0, size: 64MB,  took 0.002 secs
2015-03-09T21:33:19.878+0800 [initandlisten] build index on: local.startup_log properties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "local.startup_log" }
2015-03-09T21:33:19.878+0800 [initandlisten] 	 added index to empty collection
2015-03-09T21:33:19.884+0800 [initandlisten] waiting for connections on port 27017

4、验证mongo是否正常运行

[root@bogon /]# cd /softwares/mongodb-linux-i686-2.6.0/bin
[root@bogon bin]# mongo
bash: mongo: command not found
[root@bogon bin]# ls
bsondump  mongo  mongod  mongodump  mongoexport  mongofiles  mongoimport  mongooplog  mongoperf  mongorestore  mongos  mongostat  mongotop
[root@bogon bin]# mongo
bash: mongo: command not found
[root@bogon bin]# ./mongo
MongoDB shell version: 2.6.0
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-03-09T21:33:19.784+0800 [initandlisten] 
2015-03-09T21:33:19.784+0800 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.
2015-03-09T21:33:19.784+0800 [initandlisten] **       32 bit builds are limited to less than 2GB of data (or less with --journal).
2015-03-09T21:33:19.784+0800 [initandlisten] **       Note that journaling defaults to off for 32 bit and is currently off.
2015-03-09T21:33:19.784+0800 [initandlisten] **       See http://dochub.mongodb.org/core/32bit
2015-03-09T21:33:19.784+0800 [initandlisten] 
>

5、开放端口27017

[root@bogon bin]# vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 27017 -j ACCEPT
[root@bogon bin]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]

6、查看mongodb启动结果

[root@bogon bin]# netstat -pan|grep 27017
tcp        0      0 0.0.0.0:27017               0.0.0.0:*                   LISTEN      2487/mongod         
tcp        0      0 127.0.0.1:53891             127.0.0.1:27017             ESTABLISHED 2501/./mongo        
tcp        0      0 127.0.0.1:27017             127.0.0.1:53891             ESTABLISHED 2487/mongod         
unix  2      [ ACC ]     STREAM     LISTENING     20555  2487/mongod         /tmp/mongodb-27017.sock








 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值