通过查看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之间的网络传输。从而减小网络的带宽以及主机的压力。
所有的处理都有中间代理机器来完成。