mongodb - Ubuntu 20.04 中的 MonogDB 3.4
问题描述
在生产应用程序中,我们使用的是 MongoDB 3.4 版本。我在本地机器上安装了 ubuntu 20.04 LTS,并尝试安装 Mongo 3.4 并撞到墙上。请让我知道你的想法。这是我的步骤:
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
echo "deb http://repo.mongodb.com/apt/ubuntu "$(lsb_release -sc)"/mongodb-enterprise/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-enterprise-3.4.list
sudo apt-get update
sudo apt-get install -y mongodb-org
解决方案
好吧,我只是以一种更“手工制作的方式”来做这件事,也许......
从这里下载了应用程序:https ://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.4.24.tgz (它是,让我们从 mongodb 页面调用 vanila 版本)
在 /opt 上解压缩它:
tar zxf mongodb-linux-x86_64-3.4.24.tgz -C /opt/
短名称的符号链接:
ln -s /opt/mongodb-linux-x86_64-3.4.24 /opt/mongo
为 mongo 创建了用户:
useradd -r mongod
然后添加 systemctl 命令:
echo "[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
[Service]
User=mongod
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
[Install]
WantedBy=multi-user.target" > /etc/systemd/system/mongod.service
重新加载systemctl:
systemctl daemon-reload
然后使用以下内容创建 /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: /opt/mongo/database/
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongod.log
# network interfaces
net:
port: 27017
# bindIp: 127.0.0.1
#processManagement:
#security:
#operationProfiling:
#replication:
# replSetName: "mongodb-keys-replica-set"
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
然后启动服务:
systemctl start mongod
根据需要调整配置和目录路径。
它有效,是该 ubuntu 版本的旧版本的某种手工解决方案。不会使用 apt-get 或相关更新...但可以正常工作。
如果在本地,出于测试目的,使用 docker 映像可能不是一个坏主意……但只是一个建议,而不是您问题的答案。
推荐阅读
- javascript - HTML按钮不与Javascript交互
- reactjs - 将 ra-data-graphql 与 AppSync GraphQL API 一起使用
- c - Tizen 屏幕键盘(输入组件)文本截断
- python - 带有网站的 DNS 欺骗程序
- python - 来自 react native 的 POST 请求没有到达我的烧瓶服务器
- javascript - 为什么不能加载块?
- xamarin - 如何在 Xamarin Forms 中创建带有注释区域以及叠加层的 xaml
- java - 我应该总是有一个单独的“DataService”来调用另一个服务吗?
- ruby-on-rails - 如何创建没有模型的页面?
- pdf - PDF 生成——如何合并多个流对象?