mysql2redis这个项目主要解决mysql数据跟redis数据同步的问题

目前在测试环境研究这方面的应用,以下是git上面的介绍

git入口    git安装入口

Dependencies

please download the dependencies below and compile/install it properly :

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)

解决方案:运行

 sudo /sbin/ldconfig
 

mysql2redis的更多相关文章

  1. 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 ...

  2. redis参考文档

    本文为之前整理的关于redis的文档,放到博客上一份,也方便我以后查阅. redis简介 Redis是一个开源的.高性能的.基于键值对的缓存与存储系统, 通过提供多种键值数据类型来适应不同场景下的缓存 ...

  3. MySQL to Redis

    [TOC] 简介 使用mysql2redis可以非常便捷的将mysql中的数据导出到redis中去, 通常是需要一个select语句即可实现. 软件安装 // 安装apr + apr-util $ w ...

  4. mysql技术调优资料整理

    1,15 个有用的 MySQL/MariaDB 性能调整和优化技巧 2,MariaDB设置主从复制 3,CentOS6.4安装mysql2redis        http://www.cnblogs ...

  5. 架构体系需要进一步研究探索的V2路线图

    https://github.com/dawnbreaks/mysql2redis/blob/master/README.md http://blog.163.com/zhangjie_0303/bl ...

随机推荐

  1. PHP之路——大文件上传

    修改php.ini 1.file_uploads=on/off 是否允许通过http方式上传文件 2.max_execution_time=30 允许脚本最大执行时间,超过这个时间就会报错 3.upl ...

  2. iOS 推荐博客

    著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处.作者:Franz Fang链接:http://www.zhihu.com/question/20264108/answer/3026 ...

  3. CSS中IE8和chrom像素百分比计算差异

    IE8中和chrome在计算像素百分比上,IE8舍一位取元素像素大小,chrome则使用四舍五入取元素像素大小: 比如:<body><div stype=“width:30%”> ...

  4. jquery之ajaxfileupload异步上传插件

    点我下载工程代码由于项目需求,在处理文件上传时需要使用到文件的异步上传.这里使用Jquery Ajax File Uploader这个组件下载地址:http://www.phpletter.com/d ...

  5. 好吧,如果一定要RESTFUL的DJANGO

    看看人家写的VIEWSET, 然后用REQUESTS测试一下. from rest_framework import viewsets from rest_framework.decorators i ...

  6. BZOJ_1202_狡猾的商人_(并查集)

    描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1202 n 个月的账单,共 m 组数据,每一组数据包括 x , y , t ,表示从 x 月到 ...

  7. 在网页中插入CSS样式表的几种方法

    1. 链入外部样式表 链入外部样式表是把样式表保存为一个样式表文件,然后在页面中用<link>标记链接到这个样式表文件,这个<link>标记必须放到页面的<head> ...

  8. easyui-lang-zh_CN.js导入后还是英文提示

    <script src="/js/easyUI1.3.3/jquery.easyui.min.js" type="text/javascript"> ...

  9. Unity3D与iOS消息交互方法(1)--iOS接收Unity3D发出的消息

    跨平台这种事情不管多NB, 总要有些与原生系统交互的方法, 比如  Unity3D与iOS消息交互方法. 一: 建立一个空的Unity工程. File -->  New Project 二: 编 ...

  10. 检测Office是否安装以及获取安装 路径 及安装版本 QQ,迅雷,旺旺 C#代码

    #region 检测Office是否安装 ///<summary> /// 检测是否安装office ///</summary> ///<param name=" ...