1.下载安装包并解压
mkdir –p /opt/app/mongodb mv /opt/install/mongodb-linux-x86_64-3.0.1/ mongod
3。配置环境变量
Ensure the location of the binaries is in the PATH variable.
you can add the following line to your shell’s rc file (e.g. $HOME/.bash_profile):
export PATH$HOMGO_HOME/bin:$PATH
Run mongodb instance with dameo
4.1 Create the data directory.
mkdir -p /opt/mongo_data/db
4.2 建立启动和停止脚本
1.mongodb默认端口是27017,如果需要修改则在启动mongod进程时候则需要使用—port 选项,例如:—port 12345
2.mongodb以后台运行任务方式启动
mongod --fork --logpath /var/log/mongodb.log --dbpath /opt/mongo_data/db
3.停止mongodb进程
3.1从 mongo shell则使用 use admin db.shutdownServer()
3.2 使用mongod --shutdown 命令停止mongod进程
例如:mongod --logpath /var/log/mongodb.log --dbpath /opt/mongo_data/db --shutdown
3.3 使用kill命令停止mongod进程
参考资料:
http://docs.mongodb.org/master/tutorial/install-mongodb-on-linux/
http://docs.mongodb.org/manual/tutorial/manage-mongodb-processes/
原文:http://www.cnblogs.com/lily-tiantian/p/4365830.html