ubuntu安装mongodb及配置
2015-12-18 16:45
645 查看
参考:https://docs.mongodb.org/v3.0/tutorial/install-mongodb-on-ubuntu/
安装:
apt) ensurepackage consistency and authenticity by requiring that distributorssign packages with GPG keys. Issue the following command to import theMongoDB
public GPG Key:
Ubuntu 12.04
Ubuntu 14.04
运行:
mongod:
mongod process has started successfully bychecking the contents of the log file at/var/log/mongodb/mongod.logfor
a line reading
where <port> is the port configured in
/etc/mongod.conf,
27017 by default.
3
mongod process by issuing thefollowing command:
mongod:
5
GettingStarted Guides in various driver editions. SeeGetting Started for the available editions.
Before deploying MongoDB in a production environment, consider theProduction Notes document.
Later, to stop MongoDB, press Control+C in the terminal where themongod
instance is running.
Warning
This process will completely remove MongoDB, its configuration, and
alldatabases. This process is not reversible, so ensure that all of yourconfiguration and data is backed up before proceeding.
1
mongod process by issuing the following command:
2
3
设置
编辑:/etc/mongod.conf
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1
#processManagement:
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
设置用户名密码:
运行mongo命令: ./usr/bin/mongod -f /etc/mongod.conf --auth --fork
安装:
Import the public key used by the package management system.
The Ubuntu package management tools (i.e. dpkg andapt) ensurepackage consistency and authenticity by requiring that distributorssign packages with GPG keys. Issue the following command to import theMongoDB
public GPG Key:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
Create a list file for MongoDB.
Create the /etc/apt/sources.list.d/mongodb-org-3.0.list list file usingthe command appropriate for your version of Ubuntu:Ubuntu 12.04
echo "deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
Ubuntu 14.04
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
Reload local package database.
Issue the following command to reload the local package database:sudo apt-get update
Install the MongoDB packages.
You can install either the latest stable version of MongoDB or aspecific version of MongoDB.Install the latest stable version of MongoDB.
Issue the following command:sudo apt-get install -y mongodb-org
Install a specific release of MongoDB.
To install a specific release, you must specify each component packageindividually along with the version number, as in thefollowing example:sudo apt-get install -y mongodb-org=3.0.8 mongodb-org-server=3.0.8 mongodb-org-shell=3.0.8 mongodb-org-mongos=3.0.8 mongodb-org-tools=3.0.8
运行:
Start MongoDB.
Issue the following command to startmongod:
sudo service mongod start
Verify that MongoDB has started successfully
Verify that themongod process has started successfully bychecking the contents of the log file at/var/log/mongodb/mongod.logfor
a line reading
[initandlisten] waiting for connections on port <port>
where <port> is the port configured in
/etc/mongod.conf,
27017 by default.
3
Stop MongoDB.
As needed, you can stop themongod process by issuing thefollowing command:
sudo service mongod stop
Restart MongoDB.
Issue the following command to restartmongod:
sudo service mongod restart
5
Begin using MongoDB.
To help you start using MongoDB, MongoDB providesGettingStarted Guides in various driver editions. SeeGetting Started for the available editions.
Before deploying MongoDB in a production environment, consider theProduction Notes document.
Later, to stop MongoDB, press Control+C in the terminal where themongod
instance is running.
Uninstall MongoDB
To completely remove MongoDB from a system, you must remove the MongoDBapplications themselves, the configuration files, and any directories containingdata and logs. The following section guides you through the necessary steps.Warning
This process will completely remove MongoDB, its configuration, and
alldatabases. This process is not reversible, so ensure that all of yourconfiguration and data is backed up before proceeding.
1
Stop MongoDB.
Stop themongod process by issuing the following command:
sudo service mongod stop
2
Remove Packages.
Remove any MongoDB packages that you had previously installed.sudo apt-get purge mongodb-org*
3
Remove Data Directories.¶
Remove MongoDB databases and log files.sudo rm -r /var/log/mongodb sudo rm -r /var/lib/mongodb
设置
编辑:/etc/mongod.conf
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1
#processManagement:
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
设置用户名密码:
use products db.createUser( { "user" : "accountAdmin01", "pwd": "cleartext password", "customData" : { employeeId: 12345 }, "roles" : [ { role: "clusterAdmin", db: "admin" }, { role: "readAnyDatabase", db: "admin" }, "readWrite" ] }, { w: "majority" , wtimeout: 5000 } )
运行mongo命令: ./usr/bin/mongod -f /etc/mongod.conf --auth --fork
相关文章推荐
- MongoDB的安装(单机,副本集,分片)
- nodejs+mongodb系列教程之(4/5)--mongoose使用
- 【七】MongoDB管理之分片集群介绍
- MongoDB 备份(mongodump)恢复(mongorerstore) 导出 (Mongoexport) 导入( Mongoimport)
- MongoDB设置访问权限、设置用户
- 【Mongodb】3.X 配置身份验证
- nodejs+mongodb系列教程之(3/5)--理解路由和中间件
- mongodb查询
- MongoDB配置参数详解
- nodejs+mongodb系列教程之(2/5)--认识express4构建的nodes项目
- 查询MongoDB子文档的List字段
- MongoDB整合Spring的操作
- MongoDB快速上手
- MongoDB快速上手
- mongodb 学习笔记05 --用户管理
- mongoVUE对mongodb常用的基础操作
- nodejs+mongodb系列教程之(1/5)--开篇总述
- mongodb conf 文件
- mongodb的增删查改等常用操作
- YII2操作mongodb笔记