在 Ubuntu 20.04 上安装 Mongodb 时出现问题
Problems Installing Mongodb on Ubuntu 20.04
将提供快速上下文。我对手册很严格:
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
- wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
- echo "deb [arch=amd64,arm64] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 多元宇宙" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
- sudo apt-get 更新
- sudo apt-get install -y mongodb-org
- sudo systemctl 启动 mongod
- sudo systemctl status mongod
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2020-11-12 03:11:07 EET; 1min 8s ago
Docs: https://docs.mongodb.org/manual
Process: 6780 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=14)
Main PID: 6780 (code=exited, status=14)
systemd[1]: Started MongoDB Database Server.
systemd[1]: mongod.service: Main process exited, code=exited, status=14/n/a
systemd[1]: mongod.service: Failed with result 'exit-code'.
- mongo
MongoDB shell version v4.4.1
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1
然后尝试通过以下方式修复此状态=14/n/a:
sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chown mongodb:mongodb /tmp/mongodb-27017.sock
和其他东西
然后删除了 mongodb:
sudo apt-get purge mongodb-org*
sudo apt remove mongodb
sudo apt purge mongodb
sudo apt autoremove
按照上面的方法安装,结果一样。我需要帮助。
那是 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
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
这是来自 var/log/mongodb/mongod.log 的 mongod 日志文件是 550 行,我只复制了最后一个日志:
{"t":{"$date":"2020-11-12T15:30:35.643+02:00"},"s":"W", "c":"CONTROL", "id":20698, "ctx":"main","msg":"***** SERVER RESTARTED *****","tags":["startupWarnings"]}
{"t":{"$date":"2020-11-12T15:30:35.645+02:00"},"s":"I", "c":"CONTROL", "id":23285, "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2020-11-12T15:30:35.655+02:00"},"s":"W", "c":"ASIO", "id":22601, "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2020-11-12T15:30:35.655+02:00"},"s":"I", "c":"NETWORK", "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
{"t":{"$date":"2020-11-12T15:30:35.656+02:00"},"s":"I", "c":"STORAGE", "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":9759,"port":27017,"dbPath":"/var/lib/mongodb","architecture":"64-bit","host":"lubo"}}
{"t":{"$date":"2020-11-12T15:30:35.656+02:00"},"s":"I", "c":"CONTROL", "id":23403, "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.1","gitVersion":"ad91a93a5a31e175f5cbf8c69561e788bbc55ce1","openSSLVersion":"OpenSSL 1.1.1f 31 Mar 2020","modules":[],"allocator":"tcmalloc","environment":{"distmod":"ubuntu2004","distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2020-11-12T15:30:35.656+02:00"},"s":"I", "c":"CONTROL", "id":51765, "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Ubuntu","version":"20.04"}}}
{"t":{"$date":"2020-11-12T15:30:35.656+02:00"},"s":"I", "c":"CONTROL", "id":21951, "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"config":"/etc/mongod.conf","net":{"bindIp":"127.0.0.1","port":27017},"processManagement":{"timeZoneInfo":"/usr/share/zoneinfo"},"storage":{"dbPath":"/var/lib/mongodb","journal":{"enabled":true}},"systemLog":{"destination":"file","logAppend":true,"path":"/var/log/mongodb/mongod.log"}}}}
{"t":{"$date":"2020-11-12T15:30:35.657+02:00"},"s":"F", "c":"STORAGE", "id":50922, "ctx":"initandlisten","msg":"An incomplete repair has been detected! This is likely because a repair operation unexpectedly failed before completing. MongoDB will not start up again without --repair."}
{"t":{"$date":"2020-11-12T15:30:35.657+02:00"},"s":"F", "c":"-", "id":23091, "ctx":"initandlisten","msg":"Fatal assertion","attr":{"msgid":50922,"file":"src/mongo/db/storage/storage_engine_init.cpp","line":86}}
{"t":{"$date":"2020-11-12T15:30:35.657+02:00"},"s":"F", "c":"-", "id":23092, "ctx":"initandlisten","msg":"\n\n***aborting after fassert() failure\n\n"}
更新 ATM 我这次使用 Whosebug 的指南尝试了另一个重新安装:
- sudo apt-get install --reinstall mongodb
(有错误 - 处理时遇到错误)
- sudo systemctl 守护进程重新加载
- sudo apt update/upgrate
- sudo apt 安装 mongodb
(以下包已自动安装,不再需要)
- sudo apt autoremove
- sudo systemctl 状态 mongodb
(主进程退出,code=exited,status=100/n/a)
- sudo mongo
MongoDB shell version v3.6.8
connecting to: mongodb://127.0.0.1:27017
Implicit session: session { "id" : UUID("667c92c8-0a10-4adb-bcf6-ba045f280034") }
MongoDB server version: 3.6.8
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
Server has startup warnings:
2020-11-12T17:33:37.780+0200 I STORAGE [initandlisten]
2020-11-12T17:33:37.780+0200 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2020-11-12T17:33:37.780+0200 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2020-11-12T17:33:38.722+0200 I CONTROL [initandlisten]
2020-11-12T17:33:38.722+0200 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-11-12T17:33:38.722+0200 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2020-11-12T17:33:38.722+0200 I CONTROL [initandlisten]
- sudo apt-get install libc6
(libc6已经是最新版本(2.31-0ubuntu9.1))
- sudo systemctl status mongod
mongod.service
Loaded: not-found (Reason: Unit mongod.service not found.)
Active: active (running) since Thu 2020-11-12 17:33:37 EET; 7min ago
Main PID: 16038 (mongod)
CGroup: /system.slice/mongod.service
└─16038 /usr/bin/mongod --config /etc/mongod.conf
ное 12 17:33:37 lubo systemd[1]: Started MongoDB Database Server.
ное 12 17:34:03 lubo systemd[1]: mongod.service: Current command vanished from the unit file, execution of the command list won't be resumed.
现在我相信我们已经在 mongod 工作了,只是为了将它与 mongod.service
联系起来
- 首先删除 mongodb 的所有 PPA 存储库,然后:
- sudo apt-get purge mongodb-org*
- sudo apt 删除 mongodb
- sudo apt purge mongodb
- sudo apt autoremove
- sudo rm -r /var/log/mongodb
- sudo rm -r /var/lib/mongodb
- sudo apt-get 安装 gnupg
- wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
- echo "deb [arch=amd64,arm64] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 多元宇宙" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
- sudo apt-get 更新
- sudo apt-get 升级
- sudo apt 更新
- sudo apt 升级
- sudo apt-get install -y mongodb-org
- sudo apt-get 安装 libc6
- sudo 服务 mongod 启动
- sudo 服务 mongod 状态
这帮助我解决了这个问题
您收到此错误是因为您没有授予对 mongodb 的访问权限
您只需
sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chown mongodb:mongodb /tmp/mongodb-27017.sock
sudo service mongod restart
you can use this medium.com link,too.
现在喜欢与 mongodb
一起工作
Mongodb server-4.4.asc 在某些机器上有 ubuntu 20.04 的错误。
我重试了几次,发现了“server-4.4.asc”上的错误。我建议安装“server-4.2.asc”(ver 4.2 可以,4.4 有错误)。
MongoDB 已包含在 Ubuntu 软件包存储库中,但官方 MongoDB 存储库提供最多 up-to-date 版本,是安装软件的推荐方式。在这一步中,我们将把这个官方存储库添加到我们的服务器。
Ubuntu 通过验证软件包是否使用 GPG 密钥签名来确保软件包的真实性,因此我们首先必须导入官方 MongoDB 存储库的密钥。
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
接下来,我们将添加 MongoDB 存储库详细信息,以便 apt 知道在哪里下载软件包。发出以下命令为 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-org meta-package,其中包括守护程序、配置和初始化脚本、shell 以及管理工具。
sudo apt-get install mongodb-org
:)
将提供快速上下文。我对手册很严格: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
- wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
- echo "deb [arch=amd64,arm64] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 多元宇宙" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
- sudo apt-get 更新
- sudo apt-get install -y mongodb-org
- sudo systemctl 启动 mongod
- sudo systemctl status mongod
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2020-11-12 03:11:07 EET; 1min 8s ago
Docs: https://docs.mongodb.org/manual
Process: 6780 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=14)
Main PID: 6780 (code=exited, status=14)
systemd[1]: Started MongoDB Database Server.
systemd[1]: mongod.service: Main process exited, code=exited, status=14/n/a
systemd[1]: mongod.service: Failed with result 'exit-code'.
- mongo
MongoDB shell version v4.4.1
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1
然后尝试通过以下方式修复此状态=14/n/a:
sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chown mongodb:mongodb /tmp/mongodb-27017.sock
和其他东西
然后删除了 mongodb:
sudo apt-get purge mongodb-org*
sudo apt remove mongodb
sudo apt purge mongodb
sudo apt autoremove
按照上面的方法安装,结果一样。我需要帮助。
那是 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
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
这是来自 var/log/mongodb/mongod.log 的 mongod 日志文件是 550 行,我只复制了最后一个日志:
{"t":{"$date":"2020-11-12T15:30:35.643+02:00"},"s":"W", "c":"CONTROL", "id":20698, "ctx":"main","msg":"***** SERVER RESTARTED *****","tags":["startupWarnings"]}
{"t":{"$date":"2020-11-12T15:30:35.645+02:00"},"s":"I", "c":"CONTROL", "id":23285, "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2020-11-12T15:30:35.655+02:00"},"s":"W", "c":"ASIO", "id":22601, "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2020-11-12T15:30:35.655+02:00"},"s":"I", "c":"NETWORK", "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
{"t":{"$date":"2020-11-12T15:30:35.656+02:00"},"s":"I", "c":"STORAGE", "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":9759,"port":27017,"dbPath":"/var/lib/mongodb","architecture":"64-bit","host":"lubo"}}
{"t":{"$date":"2020-11-12T15:30:35.656+02:00"},"s":"I", "c":"CONTROL", "id":23403, "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.1","gitVersion":"ad91a93a5a31e175f5cbf8c69561e788bbc55ce1","openSSLVersion":"OpenSSL 1.1.1f 31 Mar 2020","modules":[],"allocator":"tcmalloc","environment":{"distmod":"ubuntu2004","distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2020-11-12T15:30:35.656+02:00"},"s":"I", "c":"CONTROL", "id":51765, "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Ubuntu","version":"20.04"}}}
{"t":{"$date":"2020-11-12T15:30:35.656+02:00"},"s":"I", "c":"CONTROL", "id":21951, "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"config":"/etc/mongod.conf","net":{"bindIp":"127.0.0.1","port":27017},"processManagement":{"timeZoneInfo":"/usr/share/zoneinfo"},"storage":{"dbPath":"/var/lib/mongodb","journal":{"enabled":true}},"systemLog":{"destination":"file","logAppend":true,"path":"/var/log/mongodb/mongod.log"}}}}
{"t":{"$date":"2020-11-12T15:30:35.657+02:00"},"s":"F", "c":"STORAGE", "id":50922, "ctx":"initandlisten","msg":"An incomplete repair has been detected! This is likely because a repair operation unexpectedly failed before completing. MongoDB will not start up again without --repair."}
{"t":{"$date":"2020-11-12T15:30:35.657+02:00"},"s":"F", "c":"-", "id":23091, "ctx":"initandlisten","msg":"Fatal assertion","attr":{"msgid":50922,"file":"src/mongo/db/storage/storage_engine_init.cpp","line":86}}
{"t":{"$date":"2020-11-12T15:30:35.657+02:00"},"s":"F", "c":"-", "id":23092, "ctx":"initandlisten","msg":"\n\n***aborting after fassert() failure\n\n"}
更新 ATM 我这次使用 Whosebug 的指南尝试了另一个重新安装:
- sudo apt-get install --reinstall mongodb (有错误 - 处理时遇到错误)
- sudo systemctl 守护进程重新加载
- sudo apt update/upgrate
- sudo apt 安装 mongodb (以下包已自动安装,不再需要)
- sudo apt autoremove
- sudo systemctl 状态 mongodb (主进程退出,code=exited,status=100/n/a)
- sudo mongo
MongoDB shell version v3.6.8
connecting to: mongodb://127.0.0.1:27017
Implicit session: session { "id" : UUID("667c92c8-0a10-4adb-bcf6-ba045f280034") }
MongoDB server version: 3.6.8
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
Server has startup warnings:
2020-11-12T17:33:37.780+0200 I STORAGE [initandlisten]
2020-11-12T17:33:37.780+0200 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2020-11-12T17:33:37.780+0200 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2020-11-12T17:33:38.722+0200 I CONTROL [initandlisten]
2020-11-12T17:33:38.722+0200 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-11-12T17:33:38.722+0200 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2020-11-12T17:33:38.722+0200 I CONTROL [initandlisten]
- sudo apt-get install libc6 (libc6已经是最新版本(2.31-0ubuntu9.1))
- sudo systemctl status mongod
mongod.service
Loaded: not-found (Reason: Unit mongod.service not found.)
Active: active (running) since Thu 2020-11-12 17:33:37 EET; 7min ago
Main PID: 16038 (mongod)
CGroup: /system.slice/mongod.service
└─16038 /usr/bin/mongod --config /etc/mongod.conf
ное 12 17:33:37 lubo systemd[1]: Started MongoDB Database Server.
ное 12 17:34:03 lubo systemd[1]: mongod.service: Current command vanished from the unit file, execution of the command list won't be resumed.
现在我相信我们已经在 mongod 工作了,只是为了将它与 mongod.service
联系起来- 首先删除 mongodb 的所有 PPA 存储库,然后:
- sudo apt-get purge mongodb-org*
- sudo apt 删除 mongodb
- sudo apt purge mongodb
- sudo apt autoremove
- sudo rm -r /var/log/mongodb
- sudo rm -r /var/lib/mongodb
- sudo apt-get 安装 gnupg
- wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
- echo "deb [arch=amd64,arm64] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 多元宇宙" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
- sudo apt-get 更新
- sudo apt-get 升级
- sudo apt 更新
- sudo apt 升级
- sudo apt-get install -y mongodb-org
- sudo apt-get 安装 libc6
- sudo 服务 mongod 启动
- sudo 服务 mongod 状态
这帮助我解决了这个问题
您收到此错误是因为您没有授予对 mongodb 的访问权限 您只需
sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chown mongodb:mongodb /tmp/mongodb-27017.sock
sudo service mongod restart
you can use this medium.com link,too.
现在喜欢与 mongodb
一起工作Mongodb server-4.4.asc 在某些机器上有 ubuntu 20.04 的错误。 我重试了几次,发现了“server-4.4.asc”上的错误。我建议安装“server-4.2.asc”(ver 4.2 可以,4.4 有错误)。
MongoDB 已包含在 Ubuntu 软件包存储库中,但官方 MongoDB 存储库提供最多 up-to-date 版本,是安装软件的推荐方式。在这一步中,我们将把这个官方存储库添加到我们的服务器。
Ubuntu 通过验证软件包是否使用 GPG 密钥签名来确保软件包的真实性,因此我们首先必须导入官方 MongoDB 存储库的密钥。
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
接下来,我们将添加 MongoDB 存储库详细信息,以便 apt 知道在哪里下载软件包。发出以下命令为 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-org meta-package,其中包括守护程序、配置和初始化脚本、shell 以及管理工具。
sudo apt-get install mongodb-org
:)