Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of failed recovery of Mysql Container startup

2025-03-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the Mysql container startup failure recovery example analysis, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to know it.

Recovery case of Mysql Container start failure

After rebooting NAS yesterday, I found that NAS crashed again this morning. It can only be forced to shut down and restart again.

Before starting the docker container, I adjusted the memory of the mysql container to 512m. And then the tragic discovery won't start. Later, I found that it was not because I adjusted the memory that I could not start.

View the log and display it as follows:

2020-12-27T02:43:53.375776Z 0 mysqld: [Warning] World-writable config file'/ etc/mysql/my.cnf' is ignored.

2020-12-27T02:43:53.375776Z 0 mysqld: Error on realpath () on'/ var/lib/mysql-files' (Error 2-No such file or directory)

2020-12-27T02:43:53.375776Z 0 [ERROR] [MY-010095] [Server] Failed to access directory for-- secure-file-priv. Please make sure that directory exists and is accessible by MySQL Server. Supplied value: / var/lib/mysql-files

2020-12-27T02:43:53.376005Z 0 [ERROR] [MY-010119] [Server] Aborting

Baidu decided that the solution is to re-run a mysql container and add-v / mnt/md0/User/wzp/home/www/mysql-files:/var/lib/mysql-files/ to the previous configuration.

Now here's the problem. I didn't record the full run command when I was in the run mysql container. Fortunately, you can see it through the rekcod tool. What's more, the tool can be run through docker. Because my NAS system is not a distributed version of linux,npm,yum, many tools cannot be installed.

About the use of rekcod, please refer to linuxea: how to reproduce the command to view docker run parameters.

In short, the usage is as follows:

1 docker install rekcod

$docker pull nexdrew/rekcod$ alias rekcod= "docker run-- rm-v / var/run/docker.sock:/var/run/docker.sock nexdrew/rekcod"

2 usage:

[root@TNAS-012664 ~] # rekcod mysql = = > mysql is my container name docker run-- name mysql-- runtime runc-v / mnt/md0/User/wzp/home/www/mysql/:/var/lib/mysql-p 3306:3306/tcp-- net bridge-- restart no-h 39964e9e508a-- expose 3306/tcp-- expose 33060/tcp-e 'MYSQL_ROOT_PASSWORD=123456'-e' PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin: / sbin:/bin'-e 'GOSU_VERSION=1.12'-e' MYSQL_MAJOR=5.7'-e 'MYSQL_VERSION=5.7.30-1Debian 10'-d-t-I-- entrypoint "docker-entrypoint.sh" mysql' mysqld'

You can see that my database files are all in the / mnt/md0/User/wzp/home/www/mysql/ directory. I checked the directory files, and the data should not be lost.

So, I created a new mysql2 container with the following command

Docker run-d-p 3306 docker run-e MYSQL_ROOT_PASSWORD=123456-- name mysql2-v / mnt/md0/User/wzp/home/www/mysql/:/var/lib/mysql-v / mnt/md0/User/wzp/home/www/mysql-files:/var/lib/mysql-files/ mysql

Then, I went to mysql2 and found that I couldn't connect to the database.

Docker exec-it mysql2 / bin/bash

View mysql status

Root@0e83698acbfb:/# mysqld statusmysqld: [Warning] World-writable config file'/ etc/mysql/conf.d/docker.cnf' is ignored.mysqld: [Warning] World-writable config file'/ etc/mysql/conf.d/mysql.cnf' is ignored.2020-12-27T02:39:41.865252Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using-skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.2020-12-27T02:39:41.865455Z 0 [System] [MY-010116] [Server] / usr/sbin/mysqld (mysqld 8.0.20) starting as process 1052020-12-27T02:39:41.871715Z 0 [ERROR] [MY-010123] [Server] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as rootstocks 2020-12-27T02:39:41.872541Z 0 [ERROR] [MY-010119] [Server] Aborting2020-12-27T02:39:41.872776Z 0 [System] [MY-010910] [Server] / usr/sbin/mysqld: Shutdown complete (mysqld 8.0.20) MySQL Community Server-GPL.root@0e83698acbfb:/# Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root! ^ C

Start mysqld in root mode using the following methods

Root@0e83698acbfb:/# mysqld-- user=rootmysqld: [Warning] World-writable config file'/ etc/mysql/conf.d/docker.cnf' is ignored.mysqld: [Warning] World-writable config file'/ etc/mysql/conf.d/mysql.cnf' is ignored.2020-12-27T02:40:57.169719Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using-- skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.2020-12-27T02:40:57.169896Z 0 [System] [MY-010116] [Server] / usr/sbin/mysqld (mysqld 8.0.20) starting as process 1162020-12-27T02:40:57.184807Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.2020-12-27T02:40:57.241048Z 1 [ERROR] [MY-012574] [InnoDB] Unable to lock . / ibdata1 error: 112020-12-27T02:40:58.241783Z 1 [ERROR] [MY-012574] [InnoDB] Unable to lock. / ibdata1 error: 112020-12-27T02:40:59.242983Z 1 [ERROR] [MY-012574] [InnoDB] Unable to lock. / ibdata1 error: 112020-12-27T02:41:00.244290Z 1 [ERROR] [InnoDB] Unable to lock. / ibdata1 error: 112020-12-27T02:41:01.245762Z 1 [ERROR] [MY-012574] [InnoDB] Unable to lock. / ibdata1 error: 112020-12-27T02:41:02.247539Z 1 [ERROR] [MY-012574] [InnoDB] Unable to lock. / ibdata1 error: 11

Unable to lock. / ibdata1 error: 11 has been printed on the screen, and can only be forced to interrupt by CTRL-C. Baidu has two ways to solve the problem.

1 refer to [ERROR] InnoDB of mysql: Unable to lock. / ibdata1, error: 11

According to the analysis of this article, there are two main reasons for the error. Unfortunately, the methods in the article can not solve my problem.

Insufficient disk space directory

Ibdata1 files are occupied by other processes

2 refer to the mysqld newspaper InnoDB: Unable to lock. / ibdata1 error: 11 this article solved my problem perfectly. The following operations are mainly carried out.

2.1 first, go to the directory where my mysql database is located

Cd / mnt/md0/User/wzp/home/www/mysql

2.2 then rename ibdata1 and other files, and then cp back. I don't quite understand exactly why I did it.

[root@TNAS-012664 www] # cd / mnt/md0/User/wzp/home/www/mysql/ [root @ TNAS-012664 mysql] # ls auto.cnf binlog.index client-key.pem dci'# ib_16384_0.dblwr' ib_logfile0 mautic nianbao performance_schema robot shangbiao undo_001 zeng baike ca-key .pem company_works dianzicaipiao'# ib_16384_1.dblwr' ib_logfile1 mysql niuwan private_key.pem sara_wiki sjzt_ry6 undo_002 bigdatapaltfrom ca.pem copyrightdata gs_data ib_buffer_pool'# innodb_temp' mysql.ibd pachong public_key.pem server-cert.pem Sys wenshu binlog.000001 client-cert.pem db_huayun hy_dci_admin ibdata1 integrate mysql_upgrade_info pachong2 qianliu_wiki server-key.pem ucenter_huayunyy yuanqixiaoshuo [root @ TNAS-012664 mysql] # mv ibdata1 ibdata1.bak [root @ TNAS-012664 mysql] # mv ib_logfile0 ib_ logfile0.bak [root @ TNAS-012664 mysql] # mv ib_logfile1 ib_logfile1.bak [root@TNAS-012664 mysql] # cp-an ibdata1.bak ibdata1 [root @ TNAS-012664 mysql] # cp-an ib_logfile0.bak ib_ logfile0 [root @ TNAS-012664 mysql] # cp-an ib_logfile1.bak ib_logfile1

Then I delete the previous mysql2 container, run a mysql2 container again with the following command, and find that I can connect to the mysql database.

[root@TNAS-012664] # docker run-d-p 3306 MYSQL_ROOT_PASSWORD=123456-- name mysql2-v / mnt/md0/User/wzp/home/www/mysql/:/var/lib/mysql-v / mnt/md0/User/wzp/home/www/mysql-files:/var/lib/mysql-files/ mysql1e031247ea46e82f6205db68e7fb1b55389c87e5e2cb13517f9e1ac17d514509 [root @ TNAS-012664 ~] # docker exec-it mysql2 / bin/bashroot@1e031247ea46:/# mysql- uroot-pmysql: [Warning] World -writable config file'/ etc/mysql/my.cnf' is ignored.Enter password:Welcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 8Server version: 8.0.20 MySQL Community Server-GPLCopyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.mysql > show databases

Think everything will be all right when the mysql container is ready? No,too naive! There's a little episode waiting for me. As soon as I solved the mysql container here, I suddenly found that my wiki container was inexplicably gone. Fortunately, the database files are there, and everything can be restored as before.

1 create two new wiki with the following command

Docker run-- name sarawiki-- link mysql2:mysql-p 8086 sarawang85/mediawiki:1.0.0docker run 80-d sarawang85/mediawiki:1.0.0docker run-- name qianliuwiki-- link mysql2:mysql-p 8083 VR 80-d sarawang85/mediawiki:1.0.0

2 then copy the backed-up LocalSettings.php files and Logo images into the container and get it done.

PS, if you edit a container of stop status in the docker gui interface, such as setting a memory limit, it will actually create a new container with the same name. Because after I found out that I had done this, I visited my wiki and prompted me to reinstall it.

Another PS,mysql backup must be put on the schedule immediately. Mysql memory limits cannot be limited by containers alone, and my.cnf has to respond to changes.

Thank you for reading this article carefully. I hope the article "sample Analysis of Mysql Container start failure recovery" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report