温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

MySql-BlackHole:黑洞引擎

发布时间:2020-07-28 01:55:12 来源:网络 阅读:461 作者:技术张儿 栏目:MySQL数据库

通过查看SHOW ENGINES;或SHOW VARIABLES LIKE 'have%';的输出来查看但前的mysql版本是否支持这个引擎。

mysql> show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO   | NO         |
| CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |
| FEDERATED          | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
9 rows in set (0.00 sec)


如何使用?

创建一表时,指定引擎。(select * from emp;查看时没有任何数据)

mysql> create database test;
Query OK, 1 row affected (0.00 sec)
mysql> use test;
Database changed
mysql> create table emp (empno numeric(4) not null,ename varchar(10),job varchar(9),mgr numeric(4),hiredate datetime,sal numeric(7, 2),comm numeric(7, 2),deptno numeric(2)) ENGINE = BLACKHOLE;
Query OK, 0 rows affected (0.01 sec)
mysql> insert into emp values (7369, 'SMITH', 'CLERK', 7902, '1980-12-17', 800, null, 20);
Query OK, 1 row affected (0.00 sec)
mysql> select * from emp;
Empty set (0.00 sec)


创建一个BLACKHOLE表的时候,服务器在数据库目录创建一个表定义文件。文件用表的名字开头,并且有一个.frm扩展名。没有其它文件关联到这个表格。

[root@jz_130 ~]# cd /var/lib/mysql/test/
[root@jz_130 test]# ll
total 16
-rw-r-----. 1 mysql mysql   65 Dec  3 23:18 db.opt
-rw-r-----. 1 mysql mysql 8780 Dec  3 23:19 emp.frm


从上面的例子中可以看出使用BLACKHOLE存储引擎的表不存储任何数据,但如果mysql启用了二进制日志,SQL语句被写入日志(并被复制到从服务器)。

主从同步时,在MASTER和SLAVE中间充当PROXY,缓解MASTER的压力,减少网络带宽。

在普通的MASTER与SLAVE 中间 充当缓解机器,用来缓冲MASTER机器的压力,让SLAVE连接到缓解机器,这样减少MASTER 到 SLAVE之间的网络传输。从而减小网络的带宽以及主机的压力。

所有的处理都有中间代理机器来完成。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI