0

MongoDB 版本:4.2.16
问题:在 Docker 中启动 MongoDB 容器,可以查询和插入数据,但是在创建用户时报错网络异常。

(不知道为什么上传图片失败了,贴上操作过程和异常信息吧)

[root@red-test logs]# mongosh
Current Mongosh Log ID: 6184c96c44e2cb315e73bd63
Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000
Using MongoDB: 4.2.16
Using Mongosh: 1.1.0

For mongosh info see: https://docs.mongodb.com/mongodb-shell/

——
The server generated these startup warnings when booting:
2021-11-05T13:53:03.250+0800:
2021-11-05T13:53:03.251+0800: ** WARNING: Access control is not enabled for the database.
2021-11-05T13:53:03.251+0800: ** Read and write access to data and configuration is unrestricted.
2021-11-05T13:53:03.251+0800:
2021-11-05T13:53:03.251+0800:
2021-11-05T13:53:03.251+0800: ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always’.
2021-11-05T13:53:03.251+0800: ** We suggest setting it to ‘never’
2021-11-05T13:53:03.251+0800:
2021-11-05T13:53:03.251+0800: ** WARNING: soft rlimits too low. The locked memory size is 128 bytes, it should be at least 65536 bytes
2021-11-05T13:53:03.251+0800:
——

test> use admin
switched to db admin
admin> db.createUser({user: ‘admin’,pwd: ‘Aa123456’,roles: [ { role: “userAdminAnyDatabase”, db: “admin” } ]})
MongoNetworkError: connection 4 to 127.0.0.1:27017 closed
admin>

更改状态以发布