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 ...
随机推荐
- zend studio 9.0.4 安装破解
转载于 http://www.geekso.com/ZendStudio9-key 注册破解步骤第一步:如果已经安装过Zend Studio 9.0.4的,请打开Zend Studio 9.0.4,在 ...
- MYSQL数据库备份与恢复【转】
mysqldump -h主机名 -P端口 -u用户名 -p密码 (–database) 数据库名 > 文件名.sql 在window上需要通过CMD进入mysql安装目录下的bin目录下执行 ...
- leetcode 第五题 Longest Palindromic Substring (java)
Longest Palindromic Substring Given a string S, find the longest palindromic substring in S. You may ...
- mysql数据库中某项其中一个值在该项排第几,百分几
SQL 如下: sql 1. SELECT X.USER_ID, X.TOTAL_NO, X.ORDER_NO, X.ORDER_NO / X.TOTAL_NO AS PERCENTAGE_NO AS ...
- bzoj 4066: 简单题 kd-tree
4066: 简单题 Time Limit: 50 Sec Memory Limit: 20 MBSubmit: 234 Solved: 82[Submit][Status][Discuss] De ...
- 关于keil中data,idata,xdata,pdata,code的问题
转自关于keil中data,idata,xdata,pdata,code的问题 从数据存储类型来说,8051系列有片内.片外程序存储器,片内.片外数据存储器,片内程序存储器还分直接寻址区和间接寻址类 ...
- zip压缩解压缩 项目icsharpcode-SharpZipLib-e012155
大家可以到http://www.icsharpcode.net/opensource/sharpziplib/ 下载SharpZiplib的最新版本,支持Zip, GZip, BZip2 和Tar格式 ...
- linux ERROR: ld.so: object '/lib/libcwait.so' from /etc/ld.so.preload cannot be preloaded: ignored.
[root@ora9i 3238244]# lsb_release -a LSB Version: :core-3.0-amd64:core-3.0-ia32:core-3.0-noarch:g ...
- 利用if else来运行咱们结婚吧
static void Main(string[] args) { while (true) { string ...
- 一起啃PRML - 1.1 Example: Polynomial Curve Fitting 多项式曲线拟合
一起啃PRML - 1.1 Example: Polynomial Curve Fitting @copyright 转载请注明出处 http://www.cnblogs.com/chxer/ 前言: ...