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 ...
随机推荐
- web2.0最全的国外API应用集合
web2.0最全的国外API应用集合 原文地址:http://www.buguat.com/post/98.html 2.0时代,越来越多的API被大家广泛应用,如果你还不了解API是何物,请看这里的 ...
- Android直接通过ip进行Http请求
在测试环境,如果直接通过ip访问的话,比如:url:123.123.123/user/login.do?username=a&psw=b,这样是不行的,会报protocal协议错误,要写全称, ...
- [原博客] BZOJ 2725 : [Violet 6]故乡的梦
这个题在bzoj上好像是个权限题,想做的可以去Vani的博客下载测试数据.这里有题面. 简单叙述一下题意:给你一个n个点.m条边的带权无向图,S点和T点,询问Q次删一条给定的边的S-T最短路. 其中 ...
- IIS 500 – 内部服务器错误解决方案
最近装了测试机windows2008使用IIS7.5各种不习惯呀,各种问题,唉.. 今天又遇到了“500 – 内部服务器错误. 您查找的资源存在问题,因而无法显示.”的问题,网上查找了一下,找到解决办 ...
- 转:Nginx 日志文件切割
http://www.cnblogs.com/benio/archive/2010/10/13/1849935.html 偶然发现access.log有21G大,所以将其切割. Nginx 是一个非常 ...
- Setup SQL Server 2008 Maintenance Plan Email Notifications
一条龙作完,如何设置EXCHANGE的操作员邮件通知.. ~~~~ http://808techblog.com/2009/07/setup-sql-server-2008-maintena.html ...
- Winform的多线程问题
http://blog.csdn.net/Maths_bai/article/details/6000744
- C++静态变量对象的建立和删除,兼论MFC开始运行的起点(全局对象)
看了不少C++书,当讲到静态变量的时候,总是以int成员来举例,是啊,这样很好理解.但是如果这个静态变量是一个对象行不行呢?不仅行,有时候还非常必要,而且别有洞天. 比如: // .h 文件 clas ...
- 故障模块名称: NetdiskExt64.dll的解决之法
故障模块名称: NetdiskExt64.dll的解决之法 2013年8月5日 开机,资源管理器报错.详细报错信息如下: 问题签名: 问题事件名称: APPCRASH 应用程序名: ...
- queue与topic的技术特点对比
1 queue与topic的技术特点对比 Topic Queue 概要 Publish Subscribe messaging 发布订阅消息 Point-to-Point 点对点 有无状态 to ...