mysql2redis
mysql2redis这个项目主要解决mysql数据跟redis数据同步的问题
目前在测试环境研究这方面的应用,以下是git上面的介绍
Dependencies
please download the dependencies below and compile/install it properly :
- apr-1.4.6(http://apr.apache.org/download.cgi)
- apr-util-1.5.2(http://apr.apache.org/download.cgi)
- hiredis(https://github.com/redis/hiredis)
- lib_mysqludf_json(https://github.com/mysqludf/lib_mysqludf_json)
| create function lib_mysqludf_json_info returns string soname 'lib_mysqludf_json.so'; | |
| create function json_array returns string soname 'lib_mysqludf_json.so'; | |
| create function json_members returns string soname 'lib_mysqludf_json.so'; | |
| create function json_object returns string soname 'lib_mysqludf_json.so'; | |
| create function json_values returns string soname 'lib_mysqludf_json.so'; |
Compile
run make from the src dir directly.
make
Install redis udf
please make sure that the lib_mysqludf_redis_v2.so has been put into the mysql plugin dir. By the way, you can examine where is the mysql plugin dir by run ''' mysql_config --plugindir '''. and then connect to your mysql server, run the following command to install the the redis udf.
DROP FUNCTION IF EXISTS redis_servers_set_v2;
DROP FUNCTION IF EXISTS redis_command_v2;
DROP FUNCTION IF EXISTS free_resources; CREATE FUNCTION redis_servers_set_v2 RETURNS int SONAME "lib_mysqludf_redis_v2.so";
CREATE FUNCTION redis_command_v2 RETURNS int SONAME "lib_mysqludf_redis_v2.so";
CREATE FUNCTION free_resources RETURNS int SONAME "lib_mysqludf_redis_v2.so";
Test redis udf
connect to your mysql server, run the following command to test the the redis udf.
select redis_command_v2("lpush","crmInboxEvents11",json_object(json_members("op","insert","value","valuettt")));
select redis_servers_set_v2("192.168.0.118",6379);
select redis_command_v2("lpush","crmInboxEvents11",json_object(json_members("op","insert","value","valuettt")));
select redis_command_v2("hset","hkey","hfield",json_object(json_members("op","insert","value","valuettt")));
select free_resources();
select redis_servers_set_v2("192.168.0.118",6379);
What's more
you should create a trigger which will lpush the newly modified data to redis list juste as the following example:
DELIMITER $$
CREATE TRIGGER insert_trigger AFTER INSERT ON email_folder
FOR EACH ROW BEGIN
SET @ret=
redis_command_v2("lpush","crmInboxEvents",
json_object
(
json_members
(
"op",
"insert",
"value",
json_object
(
NEW.Id as "id",NEW.type as "type",
NEW.mailserver_id as "mailserverId",NEW.sender as "sender",
NEW.sender_name as "senderName",NEW.recevier as "recevier",
NEW.replyto as "replyto",NEW.bbemails as "bbemails",
NEW.ccemails as "ccemails",NEW.subject as "subject"
)
)
)
);
END$$
DELIMITER ; 安装链接
1.先装着gi工具
git clone https://github.com/jackeylu/mysql2redis.git
2.下载mysql2redis
git clone http://github.com/redis/hiredis
3.下载hiredis
git clone http://github.com/redis/hiredis
4.安装hiredis
cd hiredis make && make install
5.安装mysql2redis
5.1.cp /usr/local/mysql/bin/mysql_config /usr/bin/
解决方案:修改src/lib_mysqludf_redis.c下面的285行,将ld修改成lld。
ERROR 1126 (HY000) at line 20: Can't open shared library 'lib_mysqludf_redis.so' (errno: 0 libhiredis.so.0.10: cannot open shared object file: No such file or directory)
解决方案:运行
mysql2redis的更多相关文章
- CentOS6.4安装mysql2redis
1.安装apr 下载:http://apache.dataguru.cn//apr/apr-1.5.1.tar.gz tar zxvf apr-.tar.gz cd apr- vi configure ...
- redis参考文档
本文为之前整理的关于redis的文档,放到博客上一份,也方便我以后查阅. redis简介 Redis是一个开源的.高性能的.基于键值对的缓存与存储系统, 通过提供多种键值数据类型来适应不同场景下的缓存 ...
- MySQL to Redis
[TOC] 简介 使用mysql2redis可以非常便捷的将mysql中的数据导出到redis中去, 通常是需要一个select语句即可实现. 软件安装 // 安装apr + apr-util $ w ...
- mysql技术调优资料整理
1,15 个有用的 MySQL/MariaDB 性能调整和优化技巧 2,MariaDB设置主从复制 3,CentOS6.4安装mysql2redis http://www.cnblogs ...
- 架构体系需要进一步研究探索的V2路线图
https://github.com/dawnbreaks/mysql2redis/blob/master/README.md http://blog.163.com/zhangjie_0303/bl ...
随机推荐
- wampserver修改默认根目录
1.打开wamp/scripts/config.inc.php ,修改$wwwDir = $c_installDir.’/www’; 2.打开wamp/bin/apache/apache2.4.9/c ...
- phpstorm调整背景、字体颜色
从这个网站(http://phpstorm-themes.com/)下载各类主题的xml文件, 然后将文件放到phpStorm的文件夹中,比如:C:\Users\USERNAME\.PhpStorm2 ...
- Educational Codeforces Round 6 C. Pearls in a Row
Educational Codeforces Round 6 C. Pearls in a Row 题意:一个3e5范围的序列:要你分成最多数量的子序列,其中子序列必须是只有两个数相同, 其余的数只能 ...
- linux的fork函数
fork函数 头文件:#include<unistd.h> 函数原型:pid_t fork( void);(pid_t 是一个宏定义,其实质是int 被定义在#include< ...
- STM32之串口通信
一.RS232通信协议 1.概念 个人计算机上的通讯接口之一,由电子工业协会(Electronic Industries Association,EIA) 所制定的异步传输标准接口. 2.电气特性 逻 ...
- 使用EF6.0出现:CS0029 无法将类型“System.Data.Entity.Core.Objects.ObjectContext”隐式转换为“System.Data.Objects.ObjectContext”错误
这是因为EF6.0重构了一些命名空间后,和VS原有的实体数据模型模板不一致了(ObjectContext context = ((IObjectContextAdapter)dataContext). ...
- Swift -- SnapKit
Snapkit SnapKit是专门为Swift语言提供AutoLayout布局使用的,特点为语法简洁易用. let subview = UIView() subview.backgroundColo ...
- cocos2dx3.4 导出节点树到XML文件
l利用cocostudio做UI和场景时,经常要去获取某个节点,cocostudio2.1开始加入了文件的概念,可以创建场景,节点,层等文件,把公用的东西创建到文件里,然后把这个文件拖到场景里使用,达 ...
- Github readme语法-- markdown
README 该文件用来测试和展示书写README的各种markdown语法.GitHub的markdown语法在标准的markdown语法基础上做了扩充,称之为GitHub Flavored Mar ...
- 《无懈可击的Web设计》_灵活的文字
常见的方法 body{ font-size:12px; } 使用像素单位的优点: 不管使用哪种浏览器或者设备来查看,文字看起来都大小一致. 为什么这么做不是无懈可击的? 以像素为单位设定文字大小之后, ...