【mysql系】mysql读库报错Difficult to find free blocks in the buffer pool 异常

您所在的位置:网站首页 whoisthatlittleboy怎么读 【mysql系】mysql读库报错Difficult to find free blocks in the buffer pool 异常

【mysql系】mysql读库报错Difficult to find free blocks in the buffer pool 异常

#【mysql系】mysql读库报错Difficult to find free blocks in the buffer pool 异常| 来源: 网络整理| 查看: 265

2023-06-28T01:33:58.052190Z 6 [Warning] InnoDB: Difficult to find free blocks in the buffer pool (137555 search iterations)! 137555 failed attempts to flush a page! Consider increasing the buffer poo l size. It is also possible that in your Unix version fsync is very slow, or completely frozen inside the OS kernel. Then upgrading to a newer version of your operating system may help. Look at the n umber of fsyncs in diagnostic info below. Pending flushes (fsync) log: 0; buffer pool: 0. 47191415 OS file reads, 1205838 OS file writes, 459976 OS fsyncs. Starting InnoDB Monitor to print further di agnostics to the standard output. 2023-06-28T01:33:58.053203Z 0 [Warning] InnoDB: Difficult to find free blocks in the buffer pool (137565 search iterations)! 137565 failed attempts to flush a page! Consider increasing the buffer poo l size. It is also possible that in your Unix version fsync is very slow, or completely frozen inside the OS kernel. Then upgrading to a newer version of your operating system may help. Look at the n umber of fsyncs in diagnostic info below. Pending flushes (fsync) log: 0; buffer pool: 0. 47191415 OS file reads, 1205838 OS file writes, 459976 OS fsyncs. Starting InnoDB Monitor to print further di agnostics to the standard output.

看到上面的问题,中文简单翻译过来大概就是缓冲池没有空闲块,也有可能在你的 Unix 版本中 fsync 调用非常慢,可能需要升级操作系统版本

上面的错误日志在哪里我是怎么拿到的?

如果你的客户端能够连接上mysql服务,可以使用show VARIABLES like '%log_error%' 命令查看到对应的文件路径

如果连接不上请登录服务器找到对应的my.cnf配置文件(如何找到这个文件呢),如果my.cnf文件没有配置log_error的选项,那默认就是在数据目录下并且文件名字是主机名.err这个文件

看到这个意思,我立刻想到了mysql有个很重要的参数innodb_buffer_pool_size

我这边看到服务器my.cnf 文件没有对该参数选项设置 那么默认就是参数值128M,这个参数值太小了,生产环境我们肯定是需要调整的

那这个参数设置多大呢?这里强调下,我这边使用的mysql版本是5.7.29

 这个是我本地windows安装的mysql对应配置选项的一段描述

 大概就是说与 MyISAM 不同, InnoDB 使用缓冲池来缓存索引和行数据。设置的值越大,用于 访问表中数据的磁盘 I/O 就越少。在专用的数据库服务器上,可以将此参数设置为计算机物理内存大小的80% 。但是,不要将它设置为太大,因为物理内存的竞争可能导致操作系统中的分页。

另外还有个参数innodb_buffer_pool_instances 查看到配置的值为1,这个也适当需要调整

 InnoDB 缓冲池划分的区域数(实例数量)。对于缓冲池在几 GB 范围内的系统,将缓冲池划分为单独的实例可以提高并发, 通过减少不同线程读写缓存页面时的争用

那这两个参数到底怎么理解呢

假设你有一个数据库服务器,其中运行着一个基于InnoDB引擎的应用程序。现在让我们来看看这两个参数的含义: 

 innodb_buffer_pool_size:假设你将innodb_buffer_pool_size设置为2GB。这意味着你为InnoDB引擎分配了2GB的内存作为缓冲池。当应用程序需要读取或写入数据时,InnoDB会尝试将这些数据页缓存在这个内存区域中。如果你的应用程序有大量的读取操作,增加innodb_buffer_pool_size的值可以提高性能,因为更多的数据可以在内存中缓存,减少了从磁盘读取的次数。  innodb_buffer_pool_instances:假设你将innodb_buffer_pool_instances设置为4。这意味着你将InnoDB缓冲池分成了4个实例。每个实例管理自己的缓冲池部分。例如,如果你的服务器有8个CPU核心,你可以将缓冲池分成4个实例,每个实例管理2个CPU核心。这样做可以提高并发性,减少在高负载情况下的争用,因为不同的实例可以并行地处理读写请求。 



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3