安装 mongodb
curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhe170-4.2.1.tgz
tar -xvf mongodb-linux-x86_64-rhe170-4.2.1
export PATH=$PATH:/datat/mongodb-linux-x86_64-rhe170-4.2.1/bin
mongod --dbpath /data/db -port 27017 --logpath /data/db/monogod.log --fork
mkdir -p /data /data/db
导入示例数据
curl -O -k https://raw.githubusercontent.com/tapdata/geeltime-mongodb-course/master/aggregation/dump.tar.gz
tar -xvf dump.tar.gz
mongorestore -h localhost:27017
title: MongoDB 安装 date: 2020-03-05 15:07:56 updated: 2020-03-05 15:07:56 tags:
- install
- mongodb category: description:
MacOS
使用 brew 安装
brew tap mongodb/brew
brew install mongodb-community
前台运行
mongod --config /usr/local/etc/mongod.conf
后台启动
brew services start mongodb-community
停止运行
brew services stop mongodb-community
配置文件
systemLog:
destination: file
path: /usr/local/var/log/mongodb/mongo.log
logAppend: true
storage:
dbPath: /usr/local/var/mongodb
net:
bindIp: 127.0.0.1
ubuntu 18.04
安装 MongoDB
apt update
apt install -y mongodb
运行
mongod --config /etc/mongodb.conf
查看 MongoDB 运行状态
systemctl status mongodb
启动 MongoDB
systemctl start mongod
停止 MongoDB
systemctl stop mongod
设置开机启动 MongoDB
systemctl enable mongod
配置文件
/etc/mongodb.conf
https://gist.github.com/7e28fe926291da61cfd3ebbe60de6e4e
docker 运行
docker run --name some-mongo -d mongo
更新记录
- 2020-03-05 15:07:56 首次发布