Mongodb的安装

1、创建yum源文件:

# vim /etc/yum.repos.d/10gen.repo


[10gen]

name=10gen Repository

baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64

gpgcheck=0

enabled=1

2、安装mongodb
# yum install mongo-10gen mongo-10gen-server

以上默认安装为最新版本,也可以添加版本号,安装指定版本,如:

# yum install mongo-10gen-2.2.3 mongo-10gen-server-2.2.3

3、配置:

安装完成后,配置文件为:/etc/mongod.conf

默认日志路径:/var/log/mongo/mongod.log

默认开启后台运行:fork = true

默认端口:port = 27017

默认数据存放路径:dbpath=/var/lib/mongo

默认pid文件路径:pidfilepath = /var/run/mongodb/mongod.pid

4、mongodb服务控制

设置开机运行:chkconfig mongod on

服务开启|关闭|重启:service mongod start|stop|restart

5、使用mongodb

[root@xen-test ~]# mongo

MongoDB shell version: 2.4.3

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

> db.test.save({id:11})

> db.test.find()

{ "_id" : ObjectId("51925edc6855b7c18d8203fb"), "id" : 11 }

> exit

bye


你可能感兴趣的:(MongoDB安装)