编辑mongo.conf后MongoDB状态失败(代码退出,状态=2)
我正在尝试远程连接到我的谷歌云服务器,也可以连接,这样我就可以从windows查看数据 我正在运行Ubuntu18.04LTS Minimal。为了启用到MongoDB的远程连接,我首先在管理数据库中创建了一个管理用户和根用户 我的问题是,一旦我在编辑mongo.conf后MongoDB状态失败(代码退出,状态=2),mongodb,Mongodb,我正在尝试远程连接到我的谷歌云服务器,也可以连接,这样我就可以从windows查看数据 我正在运行Ubuntu18.04LTS Minimal。为了启用到MongoDB的远程连接,我首先在管理数据库中创建了一个管理用户和根用户 我的问题是,一旦我在/etc/mongod.conf中将授权:“enabled”添加到安全:,并重新启动MongoDB,我在运行$:systemctl status mongod ● mongod.service - MongoDB Database Server
/etc/mongod.conf
中将授权:“enabled”
添加到安全:
,并重新启动MongoDB,我在运行$:systemctl status mongod
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2019-08-06 16:43:51 BST; 1min 20s ago
Docs: https://docs.mongodb.org/manual
Process: 6517 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=2)
Main PID: 6517 (code=exited, status=2)
Aug 06 16:43:51 instance-1 systemd[1]: Started MongoDB Database Server.
Aug 06 16:43:51 instance-1 mongod[6517]: Unrecognized option: processManagement.authorization
Aug 06 16:43:51 instance-1 mongod[6517]: try '/usr/bin/mongod --help' for more information
Aug 06 16:43:51 instance-1 systemd[1]: mongod.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Aug 06 16:43:51 instance-1 systemd[1]: mongod.service: Failed with result 'exit-code'.
/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:
authorization: "enabled"
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
/etc/mongod.conf
中似乎有一个无效参数,但从我在线阅读的内容来看,我看不出问题所在。对于4.x版本,您似乎需要修改您列出的现有安全部分
#security:
authorization: "enabled"
并将其替换为安全性。授权:已启用
或
security:
authorization: "enabled"
然后,您应该能够重新加载并测试身份验证是否按预期工作
如果你深入研究这些文档,你会发现相关的部分
安全授权
Type: string
Default: disabled
Enable or disable Role-Based Access Control (RBAC) to govern each user’s access to database resources and operations.
Set this option to one of the following:
Value Description
enabled A user can access only the database resources and actions for which they have been granted privileges.
disabled A user can access any database and perform any action.
错:
正确:
security:
authorization: enabled
在我的例子中,问题是我使用了一个选项卡缩进authorization:enabled
行。当我将选项卡替换为2个空格时,它工作了。您可以在sudo nano/etc/mongod.conf更改安全设置,对于版本4及更高版本,它是安全的。授权:启用谢谢。这正是我的问题所在我也有同样的问题。我花了1小时付账
security:
authorization: enabled