The BLACKHOLE storage engine acts as a“black hole”that accepts data but throws it away and does not store it. Retrievals always return an empty result:和其 blackhole 名字的含义一样,该存储引擎会将所有接收到的数据”吞没“,在本地不会保存所接收到的数据。所以当然也无法从对应的表中回去到相应的结果集。

mysql> CREATE TABLE test(i INT, c CHAR(10)) ENGINE = BLACKHOLE;

Query OK, 0 rows affected (0.03 sec)

mysql> INSERT INTO test VALUES(1,'record one'),(2,'record two');

Query OK, 2 rows affected (0.00 sec)

Records: 2 Duplicates: 0 Warnings: 0

mysql> SELECT * FROM test;

Empty set (0.00 sec)

To enable the BLACKHOLE storage engine if you build MySQL from source, invokeCMakewith the-DWITH_BLACKHOLE_STORAGE_ENGINEoption.

编译阶段使能 BLACKHOLE 存储引擎。

To examine the source for the BLACKHOLE engine, look in the sql directory of a MySQL source distribution.

源文件查看。

When you create a BLACKHOLE table, the server creates a table format file in the database directory. The file begins with the table name and has an .frm extension. There are no other files associated with the table.

创建 BLACKHOLE 表会产生相应的表格式文件:.frm。并且仅会产生该文件。

The BLACKHOLE storage engine supports all kinds of indexes. That is, you can include index declarations in the table definition.

BLACKHOLE 存储引擎吃吃各种类型索引。

You can check whether the BLACKHOLE storage engine is available with theSHOW ENGINESstatement.

通过mysql命令行查看是否可以使用 BLACKHOLE 存储引擎创建表。

Inserts into a BLACKHOLE table do not store any data, but if statement based binary logging is enabled, the SQL statements are logged and replicated to slave servers. This can be useful as a repeater or filter mechanism.

向 BLACKHOLE 表中 insert 数据时,实际不会存储到表中,但在使能了基于语句的 binlog 时,会记录下 SQL 语句,并可用于 slave 复制。这也就是 BLACKHOLE 会被用作复制结构中 中继器 或 过滤机制 的原因。

Note

When using the row based format for the binary log, updates and deletes are skipped, and neither logged nor applied. For this reason, you should use STATEMENT for the binary logging format, and not ROW or MIXED.

注意:在使用基于行的 binlog 时,update 和 delete 会被忽略,既不会被记录到log中也不会被真正执行。基于这个原因,应该使用基于语句的 binlog 而不是基于行或者混合模式的 binlog 。

Suppose that your application requires slave-side filtering rules, but transferring all binary log data to the slave first results in too much traffic. In such a case, it is possible to set up on the master host a“dummy”slave process whose default storage engine is BLACKHOLE, depicted as follows:

在考虑 slave 侧需要过滤功能的应用场景时,如果将完整 binlog 传输到 slave 的代价是非常大的,则可以在 master 服务器上建立一个 使用 BLACKEHOLE 存储引擎的”dummy“ slave 进程,如下图:

The master writes to its binary log. The“dummy”mysqldprocess acts as a slave, applying the desired combination of replicate-do-* and replicate-ignore-* rules, and writes a new, filtered binary log of its own. (SeeSection 16.1.4, “Replication and Binary Logging Options and Variables”.) This filtered log is provided to the slave.

master 会写自己的 binlog 文件,而”dummy“ mysqld 进程扮演了 slave 的角色,根据配置的 replicate-do-* 和 replicate-ignore-* 规则,记录被自身过滤后的 binlog 日志。而这个 binlog 日志就可以作为其他真正 slave 进行复制的源。

The dummy process does not actually store any data, so there is little processing overhead incurred by running the additionalmysqldprocess on the replication master host. This type of setup can be repeated with additional replication slaves.

由于 dummy 进程实际上没有存储任何数据,所以几乎不会为 master 主机带来额外开销。

INSERTtriggers for BLACKHOLE tables work as expected. However, because the BLACKHOLE table does not actually store any data,UPDATEandDELETEtriggers are not activated: The FOR EACH ROW clause in the trigger definition does not apply because there are no rows.

Other possible uses for the BLACKHOLE storage engine include:

Verification of dump file syntax.

Measurement of the overhead from binary logging, by comparing performance using BLACKHOLE with and without binary logging enabled.

BLACKHOLE is essentially a“no-op”storage engine, so it could be used for finding performance bottlenecks not related to the storage engine itself.

BLACKHOLE 的其他可能用途:

校验转储文件语法。

测量开启 binlog 日志所带来的额外开销。

查找和存储引擎无关的其他方面的性能瓶颈。

The BLACKHOLE engine is transaction-aware, in the sense that committed transactions are written to the binary log and rolled-back transactions are not.

mysql blackhole引擎_【原创】MySQL blackhole 存储引擎简记相关推荐

  1. mysql blackhole缺点_【MySql】 BlackHole :黑洞引擎-阿里云开发者社区

    BlackHole :黑洞引擎,写入的任何数据都会消失,用于记录binlog做复制的中继存储! 如何安装: 在安装MySQL时使用带有--with-blackhole-storage-engine选项 ...

  2. mysql存储base64位用什么类型_了解什么是存储引擎引发的MySQL面试3连问

    引言 1.什么是存储引擎? 2.你设计表时使用什么存储引擎? 3.不同存储引擎分别适用于哪些场景? (0)什么是存储引擎? 在数据库中存的就是一张张有着千丝万缕关系的表,所以表设计的好坏,将直接影响着 ...

  3. mysql1033错误存储引擎_【Mysql问题集锦(1)】mysql不能使用innodb存储引擎

    案例: 一台服务器,操作系统centos,使用 yum 安装mysql ,之前innodb存储引擎一直是可以用的,某天之后,突然不能用了,使用innodb存储引擎的数据库导入后存储引擎全部变成了myi ...

  4. 超详细图解!【MySQL进阶篇】SQL优化-索引-存储引擎

    1. Mysql的体系结构概览 整个MySQL Server由以下组成 Connection Pool : 连接池组件 Management Services & Utilities : 管理 ...

  5. mysql数据库应用模式与特点_MySQL存储引擎的实际应用以及对MySQL数据库中各主要存储引擎的独特特点的描述...

    MySQL存储引擎的实际应用以及对MySQL数据库中各主要存储引擎的独特特点的描述: 1.MySQL有多种存储引擎: MyISAM.InnoDB.MERGE.MEMORY(HEAP).BDB(Berk ...

  6. MySQL存储引擎 lnnoDB逻辑架构 innodb存储引擎表空间(ibd文件)详解 回滚日志的物理空间

    文章目录 存储引擎 一 MySQL组织架构 二 查看存储引擎信息 三 修改存储引擎 3.1 配置文件修改存储引擎 3.2 临时修改存储引擎 3.3 建表时修改存储引擎 四 存储引擎实验 五 数据库升级 ...

  7. mysql数据库引擎简介_MySQL数据库的存储引擎简介

    存储引擎 MySQL中的数据用各种不同的技术存储在文件(或者内存)中.这些技术中的每一种技术都使用不同的存储机制.索引技巧.锁定水平并且最终提供广泛的不同的功能和能力.通过选择不同的技术,你能够获得额 ...

  8. mysql 存储引擎接口_MySQL体系结构和存储引擎

    数据库与传统文件系统最大的区别在于数据库是支持事务的 一.定义数据库与实例 1.数据库: 物理操作系统的文件或者其他文件类型的集合,依照某种数据模型组织起来并存储于二级存储器中的数据集合. 2.实例: ...

  9. MySQL数据库的索引、事务和存储引擎

    目录 一.索引 1.1 索引的概念 1.2 索引的作用 1.3 创建索引的原则 1.4 索引的分类 1.5 索引的创建 1.5.1 普通索引 1.5.2 唯一索引 1.5.3 主键索引 1.5.4 组 ...

  10. mysql and常用引擎_MySQL两大常用存储引擎MyISAM,InnoDB的区别

    本文主要整理了MySQL两大常用的存储引擎MyISAM,InnoDB的六大常见区别,来源于Mysql手册以及互联网的资料 InnoDB与Myisam的六大区别 MyISAM InnoDB 构 成上的区 ...

最新文章

  1. 面试官:你说熟悉MySQL,那来谈谈InnoDB怎么解决幻读的?
  2. 吴思教授:揭秘视觉信息处理的闭环
  3. csrf攻击防御 php,Yii2.0防御csrf攻击方法
  4. Linux 内核源码分析 IPv6报文接收处理流程
  5. 关键词多样性的重要意义
  6. android开发技术探索,《android开发艺术探索》读书笔记(十三)--综合技术(示例代码)...
  7. 云消防大数据_消防云大数据
  8. 【操作系统/OS笔记14】经典同步问题:读者-写者问题、哲学家就餐问题
  9. 计算机组成原理——第四章
  10. python发送邮件带附件_python 发送带附件邮件
  11. 《CLR Via C# 第3版》笔记之(八) - 类型的转换构造器和方法
  12. 关于诺顿误杀系统文件的解决方法
  13. python爬虫淘宝评论_Python爬虫,抓取淘宝商品评论内容
  14. gimp 抠图_自动抠图工具,不用懂PS,还可以批量抠图
  15. 剑侠世界手游服务器维护公告,剑侠世界手游公告_剑侠世界手游开服公告_更新公告_安趣网...
  16. Coinbase、BlockFi相继开启上市准备工作,但SEC准备好了吗?
  17. 417分上那所计算机学院,2021年高考417分左右能上什么大学(100所)
  18. arXiv | FedPer:带个性化层的联邦学习
  19. 基于NAR神经网络的时间序列预测
  20. 学tlc和JAVA,#Java学习之路——第一部分总结

热门文章

  1. 扩展程序无法拖进谷歌浏览器内的解决办法
  2. Farthest Point Sampling(最远点采样)
  3. 华为OD机试题,用 Java 解【火星文计算 2】问题
  4. react全家桶从0搭建一个完整的react项目(react-router4、redux、redux-saga)
  5. 【学习笔记-FPGA】verilog语言中assign的使用
  6. Linux小白第一天——VMware Player 装 CentOS
  7. Java中匿名类的两种实现方式
  8. 张益唐新成果首次公开直播,开场写下ac-bd=(a+b)c-(c+d)b,这回好像能看懂?
  9. python速度_只需一行代码,让你的Python运算速度更加流畅!
  10. 如何保持mysql和redis中数据的一致性?