参考文档
https://docs.mongodb.com/manual/tutorial/install-mongodb-enterprise-on-ubuntu/
用 apt-get 安装
安装 步骤
1.导入包管理系统使用的公钥
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
- /etc/apt/sources.list.d/mongodb-enterprise.list 为MongoDB 创建一个文件 。版本-- ubuntu18.04
echo "deb [ arch=amd64 ] http://repo.mongodb.com/apt/ubuntu bionic/mongodb-enterprise/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-enterprise.list
3.重新加载本地包数据库
sudo apt-get update
4.安装MongoDB Enterprise软件包
sudo apt-get install -y mongodb-enterprise
5.安装MongoDB Enterprise的特定版本
sudo apt-get install -y mongodb-enterprise=4.0.3 mongodb-enterprise-server=4.0.3 mongodb-enterprise-shell=4.0.3 mongodb-enterprise-mongos=4.0.3 mongodb-enterprise-tools=4.0.3
6.固定特定版本的MongoDB Enterprise
echo "mongodb-enterprise hold" | sudo dpkg --set-selections
echo "mongodb-enterprise-server hold" | sudo dpkg --set-selections
echo "mongodb-enterprise-shell hold" | sudo dpkg --set-selections
echo "mongodb-enterprise-mongos hold" | sudo dpkg --set-selections
echo "mongodb-enterprise-tools hold" | sudo dpkg --set-selections
运行
默认情况下,MongoDB实例存储
- 它的数据文件 /var/lib/mongodb
- 它的日志文件 /var/log/mongodb
----- 验证MongoDB是否已成功启动:
mongod
通过检查日志文件的内容以/var/log/mongodb/mongod.log
获取行读数,验证进程是否已成功启动
sudo service mongod start
sudo service mongod stop
sudo service mongod restart
配置文件:
/etc/mongod.conf
shell 链接
mongodb 的 默认端口 27017
which mongod
which mongo
mongo --port 27017
mongo
客户端连接
mongodb 默认 本地连接
# 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
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
修改配置
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0
sudo service mongod restart
二进制包安装
mongodb.conf 内容:
storage:
dbPath: /var/lib/mongodb/
journal:
enabled: true
wiredTiger:
engineConfig:
configString: cache_size=1024M
systemLog:
verbosity: 0
destination: file
logAppend: true
path: /var/log/mongodb/mongodb.log
net:
port: 27017
bindIp: 0.0.0.0
processManagement:
fork: true
timeZoneInfo: /usr/share/zoneinfo
启动
mongod -f /etc/mongodb.conf
网友评论