简体   繁体   English

在容器中恢复 Percona Xtradb

[英]Recover Percona Xtradb in container

I have Percona Xtradb Cluster running on container.我在容器上运行Percona Xtradb Cluster

I stopped the container and then started it.我停止了容器,然后启动了它。

I have error:我有错误:

2017-02-11T13:12:00.423566Z 0 [ERROR] Found 1 prepared transactions! 2017-02-11T13:12:00.423566Z 0 [错误] 发现 1 个准备好的交易! It means that mysqld was not shut down properly last time and critical recovery information (last binlog or tc.log file) was manually deleted after a crash.这意味着mysqld上次没有正确关闭,并且在崩溃后手动删除了关键恢复信息(最后一个binlog或tc.log文件)。 You have to start mysqld with --tc-heuristic-recover switch to commit or rollback pending transactions.您必须使用 --tc-heuristic-recover 开关启动 mysqld 才能提交或回滚挂起的事务。

2017-02-11T13:12:00.423739Z 0 [ERROR] Aborting 2017-02-11T13:12:00.423739Z 0 [错误] 中止

The message says that I need mysqld --tc-heuristic-recover but container stops after mysql fails to start.该消息说我需要mysqld --tc-heuristic-recover但容器在 mysql 无法启动后停止。

My questions are:我的问题是:

  • How can I fix this problem not to run new container but start existing one?如何解决此问题而不是run新容器而是start现有容器?

  • Is there any way to make Docker container still running after main process ( mysqld ) is stopped?有没有办法让 Docker 容器在主进程( mysqld )停止后仍然运行?

That container uses volumes (see here ), so your data is not inside the container.该容器使用卷(请参阅此处),因此您的数据不在容器内。

To find where it is stored, use docker container inspect YOUR_CONTAINER_NAME , and search for Mounts in the output.要找到它的存储位置,请使用docker container inspect YOUR_CONTAINER_NAME ,并在输出中搜索Mounts If you have jq installed you can use something like如果你安装了jq你可以使用类似的东西

$ docker container inspect YOUR_CONTAINER_NAME | jq ".[0].Mounts"

Once you found the directory where the data is stored, you should create a backup .找到存储数据的目录后,您应该创建一个备份

You can then create a new container, with a bind to that directory.然后,您可以创建一个新容器,并绑定到该目录。 Something like就像是

$ docker run -it -v VOLUME_PATH:/var/lib/mysql OTHER_OPTIONS_HERE image_name /bin/sh

This should give you a shell where you can execute any commands you may need.这应该为您提供一个 shell,您可以在其中执行您可能需要的任何命令。

Once you finished, you can delete this container, and hopefully the percona one should now work.完成后,您可以删除这个容器,希望 percona 现在应该可以工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM