mysql host_cache表为空

前段时间有台应服务器报错:Host '192.168.210.79' is blocked because of many connection errors; unblock with 'mysqladmin flush-h

当时已经查到原因是网络原因导致该ip访问数据库被阻塞,多次失败,该ip被mysql屏蔽。使用flush hosts命令清空hosts缓存后,连接恢复正常。此时可以查看:select * from performance_schema.host_cache;查看错误信息。

这几天又遇到这个问题,根据之前的经验先查看host_cache表发现为空。奇怪,按理说应有记录的。

查看官方文档介绍:
The host_cache table provides access to the contents of the host cache, which contains client host name and IP address information and is used to avoid DNS lookups. The host_cache table exposes the contents of the host cache so that it can be examined using SELECT statements. This may help you diagnose the causes of connection problems. The Performance Schema must be enabled or this table is

host_cache表提供对主机缓存内容的访问,其中包含客户机主机名和IP地址信息,用于避免DNS查找。host_cache表公开了主机缓存的内容,以便可以使用SELECT语句检查它。这可以帮助您诊断连接问题的原因。必须启用性能模式,否则此表为空。


可以看到,必须启用性能模式...
MariaDB [(none)]> show variables like 'performance_schema';
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| performance_schema | OFF   |
+--------------------+-------+
1 row in set (0.00 sec)

关闭着的。

在查看MYSQL官方文档:
performance_schema

Property    Value
Command-Line Format    --performance-schema=#
System Variable    performance_schema
Scope    Global
Dynamic    No
SET_VAR Hint Applies    No
Type    Boolean
Default Value    ON


查看MARIADB官方文档:
performance_schema

Description: If set to 1 (0 is default), enables the Performance Schema
Commandline: --performance-schema=#
Scope: Global
Dynamic: No
Data Type: boolean
Default Value: OFF (>= MariaDB 10.0.12), ON (<= MariaDB 10.0.11)
Introduced: MariaDB 5.5

官方mysql的各个版本performance_schema默认是开启的,但是MariaDB 10.0.12及之后的版本默认是关闭的。

 

查看本机的mariadb版本:

MariaDB [(none)]> select version();
+-----------------------+
| version()             |
+-----------------------+
| 10.0.24-MariaDB-wsrep |
+-----------------------+
1 row in set (0.00 sec)

悲催,参数文件里加上performance_schema=1重启生效。
另外如果想跳过主机解析,可以加参数skip-name-resolve,这样不会再出现这种连接错误。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值