【发布时间】:2021-03-06 19:24:13
【问题描述】:
我在 docker 容器中运行 mongodb,并且我有数据文件备份。
但今天我不小心删除了我的mongodb。
我尝试运行另一个容器并将数据文件放入容器中,但它不起作用。
如何从数据文件中恢复我的数据?
我使用的容器是tutum/mongodb。我的docker-compose.yml文件是
mongo_db:
image: tutum/mongodb
privileged: true
restart: always
ports:
- 27016:27017
- 28016:28017
volumes:
- /var/mongodb:/data/db
environment:
- MONGODB_PASS=xxxxxx
- AUTH=yes
现在我想将我的数据从目录 /var/mongodb 恢复到我的新容器
我将 mongod.lock 以外的文件放入新容器中,但我的 mongodb 无法运行。 这是屏幕截图:
mongod.conf 是:
# Where to store the data.
# Note: if you run mongodb as a non-root user (recommended) you may
# need to create and set permissions for this directory manually,
# e.g., if the parent directory isn't mutable by the mongodb user.
dbpath=/var/lib/mongodb
#where to log
logpath=/var/log/mongodb/mongod.log
logappend=true
#port = 27017
# Listen to local interface only. Comment out to listen on all interfaces.
bind_ip = 127.0.0.1
# Disables write-ahead journaling
# nojournal = true
# Enables periodic logging of CPU utilization and I/O wait
#cpu = true
# Turn on/off security. Off is currently the default
#noauth = true
#auth = true
# Verbose logging output.
#verbose = true
# Inspect all client data for validity on receipt (useful for
# developing drivers)
#objcheck = true
# Enable db quota management
#quota = true
# Set oplogging level where n is
# 0=off (default)
# 1=W
# 2=R
# 3=both
# 7=W+some reads
#diaglog = 0
# Ignore query hints
#nohints = true
# Enable the HTTP interface (Defaults to port 28017).
#httpinterface = true
# Turns off server-side scripting. This will result in greatly limited
# functionality
#noscripting = true
# Turns off table scans. Any query that would do a table scan fails.
#notablescan = true
# Disable data file preallocation.
#noprealloc = true
# Specify .ns file size for new databases.
# nssize = <size>
# Replication Options
# in replicated mongo databases, specify the replica set name here
#replSet=setname
# maximum size in megabytes for replication operation log
#oplogSize=1024
# path to a key file storing authentication info for connections
# between replica set members
#keyFile=/path/to/keyfile
容器开始运行时容器在 env 中设置了 STORAGE_ENGINE 容器的环境是:
# mongod.conf
STORAGE_ENGINE=wiredTiger
HOSTNAME=bb544551ec2b
MONGODB_PASS=xxxxxx
LS_COLORS=
AUTH=yes
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/etc
SHLVL=1
HOME=/root
LESSOPEN=| /usr/bin/lesspipe %s
JOURNALING=yes
LESSCLOSE=/usr/bin/lesspipe %s %s
_=/usr/bin/env
OLDPWD=/
tutum/mongodb:3.0下的日志:
【问题讨论】:
-
你好王凯文;图片在帖子中很有用,但确保帖子在没有它们的情况下仍然清晰。您可以直接将相关信息复制并粘贴到帖子中,而不是显示终端的屏幕截图吗? cfmeta.stackoverflow.com/questions/303812/…