Home - 1990bingliu/mongodb GitHub Wiki
ubuntu下安装mongodb
sudo apt-get install mongodb
快速安装 查看一下当前版本
$ dpkg -l mongodb
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-=================================
ii mongodb 1:2.6.10-0ub amd64 object/document-oriented database
2.6.10 版本的,不是最新,最新是的4.0
测试一下连接mongodb
$ mongo
MongoDB shell version: 2.6.10
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
>
默认就连接上了test 数据库
使用mongodb官方的的deb库,安装较新的版本
- 导入包管理系统使用的公钥
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
- 为MongoDB创建一个列表文件
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
- 更新本地包数据库
sudo apt-get update
- 安装最新的MongoDB
sudo apt-get install -y mongodb-org
- 查看配置文件
配置文件路径在
/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 #绑定监听的ip 127.0.0.1只能监听本地的连接,可以改为0.0.0.0
#processManagement:
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
- 启动MongoDb
sudo serivce mongod statrt # 启动守护进程
sudo service mongod stop # 关闭