mongodb2.6安装
操作系统环境如下:1
2
3
4
5
# cat /etc/issue
CentOS release 6.4 (Final)
Kernel \r on an \m
# uname -r
2.6.32-358.el6.x86_64
mongodb2.6下载地址
1
# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.11.tgz
安装mongodb2.6
1
2
3
4
5
# 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
# tar fxz mongodb-linux-x86_64-2.6.11.gz
# mv mongodb-linux-x86_64-2.6.11 /usr/local/
# ln -s/usr/local/mongodb-linux-x86_64-2.6.11 /usr/local/mongodb
创建mongodb用户
1
2
#groupadd -r mongodb
#useradd -r -g mongodb mongodb
创建mongodb数据库和logs目录
1
2
3
#mkdir /data/
#mkdir /data/logs /data/m20000
#chown mongodb.mongodb /data -R
mongo环境变量配置
1
2
vim /etc/profile
export PATH=$PATH:/usr/local/mongodb/bin
加载环境配置文件
1
source /ect/profile
启动mongodb
1
mongod --dbpath=/data/m20000/ --logpath=/data/logs/m20000.log--logappend -fork --port 20000
登陆mongodb
1
2
3
4
5
# mongo --port 20000
MongoDB shell version: 2.6.11
connecting to: 127.0.0.1:20000/test
> db
test
创建数据以及查看
1
2
3
4
5
6
> 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 }
页:
[1]