update mysql2redis.md
This commit is contained in:
parent
469eae3131
commit
adf97d94d4
|
@ -4,16 +4,34 @@ mysql2redis
|
|||
## STATUS
|
||||
draft
|
||||
|
||||
## MAIN FUNCTIONS
|
||||
This doc tells users how to install mysql2redis in linux env.
|
||||
## INTRO
|
||||
This doc tells users how to install mysql2redis in linux
|
||||
env. Mysql2redis is mysql UDF(user-defined function) dynamic library,
|
||||
which is used to update redis when mysql update.
|
||||
|
||||
## DENPENDENCY
|
||||
1. jemalloc
|
||||
2. apr
|
||||
3. apr-util
|
||||
4. hiredis
|
||||
5. lib_mysqludf_json
|
||||
|
||||
## INSTALL DEPS
|
||||
* sudo apt-get install libjemalloc1 libjemalloc-dev
|
||||
or source download install
|
||||
* install apr: 1. download 2. ./configure 3. make 4. make test 5. make
|
||||
install
|
||||
* install apr-util: 1. download 2. ./configure
|
||||
--with-apr=/usr/local/apr 3. make 4. make install
|
||||
* install jemalloc
|
||||
1. sudo apt-get install libjemalloc1 libjemalloc-dev (Ubuntu)
|
||||
2. or source install, which can be download from
|
||||
[here](http://www.canonware.com/download/jemalloc/jemalloc-3.5.0.tar.bz2).
|
||||
* install apr
|
||||
1. download: wget http://mirror.bit.edu.cn/apache//apr/apr-1.5.0.tar.gz
|
||||
2. ./configure
|
||||
3. make
|
||||
4. make test
|
||||
5. sudo make install
|
||||
* install apr-util
|
||||
1. download
|
||||
2. ./configure --with-apr=/usr/local/apr
|
||||
3. make
|
||||
4. sudo make install
|
||||
* install lib_mysqludf_json
|
||||
1. download: wget https://github.com/mysqludf/lib_mysqludf_json
|
||||
2. copy lib_mysqludf_json.so to /usr/lib/mysql/plugin
|
||||
|
@ -22,50 +40,57 @@ This doc tells users how to install mysql2redis in linux env.
|
|||
2. cd hiredis;
|
||||
3. make
|
||||
4. sudo make install #or copy libhiredis.so in mysql plugin dir
|
||||
* configure Makefile
|
||||
1. modify its format.
|
||||
2. modify mysqlplugindir i.e. PLUGINDIR
|
||||
* install mysql2redis:
|
||||
1. make (note QA)
|
||||
|
||||
* install mysql2redis
|
||||
1. download git clone https://github.com/aborn/mysql2redis.git
|
||||
2. cd mysql2redis
|
||||
3. modify Makefile
|
||||
* make Makefile sytax right.
|
||||
* modify mysqlplugindir (PLUGINDIR)
|
||||
4. make
|
||||
|
||||
## QA
|
||||
|
||||
|
||||
#### Install apr error
|
||||
1. /usr/local/apr/include/apr-1/apr.h:358:1: error: unknown type name
|
||||
‘off64_t’
|
||||
* sudo vi /usr/local/apr/include/apr-1/apr.h in line 358
|
||||
* add line typedef long off64_t;
|
||||
before typedef off64_t apr_off_t;
|
||||
|
||||
* before typedef off64_t apr_off_t;
|
||||
* message as follow:
|
||||
> . vagrant@precise32 ~/mysql2redis
|
||||
> % make
|
||||
> gcc -Werror -O2 -g `/usr/bin/mysql_config --include` -I/usr/local/include -I/usr/local/apr/include -I. -fPIC -shared -rdynamic lib_mysqludf_redis.c utils.c\
|
||||
> -lhiredis -L"/usr/lib64/mysql/plugin" -L/usr/local/apr/lib -lapr-1 -laprutil-1 -ljemalloc -o "/usr/lib64/mysql/plugin"/lib_mysqludf_redis_v2.so
|
||||
> In file included from lib_mysqludf_redis.c:50:0:
|
||||
> /usr/local/apr/include/apr-1/apr.h:358:1: error: unknown type name ‘off64_t’
|
||||
> lib_mysqludf_redis.c: In function ‘check_error’:
|
||||
> lib_mysqludf_redis.c:271:13: error: format not a string literal and no format arguments [-Werror=format-security]
|
||||
> cc1: all warnings being treated as errors
|
||||
> make: *** [linux] Error 1
|
||||
|
||||
#### Install mysql2redis
|
||||
2. lib_mysqludf_redis.c:271:13: error: format not a string literal and
|
||||
no format arguments [-Werror=format-security]
|
||||
* vi lib_mysqludf_redis.c in line 271
|
||||
* /*fprintf(pFile,buf)*/
|
||||
fputs(buf, pFile);
|
||||
* fputs(buf, pFile);
|
||||
* message append follow:
|
||||
> % make
|
||||
> gcc -Werror -O2 -g `/usr/bin/mysql_config --include` -I/usr/local/include -I/usr/local/apr/include -I. -fPIC -shared -rdynamic lib_mysqludf_redis.c utils.c\
|
||||
> -lhiredis -L"/usr/lib64/mysql/plugin" -L/usr/local/apr/lib -lapr-1 -laprutil-1 -ljemalloc -o "/usr/lib64/mysql/plugin"/lib_mysqludf_redis_v2.so
|
||||
> lib_mysqludf_redis.c: In function ‘check_error’:
|
||||
> lib_mysqludf_redis.c:271:13: error: format not a string literal and no format arguments [-Werror=format-security]
|
||||
> cc1: all warnings being treated as errors
|
||||
> make: *** [linux] Error 1
|
||||
|
||||
|
||||
#### Install hiredis
|
||||
3. install hiredis
|
||||
* make: Nothing to be done for `all'.
|
||||
* sudo make install
|
||||
|
||||
## APPEND
|
||||
1. vagrant@precise32 ~/mysql2redis
|
||||
% make
|
||||
gcc -Werror -O2 -g `/usr/bin/mysql_config --include` -I/usr/local/include -I/usr/local/apr/include -I. -fPIC -shared -rdynamic lib_mysqludf_redis.c utils.c\
|
||||
-lhiredis -L"/usr/lib64/mysql/plugin" -L/usr/local/apr/lib -lapr-1 -laprutil-1 -ljemalloc -o "/usr/lib64/mysql/plugin"/lib_mysqludf_redis_v2.so
|
||||
In file included from lib_mysqludf_redis.c:50:0:
|
||||
/usr/local/apr/include/apr-1/apr.h:358:1: error: unknown type name ‘off64_t’
|
||||
lib_mysqludf_redis.c: In function ‘check_error’:
|
||||
lib_mysqludf_redis.c:271:13: error: format not a string literal and no format arguments [-Werror=format-security]
|
||||
cc1: all warnings being treated as errors
|
||||
make: *** [linux] Error 1
|
||||
|
||||
2. % make
|
||||
gcc -Werror -O2 -g `/usr/bin/mysql_config --include` -I/usr/local/include -I/usr/local/apr/include -I. -fPIC -shared -rdynamic lib_mysqludf_redis.c utils.c\
|
||||
-lhiredis -L"/usr/lib64/mysql/plugin" -L/usr/local/apr/lib -lapr-1 -laprutil-1 -ljemalloc -o "/usr/lib64/mysql/plugin"/lib_mysqludf_redis_v2.so
|
||||
lib_mysqludf_redis.c: In function ‘check_error’:
|
||||
lib_mysqludf_redis.c:271:13: error: format not a string literal and no format arguments [-Werror=format-security]
|
||||
cc1: all warnings being treated as errors
|
||||
make: *** [linux] Error 1
|
||||
|
||||
3. vagrant@precise32 ~/sw/hiredis
|
||||
% sudo make install
|
||||
|
|
|
@ -16,8 +16,10 @@ CREATE TRIGGER tri_set_insert AFTER INSERT ON account
|
|||
BEGIN
|
||||
DECLARE done INT DEFAULT 99;
|
||||
DECLARE ret INT DEFAULT 99;
|
||||
DECLARE fre INT DEFAULT 99;
|
||||
SET @ret=redis_servers_set_v2("127.0.0.1",6379);
|
||||
SET @done=redis_command_v2("127.0.0.1",6379,"set",concat("account:",new.acct_num),concat("acct_num:",new.acct_num, " amount:", new.amount));
|
||||
SET @fre=free_resources();
|
||||
END;|
|
||||
delimiter ;
|
||||
|
||||
|
@ -33,8 +35,10 @@ CREATE TRIGGER tri_set_update AFTER UPDATE ON account
|
|||
BEGIN
|
||||
DECLARE done INT DEFAULT 99;
|
||||
DECLARE ret INT DEFAULT 99;
|
||||
DECLARE fre INT DEFAULT 99;
|
||||
SET @ret=redis_servers_set_v2("127.0.0.1",6379);
|
||||
SET @done=redis_command_v2("127.0.0.1",6379,"set",concat("account:",new.acct_num),concat("acct_num:",new.acct_num, " amount:", new.amount));
|
||||
SET @fre=free_resources();
|
||||
END;|
|
||||
delimiter ;
|
||||
|
||||
|
@ -51,8 +55,10 @@ CREATE TRIGGER tri_set_delete AFTER DELETE ON account
|
|||
BEGIN
|
||||
DECLARE done INT DEFAULT 99;
|
||||
DECLARE ret INT DEFAULT 99;
|
||||
DECLARE fre INT DEFAULT 99;
|
||||
SET @ret=redis_servers_set_v2("127.0.0.1",6379);
|
||||
#SET @done=redis_command_v2("127.0.0.1",6379,"set",concat("account:",old.acct_num),concat("del_acct_num:",old.acct_num, " amount:", old.amount));
|
||||
SET @done=redis_command_v2("127.0.0.1",6379,"del",concat("account:",old.acct_num),"deleted success.");
|
||||
SET @fre=free_resources();
|
||||
END; |
|
||||
delimiter ;
|
||||
|
|
Loading…
Reference in New Issue