首页 > 代码库 > mongodb的安装和配置
mongodb的安装和配置
1.下载安装
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.6.tgz
tar zxf mongodb-linux-x86_64-3.0.6.tgz
mv mongodb-linux-x86_64-3.0.6 /usr/local/mongodb
2.创建数据目录,必须创建,不然启动失败。
mkdir -p /data/db
启动:
/usr/local/mongodb/bin/mongod --dbpath=/usr/local/server/mongodb/data --logpath=/usr/local/server/mongodb/logs --logappend --port=27017 --fork
3.参数解释
/usr/local/mongodb/bin/mongo
MongoDB shell version: 3.0.6
connecting to: test
>2+2
4
2017-06-11T00:12:09.875+0800 I NETWORK [initandlisten] connection accepted from 127.0.0.1:54624 #13 (1 connection now open)
2017-06-11T00:12:09.880+0800 I ACCESS [conn13] Unauthorized not authorized on admin to execute command { getLog: "startupWarnings" }
2017-06-11T00:12:28.804+0800 I NETWORK [initandlisten] connection accepted from 10.10.2.13:63225 #14 (2 connections now open)
2017-06-11T00:12:28.805+0800 I NETWORK [initandlisten] connection accepted from 10.10.2.13:63227 #15 (3 connections now open)
2017-06-11T00:12:28.805+0800 I NETWORK [initandlisten] connection accepted from 10.10.2.13:63226 #16 (4 connections now open)
2017-06-11T00:12:28.808+0800 I NETWORK [conn14] end connection 10.10.2.13:63225 (3 connections now open)
2017-06-11T00:12:28.831+0800 I NETWORK [conn15] end connection 10.10.2.13:63227 (2 connections now open)
2017-06-11T00:12:29.717+0800 I NETWORK [conn16] end connection 10.10.2.13:63226 (1 connection now open)
(1 connection now open)#表明一个来自本机的连接
5.创建数据库
> use aaa #创建
switched to db aaa
> db #查看
aaa
6.MongoDB 备份(mongodump)与恢复(mongorestore)
mongodb的安装和配置