到mongodb官方网站http://www.mongodb.org/downloads下载mongodb,解压并将目录考到需要安装的服务器上,然后进行配置。例如:
[root@SHNHDX17-165 mongodb]# mkdir data
[root@SHNHDX17-165 mongodb]# mkdir logs
[root@SHNHDX17-165 mongodb]# cd logs
[root@SHNHDX17-165 logs]# touch mongodb.log
port=27017 【代表端口号,如果不指定则默认为 27017 】
dbpath=/root/data/web/mongodb/data/ 【数据库路径】
logpath=/root/data/web/mongodb/logs/mongodb.log 【日志路径】
logappend=true 【日志文件自动累加,而不是覆盖】
[root@SHNHDX17-164 mongodb]# bin/mongo localhost:27017
MongoDB shell version: 2.4.5
connecting to: localhost:27017/test
Server has startup warnings:
Fri Nov 8 13:05:59.823 [initandlisten]
Fri Nov 8 13:05:59.823 [initandlisten] ** WARNING: You are running on a NUMA machine.
Fri Nov 8 13:05:59.823 [initandlisten] ** We suggest launching mongod like this to avoid performance problems:
Fri Nov 8 13:05:59.823 [initandlisten] ** numactl --interleave=all mongod [other options]
Fri Nov 8 13:05:59.823 [initandlisten]
>
vi ~/.bash_profile
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin:/root/data/web/mongodb/bin