k8s 部署 mysql 故障恢复记录

embedded/2024/10/23 5:31:00/

k8s 集群 用 helm 部署 mariadb (https://charts.bitnami.com/bitnami)

https://github.com/bitnami/charts/tree/main/bitnami/mariadb

采用了主从部署

default   mariadb-primary-0    1/1  Running   0   10m   10.224.166.150   node1
default   mariadb-secondary-0  1/1  Running   1   13d   10.224.104.26    node2

由于一次机房停电,导致磁盘文件异常。primary 启动不了

mariadb 06:32:07.66 Welcome to the Bitnami mariadb container
mariadb 06:32:07.67 Subscribe to project updates by watching https://github.com/bitnami/containers
mariadb 06:32:07.68 Submit issues and feature requests at https://github.com/bitnami/containers/issues
mariadb 06:32:07.68
mariadb 06:32:07.69 INFO  ==> ** Starting MariaDB setup **
mariadb 06:32:07.73 INFO  ==> Validating settings in MYSQL_*/MARIADB_* env vars
mariadb 06:32:07.74 INFO  ==> Initializing mariadb database
mariadb 06:32:07.80 WARN  ==> The mariadb configuration file '/opt/bitnami/mariadb/conf/my.cnf' is not writable. Configurations based on environment variables will not be applied for this file.
mariadb 06:32:07.81 INFO  ==> Using persisted data
mariadb 06:32:07.89 INFO  ==> Running mysql_upgrade
mariadb 06:32:07.92 INFO  ==> Starting mariadb in background
2024-10-22  6:32:07 0 [Note] Starting MariaDB 10.6.12-MariaDB-log source revision 4c79e15cc3716f69c044d4287ad2160da8101cdc as process 52
2024-10-22  6:32:07 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2024-10-22  6:32:07 0 [Note] InnoDB: Using transactional memory
2024-10-22  6:32:07 0 [Note] InnoDB: Number of pools: 1
2024-10-22  6:32:07 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2024-10-22  6:32:07 0 [Note] mysqld: O_TMPFILE is not supported on /opt/bitnami/mariadb/tmp (disabling future attempts)
2024-10-22  6:32:07 0 [Note] InnoDB: Using Linux native AIO
2024-10-22  6:32:07 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
2024-10-22  6:32:08 0 [Note] InnoDB: Completed initialization of buffer pool
2024-10-22  6:32:08 0 [Note] InnoDB: 128 rollback segments are active.
2024-10-22  6:32:08 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2024-10-22  6:32:08 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2024-10-22  6:32:08 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2024-10-22  6:32:08 0 [Note] InnoDB: 10.6.12 started; log sequence number 16872896567; transaction id 46736708
2024-10-22  6:32:08 0 [Note] InnoDB: Loading buffer pool(s) from /bitnami/mariadb/data/ib_buffer_pool
2024-10-22  6:32:08 0 [Note] Plugin 'FEEDBACK' is disabled.
2024-10-22  6:32:08 0 [Note] Server socket created on IP: '127.0.0.1'.
2024-10-22  6:32:08 0 [Note] Zerofilling moved table:  './mysql/db'
2024-10-22  6:32:08 0 [ERROR] mysql.db: Page      8192:  Got error: 175 when reading datafile
2024-10-22  6:32:08 0 [Warning] Checking table:   './mysql/db'
2024-10-22  6:32:08 0 [ERROR] mysql.db: Table is probably from another system and must be zerofilled or repaired ('REPAIR TABLE table_name') to be usable on this system
2024-10-22  6:32:08 0 [Warning] Recovering table: './mysql/db'
2024-10-22  6:32:08 0 [Note] mysql.db: Running zerofill on moved table
2024-10-22  6:32:08 0 [ERROR] mysql.db: Page      8192:  Got error: 175 when reading datafile
2024-10-22  6:32:08 0 [ERROR] Couldn't repair table: mysql.db
2024-10-22  6:32:08 0 [ERROR] Fatal error: Can't open and lock privilege tables: Index for table 'db' is corrupt; try to repair it
2024-10-22  6:32:08 0 [ERROR] Aborting
Warning: Memory not freed: 280

解决过程

尝试 innodb_force_recovery 方案,无效。

修改 mysql.cnf ,添加配置,启动失败
kubectl edit cm -n ds-system aicore-mariadb-primary
> innodb_force_recovery=6
> innodb_purge_thread=1

异常文件恢复方案

由于从节点的实例正常,检查两边文件

[root@node1 mysql]# ll /data/k8s/mysql-master/data/mysql/db*
-rw-rw---- 1 elastic elastic  3446 May 11 09:20 db.frm
-rw-rw---- 1 elastic elastic  8192 Oct  9 09:19 db.MAD
-rw-rw---- 1 elastic elastic  8192 Oct  9 09:09 db.MAD-241009011242.BAK
-rw-rw---- 1 elastic elastic 16384 Oct 22 15:42 db.MAI
-rw-rw---- 1 elastic elastic    67 May 11 09:20 db.opt[root@node2 ~]# ls /data/k8s/mysql-secondary/data/mysql -l
-rw-rw---- 1 elastic elastic     3446 May 11 09:20 db.frm
-rw-rw---- 1 elastic elastic    16384 Oct  1 10:40 db.MAD
-rw-rw---- 1 elastic elastic    24576 Oct  1 10:40 db.MAI
-rw-rw---- 1 elastic elastic       67 May 11 09:20 db.opt

mariadb-primary 的 db.MAD 比 aicore-mariadb-secondary 的文件大小差异很大,把从节点的db表文件全部复制过来

 scp node2:/data/k8s/mysql-secondary/data/mysql/db* /data/k8s/mysql-master/data/mysql/

重启 mariadb-primary 后成功


http://www.ppmy.cn/embedded/129741.html

相关文章

习题|曲线平面曲线

目录 T1T2T3 T1 (1)设 E 3 E^3 E3中曲线 C C C的所有切线过一个定点,证明 C C C是直线. (2) 证明:所有主法线过定点的曲线是圆. 证明:(1) 设 P 0 P_0 P0​是弧长参数曲线 C : r r ( s ) C:\mathbf{r}\mathbf{r}(s) C:rr(s)的切线所过的定点…

ChatGLM-6B和Prompt搭建专业领域知识问答机器人应用方案(含完整代码)

目录 ChatGLM-6B部署 领域知识数据准备 领域知识数据读取 知识相关性匹配 Prompt提示工程 领域知识问答 完整代码 本文基于ChatGLM-6B大模型和Pompt提示工程搭建医疗领域知识问答机器人为例。 ChatGLM-6B部署 首先需要部署好ChatGLM-6B,参考 ChatGLM-6B中英双…

T2彩色图片分类

导入 keras中的数据集。 datasets是数据集,用来加载tensorflow的一些数据集 layers:kersa中的核心模块,用来构建神经网络模型的各种层 models:用来管理模型的模块。这边数据集的导出花了好长的时间。中间断了一下,后来无法找到文件,去了数据…

【p2p、分布式,区块链笔记 UPNP】: 简单服务发现协议 SSDP

在设备加入网络,UPnP发现协议允许设备向控制点广告它的服务。它使用向一个标准地址和端口多址传送发现消息来实现。控制点在此端口上侦听是否有新服务加入系统。为了通知所有设备,一个设备为每个其上的嵌入设备和服务发送一系列相应的发现消息。每个消息…

中小型医院网站:Spring Boot技术栈

3 系统分析 3.1 可行性分析 通过对本基于Spring Boot的中小型医院网站实行的目的初步调查和分析,提出可行性方案并对其一一进行论证。我们在这里主要从技术可行性、操作可行性、经济可行性和时间可行性四方面进行分析。 3.1.1 技术可行性 本基于Spring Boot的中小型…

C++模拟算法

模拟 模拟算法通过模拟实际情况来解决问题,一般容易理解但是实现起来比较复杂,有很多需要注意的细节,或者是一些所谓很“麻烦”的东西。模拟题一般不涉及太难的算法,一般就是由较多的简单但是不好处理的部分组成的,考…

【C++刷题】力扣-#243-最短单词距离

题目描述 给定一个单词列表 words 和两个单词 word1 和 word2,返回这两个单词在列表中的最短距离。如果 word1 和 word2 是同一个单词,则返回它与自身的最近距离。 示例 示例 1: 输入: words ["practice", "makes", "perfec…

Java学习Day50:唤醒八戒(Excel相关)

1.批量导入Excel数据 1.实现模板下载 <el-card class"box-card"> <div class"boxMain"> <el-button style"margin-bottom: 20px;margin-right: 20px" type"primary" click"downloadTemplate()">模板下载…