Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongodb:ACCESS [main] error opening file: /mongo/key.txt: bad file

Tags:

mongodb

  1. Generated the key.txt

openssl rand -base64 666 > /mongo/key.txt chmod 600 /mongo/key.txt

  1. Command

--keyFile=/mongo/key.txt --replSet=MONGO_EDU_SET --dbpath=/mongo/data --logpath=/mongo/logs/a.log --logappend

2019-09-05T07:01:23.625+0000 I  ACCESS   [main] error opening file: /mongo/key.txt: bad file

enter image description here

like image 766
Jo.gel Avatar asked Mar 04 '23 11:03

Jo.gel


1 Answers

Check the owner and attributes of /mongo/key.txt in container. It must be like this:

root@243810c57e61:/# ll /etc/mongo/replkey 
-r-------- 1 mongodb root 1024 Sep 27 12:19 /etc/mongo/replkey
like image 117
Фёдор Пашнин Avatar answered Mar 07 '23 00:03

Фёдор Пашнин