您的位置:首页 > 数据库 > Mongodb

mongodb2.6安装

2015-12-19 20:32 627 查看
操作系统环境如下:

[root@zxl-nginx ~]# cat /etc/issue
CentOS release 6.4 (Final)
Kernel \r on an \m
[root@zxl-nginx ~]# uname -r
2.6.32-358.el6.x86_64
mongodb2.6下载地址
# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.11.tgz[/code]安装mongodb2.6 
[root@zxl-nginx src]# ll mongodb-linux-x86_64-2.6.11.gz
-rw-r--r-- 1 root root 116659120 Dec 13 09:32 mongodb-linux-x86_64-2.6.11.gz
[root@zxl-nginx src]# tar fxz mongodb-linux-x86_64-2.6.11.gz
[root@zxl-nginx src]# mv mongodb-linux-x86_64-2.6.11 /usr/local/
[root@zxl-nginx src]# ln -s  /usr/local/mongodb-linux-x86_64-2.6.11 /usr/local/mongodb
创建mongodb用户
[root@zxl-nginx src]#groupadd -r mongodb
[root@zxl-nginx src]#useradd -r -g mongodb mongodb
创建mongodb数据库和logs目录
[root@zxl-nginx src]#mkdir /data/
[root@zxl-nginx src]#mkdir /data/logs /data/m20000
[root@zxl-nginx src]#chown mongodb.mongodb /data -R
mongo环境变量配置
vim /etc/profile
export PATH=$PATH:/usr/local/mongodb/bin
加载环境配置文件
source /ect/profile
启动mongodb
mongod --dbpath=/data/m20000/ --logpath=/data/logs/m20000.log  --logappend -fork --port 20000
登陆mongodb
[root@zxl-nginx ~]# mongo --port 20000
MongoDB shell version: 2.6.11
connecting to: 127.0.0.1:20000/test
> db
test


创建数据以及查看
> use zxl
switched to db zxl
> db.ha.insert({name:"abc",age:21})
WriteResult({ "nInserted" : 1 })
> db.ha.find()
{ "_id" : ObjectId("56739b27154b52481c1c5749"), "name" : "abc", "age" : 21 }


本文出自 “村里的男孩” 博客,请务必保留此出处http://noodle.blog.51cto.com/2925423/1726421
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: