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 ...
随机推荐
- http 和 Tcp 的区别
http 和 tcp 的区别: Http在每一次请求结束后都会主动释放连接,因此HTTP连接是一种“短链接”,要保持客户端程序的在线状态,需要不断地向服务器端发起连接请求. TCP连接时一种“长连接” ...
- 理解Python的迭代器
首先,廖雪峰老师的教程中解释了迭代器和生成器,这篇文章只是补充和我个人的总结. 什么是迭代 可以直接作用于for循环的对象统称为可迭代对象(Iterable). 可以被next()函数调用并不断返回下 ...
- [BZOJ 3531] [Sdoi2014] 旅行 【离线+LCT】
题目链接:BZOJ - 3531 题目分析 题目询问一条路径上的信息时,每次询问有某种特定的文化的点. 每个点的文化就相当于一种颜色,每次询问一条路径上某种颜色的点的信息. 可以使用离线算法, 类似于 ...
- BZOJ 1717: [Usaco2006 Dec]Milk Patterns 产奶的模式
Description 农夫John发现他的奶牛产奶的质量一直在变动.经过细致的调查,他发现:虽然他不能预见明天产奶的质量,但连续的若干天的质量有很多重叠.我们称之为一个"模式". ...
- Android 向系统发送一条短信
s //向系统写一条短信 ContentValues contentValues = new ContentValues(); contentValues.put("body",& ...
- 设计模式之装饰(Decorator)模式 代码详解
/** * Created with IntelliJ IDEA. * User: HYY * Date: 13-10-27 * Time: 下午10:49 * To change this temp ...
- 【HDU 3949】 XOR (线性基,高斯消元)
XOR Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
- 【 CodeForces - 392C】 Yet Another Number Sequence (二项式展开+矩阵加速)
Yet Another Number Sequence Description Everyone knows what the Fibonacci sequence is. This sequence ...
- eclipse导入已有源码
http://blog.csdn.net/scruffybear/article/details/1917301 如有转载,请注明出处,并保持文章的完整性,谢谢! 最近工作之余在研究国外经典书籍< ...
- git从指定的commit创建分支
How do I create a new git branch from an old commit? git checkout -b justin a9c146a09505837ec03b Thi ...