mysql q4m_MySQL消息存储引擎Q4M试玩

news/2024/7/24 8:01:47 标签: mysql q4m

1. 安装二进制包:由于我的是5.1.48,从官网选择对应的包http://q4m.kazuhooku.com/dist/old/下载后解压a. 将support-files/q4m-forward 拷贝到mysql安装目录/bin下b. 将libqueue_engine.so 拷贝到mysql安装目录/lib/mysql/plugin下执行:$cat support-files

1. 安装

二进制包:

由于我的是5.1.48,从官网选择对应的包

http://q4m.kazuhooku.com/dist/old/

下载后解压

a. 将support-files/q4m-forward  拷贝到mysql安装目录/bin下

b. 将libqueue_engine.so 拷贝到mysql安装目录/lib/mysql/plugin下

执行:

$cat support-files/install.sql  www.2cto.com

INSTALL PLUGIN queue SONAME 'libqueue_engine.so';

CREATE FUNCTION queue_wait RETURNS INT SONAME 'libqueue_engine.so';

CREATE FUNCTION queue_end RETURNS INT SONAME 'libqueue_engine.so';

CREATE FUNCTION queue_abort RETURNS INT SONAME 'libqueue_engine.so';

CREATE FUNCTION queue_rowid RETURNS INT SONAME 'libqueue_engine.so';

CREATE FUNCTION queue_set_srcid RETURNS INT SONAME 'libqueue_engine.so';

CREATE FUNCTION queue_compact RETURNS INT SONAME 'libqueue_engine.so';

这时候Queue引擎的状态还是disable,重启一下mysqld就变成active了。

root@test 05:50:59>show plugins;

+---------------------+--------+--------------------+---------------------+---------+

| Name                | Status | Type               | Library             | License |

+---------------------+--------+--------------------+---------------------+---------+

| binlog              | ACTIVE | STORAGE ENGINE     | NULL                | GPL     |

| partition           | ACTIVE | STORAGE ENGINE     | NULL                | GPL     |

| CSV                 | ACTIVE | STORAGE ENGINE     | NULL                | GPL     |

| MEMORY              | ACTIVE | STORAGE ENGINE     | NULL                | GPL     |

| MyISAM              | ACTIVE | STORAGE ENGINE     | NULL                | GPL     |

| MRG_MYISAM          | ACTIVE | STORAGE ENGINE     | NULL                | GPL     |

| InnoDB              | ACTIVE | STORAGE ENGINE     | ha_innodb_plugin.so | GPL     |

| INNODB_TRX          | ACTIVE | INFORMATION SCHEMA | ha_innodb_plugin.so | GPL     |

| INNODB_LOCKS        | ACTIVE | INFORMATION SCHEMA | ha_innodb_plugin.so | GPL     |

| INNODB_LOCK_WAITS   | ACTIVE | INFORMATION SCHEMA | ha_innodb_plugin.so | GPL     |

| INNODB_CMP          | ACTIVE | INFORMATION SCHEMA | ha_innodb_plugin.so | GPL     |

| INNODB_CMP_RESET    | ACTIVE | INFORMATION SCHEMA | ha_innodb_plugin.so | GPL     |

| INNODB_CMPMEM       | ACTIVE | INFORMATION SCHEMA | ha_innodb_plugin.so | GPL     |

| INNODB_CMPMEM_RESET | ACTIVE | INFORMATION SCHEMA | ha_innodb_plugin.so | GPL     |

| QUEUE               | ACTIVE | STORAGE ENGINE     | libqueue_engine.so  | GPL     |

+---------------------+--------+--------------------+---------------------+---------+

安装完毕,可以开始玩一把了。

2.

a.创建一个QUEUE表

root@test 05:52:29>create table t1 (a int , b varchar(100)) engine=queue;

Query OK, 0 rows affected (0.00 sec)

尝试插入一条数据:  www.2cto.com

root@test 05:52:51>insert into t1 values (1,"sd");

ERROR 1598 (HY000): Binary logging not possible. Message: Statement cannot be logged to the binary log in row-based nor statement-based format

咿?插入失败,看样子Queue不支持binlog复制。好吧,重启把binlog禁用掉。再次执行

root@test 05:57:03>insert into t1 values (1,"sd");

Query OK, 1 row affected (0.01 sec)

这下插入成功了

root@test 05:57:13>insert into t1 values (2,"sda"),(3,"fio"),(4,"sas");

Query OK, 3 rows affected (0.00 sec)

-----------------------------------------

以下内容有些是参考自官方的一个PPT。

-------------------------------------------

那么QUEUE存储引擎和其他存储引擎(例如Innodb)有什么不同呢?

——不支持主键和索引

——支持insert/delete,但不支持update

——根据插入数据的顺序进行排序

——缓存select count(*)

另外该存储引擎使用了多个定义的函数来简化操作,堪称傻瓜式!!!!

针对每个连接有两种模式:OWNER模式和Non-Owner模式,在进入owner模式后,该连接所拥有的数据对其他连接而言是不可见的。

模式的切换使用函数来实现:

a).进入Owner模式

通常情况下,在发起连接后,处于Non-Owner模式,当调用函数Queue_wait()时,进入Owner 模式,根据传递给queue_wait函数的参数,会等待直到可以获得一行数据,在这之后,这行数据对其他连接而言是不可见的。

Queue_wait的参数类似于如下格式:

select * from t1 where  queue_wait(“t1”);

等待获得t1内的一行数据,默认超时时间为60秒

Select * from t1 where  queue_wait(“t1: a<4”)

----等待a<4的数据行  www.2cto.com

注:只支持检查数值类型的行

Select  queue_wait(“t1”,”t2”,30)

检查t1或t2表是否有记录,若获得t1表记录,返回1,若是t2表,则返回2,若是30秒超时,返回0

b)退出owner模式

有两种方式:

(1).调用queue_end()删除之前由queue_wait获得的行记录并返回到Non-Owner模式

(2)调用 queue_abort()释放拥有的行,但不删除。关闭连接与queue_abort()的效果相同。

3.内部行Id

每一行都有一个内建64位的Row ID,主要用于检测冲突。

Queue_rowid()

----返回当前连接拥有的行的RowId,如果不拥有任何行,则返回NULL

queue_set_srcid(src_tbl_id, mode, src_row_id)

src_tbl_id:用于定义源表

mode: a表示删除重复行,w表示重置

src_row_id:从源表获得的row id

该函数用于检查记录是否已经插入了目标表里,如果为true,那么下次的插入将被忽略

作者 MySQL内核与性能优化


http://www.niftyadmin.cn/n/1468973.html

相关文章

peewee_如何在peewee中使用postgis几何

peeweeIt’s astonishing to me how many people have this problem, and nobody thought to write up a solution to make other people’s searches a little easier. So, here I am, to save you some time with your Peewee and PostGIS adventures.令我惊讶的是&#xff0…

mysql string 连接_MySql 连接字符串

一、MySQL Connector/ODBC 2.50 (MyODBC 2.50)连接方式1、本地数据库连接Driver{MySQL};Serverlocalhost;Option16834;DatabasemyDataBase;2、远程数据连接Driver{MySQL};ServermyServerAddress;Option131072;Stmt;DatabasemyDataBase; UsermyUsername;PasswordmyPassword;3、特…

golang dns服务器_2020年在golang中建立网络服务器的初学者指南

golang dns服务器In this article, I’ll teach you how to create simple web servers with the Go language.在本文中&#xff0c;我将教您如何使用Go语言创建简单的Web服务器。 Golang入门 (Getting Started With Golang) It would be best if you have Go installed on yo…

oracle异构mysql_配置Oracle GoldenGate异构oracle到mysql同步

最近研究了一下oracle Goldengate异构同步的过程,真是几天不用手生&#xff0c;敲命令竟然如此生疏。不过还算顺利&#xff0c;经过一番折腾终于好了。环境描述&#xff1a;192.0.2.101( Oracle ) —>192.0.2.102 (Mysql )版本&#xff1a;操作系统&#xff1a;redhat6.5Ora…

程序运行出现内部应用程序错_应用程序和网站在什么上运行

程序运行出现内部应用程序错This is the first article in my series looking into the inner workings of ‘the Cloud” and the data centres that host them. With the proliferation of apps and websites, and with seemingly everything being connected to ‘the cloud…

java mysql 分布式锁_死磕 java同步系列之mysql分布式锁

欢迎关注我的公众号“彤哥读源码”&#xff0c;查看更多源码系列文章, 与彤哥一起畅游源码的海洋。(手机横屏看源码更方便)问题(1)什么是分布式锁&#xff1f;(2)为什么需要分布式锁&#xff1f;(3)mysql如何实现分布式锁&#xff1f;(4)mysql分布式锁的优点和缺点&#xff1f;…

centos下mysql主从分离_centos下的mysql 主从分离

1、分别同时打开主机和从机的my.cnf命令进行设置vim /etc/my.cnf在[mysqld]下 ?自己填数字&#xff0c;但是不能重复log-binserver-id?2、在主机进行操作&#xff0c;进入mysql主机赋予从机权限&#xff1a;grant replication slave, replication client on *.*…

mysql修改binlog格式_my15_ mysql binlog格式从mixed修改为row格式

由于主库繁忙&#xff0c;就在从库上修改binlog格式1. 从库切日志mysql> flush logs;Query OK, 0 rows affected (0.00 sec)mysql> flush logs;Query OK, 0 rows affected (0.00 sec)mysql> flush logs;Query OK, 0 rows affected (0.00 sec)2. 验证修改格式之前的日志…