MongoDB (NoSQL) for Linux 部署文档
一:运行环境
操作系统:oracle enterprise linux 6.5(64bit)
Current version:x86_64-2.6.5 for linux
二:减压安装包
[root@www.solgle.com Desktop]# tar -vxzf mongodb-linux-x86_64-2.6.5.gz
mongodb-linux-x86_64-2.6.5/README
mongodb-linux-x86_64-2.6.5/THIRD-PARTY-NOTICES
mongodb-linux-x86_64-2.6.5/GNU-AGPL-3.0
mongodb-linux-x86_64-2.6.5/bin/mongodump
mongodb-linux-x86_64-2.6.5/bin/mongorestore
mongodb-linux-x86_64-2.6.5/bin/mongoexport
mongodb-linux-x86_64-2.6.5/bin/mongoimport
mongodb-linux-x86_64-2.6.5/bin/mongostat
mongodb-linux-x86_64-2.6.5/bin/mongotop
mongodb-linux-x86_64-2.6.5/bin/mongooplog
mongodb-linux-x86_64-2.6.5/bin/mongofiles
mongodb-linux-x86_64-2.6.5/bin/bsondump
mongodb-linux-x86_64-2.6.5/bin/mongoperf
mongodb-linux-x86_64-2.6.5/bin/mongod
mongodb-linux-x86_64-2.6.5/bin/mongos
mongodb-linux-x86_64-2.6.5/bin/mongo
[root@www.solgle.com Desktop]# ls
mongodb-linux-x86_64-2.6.5 mongodb-linux-x86_64-2.6.5.gz
三:创建相关目录文件
1:创建数据及日志存放目录及文件
[root@www.solgle.com ~]# mkdir /mongodb
[root@www.solgle.com ~]# mkdir /mongodb/data
[root@www.solgle.com ~]# mkdir /mongodb/log
[root@www.solgle.com mongodb]# cd log
[root@www.solgle.com log]# touch mongodb.log
[root@www.solgle.com log]#
2:将减压的mongodb-linux-x86_64-2.6.5文件也移动进来
[root@www.solgle.com Desktop]# mv mongodb-linux-x86_64-2.6.5 /mongodb/
[root@www.solgle.com Desktop]# cd /mongodb/
[root@www.solgle.com mongodb]# ls
data log mongodb-linux-x86_64-2.6.5
四:配置环境变量
1:进入目录
[root@www.solgle.com bin]# cd /mongodb/mongodb-linux-x86_64-2.6.5/bin
[root@www.solgle.com bin]# ls
bsondump mongod mongoexport mongoimport mongoperf mongos mongotop
mongo mongodump mongofiles mongooplog mongorestore mongostat
[root@www.solgle.com bin]# ./mongod --help
Options:
General options:
-h [ --help ] show this usage information
--version show version information
-f [ --config ] arg configuration file specifying additional options
-v [ --verbose ] [=arg(=v)] be more verbose (include multiple times for more
verbosity e.g. -vvvvv)
--quiet quieter output
--port arg specify port number - 27017 by default
--bind_ip arg comma separated list of ip addresses to listen on
- all local ips by default
--maxConns arg max number of simultaneous connections - 1000000
by default
… …
… …
2:启动mongodb
方法a:
[root@www.solgle.com bin]# ./mongod -port 27017 --dbpath /mongodb/data/ --logpath
/mongodb/log/mongodb.log
---执行了该命令后,可能需要重新开终端窗口
方法b:
[root@www.solgle.com mongodb]# cd /mongodb/
[root@www.solgle.com mongodb]# vi mongodb.conf
port=27017
dbpath=/mongodb/data/
logpath=/mongodb/log/mongodb.log
logappend=true
:wq!
[root@www.solgle.com mongodb]# cd /mongodb/mongodb-linux-x86_64-2.6.5/bin
[root@www.solgle.com bin]# ./mongod -f /mongodb/mongodb.conf
3:查看端口及服务
[root@www.solgle.com ~]# netstat -lanp | grep "27017"
tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN
3910/./mongod
unix 2 [ ACC ] STREAM LISTENING 22328 3910/./mongod
/tmp/mongodb-27017.sock
[root@www.solgle.com ~]# cd /mongodb/mongodb-linux-x86_64-2.6.5/bin/
[root@www.solgle.com bin]# ls
bsondump mongod mongoexport mongoimport mongoperf mongos mongotop
mongo mongodump mongofiles mongooplog mongorestore mongostat
4:测试登陆
[root@www.solgle.com bin]# ./mongo
MongoDB shell version: 2.6.5
connecting to: test
> exit
Bye
[root@www.solgle.com bin]# ./mongo localhost:27017
MongoDB shell version: 2.6.5
connecting to: localhost:27017/test
>
5:测试浏览器访问
输入网址
http://192.168.*.*:27017/
浏览器显示结果:It looks like you are trying to access MongoDB over HTTP on the
native driver port.