1.安装中的问题
[root@test magent-0.6]# make gcc -Wall -g -O2 -I/usr/local/include -m64 -c -o magent.o magent.c magent.c: In function ‘writev_list’: magent.c:729: error: ‘SSIZE_MAX’ undeclared (first use in this function) magent.c:729: error: (Each undeclared identifier is reported only once magent.c:729: error: for each function it appears in.) make: *** [magent.o] Error 1 [root@test magent-0.6]# ll
在magent.c中增加
#ifndef SSIZE_MAX #define SSIZE_MAX ((~((size_t) 0)) / 2) #endif
2.修改Makefile文件
[root@test magent-0.6]# make gcc -Wall -g -O2 -I/usr/local/include -m64 -c -o magent.o magent.c gcc -Wall -g -O2 -I/usr/local/include -m64 -c -o ketama.o ketama.c gcc -Wall -g -O2 -I/usr/local/include -m64 -o magent magent.o ketama.o /usr/lib64/libevent.a /usr/lib64/libm.a gcc: /usr/lib64/libm.a: No such file or directory make: *** [magent] Error 1
LIBS = /usr/lib64/libevent.a /usr/lib64/libm.a为
LIBS = /usr/lib64/libevent.so /usr/lib64/libm.so
然后就编译通过了
开启三个端口
memcached -d -p 11211 -u memcached -m 64 -c 1024 memcached -d -p 11212 -u memcached -m 64 -c 1024 memcached -d -p 11213 -u memcached -m 64 -c 1024
11211 11212 作为两个后端一致性hash的memcached服务,11213 作为备份memcached
magent -u memcached -n 51200 -l 127.0.0.1 -p 11210 -s 0.0.0.0:11211 -s 0.0.0.0:11212 -b 0.0.0.0:11213测试过程:
magent端:
[root@test ~]# telnet 127.0.0.1 11210 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. stats memcached agent v0.6 matrix 1 -> 0.0.0.0:11211, pool size 0 matrix 2 -> 0.0.0.0:11212, pool size 0 END #--------------插入数据--------------------- set key1 0 0 8 12345678 STORED set key2 0 0 8 12345678 STORED set key3 0 0 8 12345678 STORED #--------------测试获取数据----------------- get key1 VALUE key1 0 8 12345678 END get key2 VALUE key2 0 8 12345678 END get key3 VALUE key3 0 8 12345678 END #断掉memcached -d -p 11211 -u memcached -m 64 -c 1024 后获取数据 get key1 VALUE key1 0 8 12345678 END get key2 VALUE key2 0 8 12345678 END get key3 VALUE key3 0 8 12345678 END #重启memcached -d -p 11211 -u memcached -m 64 -c 1024 后获取数据 get key1 VALUE key1 0 8 12345678 END get key2 END get key3 VALUE key3 0 8 12345678 END
11211端口主机
[root@test fail2ban]# telnet 127.0.0.1 11211 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. stat ERROR stats STAT pid 14184 STAT uptime 274 STAT time 1410764701 STAT version 1.4.4 STAT pointer_size 64 STAT rusage_user 0.000999 STAT rusage_system 0.007998 STAT curr_connections 11 STAT total_connections 12 STAT connection_structures 12 STAT cmd_get 0 STAT cmd_set 1 STAT cmd_flush 0 STAT get_hits 0 STAT get_misses 0 STAT delete_misses 0 STAT delete_hits 0 STAT incr_misses 0 STAT incr_hits 0 STAT decr_misses 0 STAT decr_hits 0 STAT cas_misses 0 STAT cas_hits 0 STAT cas_badval 0 STAT auth_cmds 0 STAT auth_errors 0 STAT bytes_read 39 STAT bytes_written 15 STAT limit_maxbytes 67108864 STAT accepting_conns 1 STAT listen_disabled_num 0 STAT threads 4 STAT conn_yields 0 STAT bytes 77 STAT curr_items 1 STAT total_items 1 STAT evictions 0 END get key1 END get key2 VALUE key2 0 8 12345678 END get key3 END
(pythonenv)[xluren@test battery]$ telnet 127.0.0.1 11212 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. stats STAT pid 14191 STAT uptime 302 STAT time 1410764733 STAT version 1.4.4 STAT pointer_size 64 STAT rusage_user 0.004999 STAT rusage_system 0.003999 STAT curr_connections 11 STAT total_connections 12 STAT connection_structures 12 STAT cmd_get 0 STAT cmd_set 2 STAT cmd_flush 0 STAT get_hits 0 STAT get_misses 0 STAT delete_misses 0 STAT delete_hits 0 STAT incr_misses 0 STAT incr_hits 0 STAT decr_misses 0 STAT decr_hits 0 STAT cas_misses 0 STAT cas_hits 0 STAT cas_badval 0 STAT auth_cmds 0 STAT auth_errors 0 STAT bytes_read 59 STAT bytes_written 16 STAT limit_maxbytes 67108864 STAT accepting_conns 1 STAT listen_disabled_num 0 STAT threads 4 STAT conn_yields 0 STAT bytes 154 STAT curr_items 2 STAT total_items 2 STAT evictions 0 END get key1 VALUE key1 0 8 12345678 END get key2 END get key3 VALUE key3 0 8 12345678 END
[root@test test]# telnet 127.0.0.1 11213 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. stats STAT pid 14198 STAT uptime 318 STAT time 1410764752 STAT version 1.4.4 STAT pointer_size 64 STAT rusage_user 0.000000 STAT rusage_system 0.008998 STAT curr_connections 11 STAT total_connections 12 STAT connection_structures 12 STAT cmd_get 0 STAT cmd_set 3 STAT cmd_flush 0 STAT get_hits 0 STAT get_misses 0 STAT delete_misses 0 STAT delete_hits 0 STAT incr_misses 0 STAT incr_hits 0 STAT decr_misses 0 STAT decr_hits 0 STAT cas_misses 0 STAT cas_hits 0 STAT cas_badval 0 STAT auth_cmds 0 STAT auth_errors 0 STAT bytes_read 85 STAT bytes_written 24 STAT limit_maxbytes 67108864 STAT accepting_conns 1 STAT listen_disabled_num 0 STAT threads 4 STAT conn_yields 0 STAT bytes 231 STAT curr_items 3 STAT total_items 3 STAT evictions 0 END get key1 VALUE key1 0 8 12345678 END get key2 VALUE key2 0 8 12345678 END get key3 VALUE key3 0 8 12345678 END
弊端:
当11211挂掉后,会从11213备机获取数据,但是当11211起来之后,会在11211取数据,数据取不到,然后即使11213有,也不会去11213去获取。