Mongodb:通过配置文件启动,报error opening file: /mongo/key: bad file

  1. 生成的keyFile 方式:
openssl rand -base64 666 > /mongo/key
chmod 600 /mongo/key
  1. 使用docker-compose 启动的,配置文件如下:

clipboard.png

3.报错如下:

clipboard.png

mongo_1  | 2019-09-05T06:31:41.432+0000 W  CONTROL  [main] Option: sslMode is deprecated. Please use tlsMode instead.
mongo_1  | about to fork child process, waiting until server is ready for connections.
mongo_1  | forked process: 27
mongo_1  | 2019-09-05T06:31:41.435+0000 I  CONTROL  [main] ***** SERVER RESTARTED *****
mongo_1  | 2019-09-05T06:31:41.440+0000 I  CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
mongo_1  | 2019-09-05T06:31:41.443+0000 I  ACCESS   [main] error opening file: /mongo/key: bad file
mongo_1  | ERROR: child process failed, exited with error number 1
mongo_1  | To see additional information in this output, start without the "--fork" option.
阅读 17.8k
4 个回答
新手上路,请多包涵

执行一下,

chown 999 /mongo/key

重启.

我将文件所有者修改为启动用户,并将文件的权限为400就可以了,可以采用ps aux | grep mongod 命令查看docker的启动mongo的用户,并将文件所有者修改即可

新手上路,请多包涵

我问一下 bad file的问题解决了吗

新手上路,请多包涵

RUN chown mongodb:mongodb /mongo/key
RUN chmod 600 /mongo/key

把keyFile的用户所属分配给mongodb, 权限调整为600

推荐问题
宣传栏