问题描述
- keepalived+twemproxy +redis问题求教
- 自己搭了玩的,2台虚拟机
10.20.71.150(redis2个实例分别是端口63796389 twemproxy 监听22122 -s22222
此外还有keepalived (只装了这一个没有master/slave。就有问题了))
10.20.71.161(redis2个实例分别是端口63796389 twemproxy 监听22122 -s22222)
VIP:10.20.71.65
集体配置:```10.20.71.150 nutcracker.yml
alpha:
listen: 10.20.71.150:22122
hash: fnv1a_64
distribution: ketama
auto_eject_hosts: true
redis: true
server_retry_timeout: 2000
server_failure_limit: 1
servers:- 127.0.0.1:6379:1
- 127.0.0.1:6389:1
- 10.20.71.161:6379:1
- 10.20.71.161:6389:1
```10.20.71.161 nutcracker.yml alpha: listen: 10.20.71.161:22122 hash: fnv1a_64 distribution: ketama auto_eject_hosts: true redis: true server_retry_timeout: 2000 server_failure_limit: 1 servers: - 127.0.0.1:6379:1 - 127.0.0.1:6389:1 - 10.20.71.150:6379:1 - 10.20.71.150:6389:1
! Configuration File for keepalivedglobal_defs { notification_email { acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc } notification_email_from Alexandre.Cassen@firewall.loc smtp_server 192.168.200.1 smtp_connect_timeout 30 router_id LVS_DEVEL}vrrp_instance VI_1 { state MASTER interface eth0 virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 10.20.71.65 }}virtual_server 10.20.71.65 22122 { delay_loop 3 lb_algo wrr lb_kind DR protocol TCP sorry_server 127.0.0.1 22122 real_server 10.20.71.150 22122 { TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 } } real_server 10.20.71.161 22122 { TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 } }}
```各进程情况,以及ipvsadm -Ln
[root@dev2 src]# ps -ef|grep redis
root 734 1 0 02:32 ? 00:00:05 /opt/redis-3.0.2/src/redis-server *:6379root 742 1 0 02:32 ? 00:00:05 /opt/redis-3.0.2/src/redis-server *:6389
root 2754 1899 0 05:02 pts/0 00:00:00 grep redis
[root@dev2 src]# ps -ef|grep nut
root 2090 1 0 04:04 ? 00:00:00 /opt/twemproxy-0.4.0/src/nutcracker -d -c /opt/nutcracker2.yml -o /opt/twemproxy.log
root 2756 1899 0 05:02 pts/0 00:00:00 grep nut
[root@dev2 src]# ps -ef|grep keepalived
root 2126 1 0 04:05 ? 00:00:00 /usr/sbin/keepalived -D
root 2127 2126 0 04:05 ? 00:00:00 /usr/sbin/keepalived -D
root 2128 2126 0 04:05 ? 00:00:00 /usr/sbin/keepalived -D
root 2758 1899 0 05:02 pts/0 00:00:00 grep keepalived
[root@dev2 src]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 10.20.71.65:22122 wrr
-> 10.20.71.150:22122 Local 1 0 0-> 10.20.71.161:22122 Route 1 0 0
[root@dev2 src]#
```问题现象:VIP(65)+22122不能访问[root@dev2 src]# ./redis-cli -h 10.20.71.65 -p 22122Could not connect to Redis at 10.20.71.65:22122: Connection timed outnot connected> ```真实IP+22122可以访问(应该能证明twemproxy没有问题吧)[root@dev2 src]# ./redis-cli -h 10.20.71.150 -p 2212210.20.71.150:22122> set oo 11OK10.20.71.150:22122> get oo11""10.20.71.150:22122> ```真实IP+redis端口也是可以的(redis应该也没装错)[root@dev2 src]# ./redis-cli -h 10.20.71.150 -p 638910.20.71.150:6389> set pp ppOK10.20.71.150:6389> get pppp""```最后VIP+redis端口也是可以的[root@dev2 src]# ./redis-cli -h 10.20.71.65 -p 638910.20.71.65:6389> keys *1) ""m""2) ""pp""3) ""redisinstallredord""4) ""1""
{""service"":""nutcracker""source"":""dev2""version"":""0.3.0""uptime"":2934timestamp"":1440665580total_connections"":955curr_connections"":2alpha"": {""client_eof"":0client_err"":951client_connections"":1server_ejects"":0forward_error"":0fragments"":0127.0.0.1:6379"": {""server_eof"":0server_err"":0server_timedout"":0server_connections"":1server_ejected_at"":0requests"":4request_bytes"":109responses"":4response_bytes"":26in_queue"":0in_queue_bytes"":0out_queue"":0out_queue_bytes"":0}127.0.0.1:6389"": {""server_eof"":at"":0requests"":0request_bytes"":0responses"":0response_bytes"":0in_queue"":0in_queue_bytes"":0out_queue"":0out_queue_bytes"":0}10.20.71.161:6379"": {""server_eof"":0server_err"":0server_timedout"":0server_connections"":0server_ejected_at"":0requests"":0request_bytes"":0responses"":0response_bytes"":0in_queue"":0in_queue_bytes"":0out_queue"":0out_queue_bytes:0}10.20.71.161:6389"": {""server_eof"":0server_err"":0server_timedout"":0server_connections"":0server_ejected_at"":0requests"":0request_bytes"":0responses"":0response_bytes"":0in_queue"":0in_queue_bytes"":0out_queue"":0out_queue_bytes"":0}}}Connection to host lost.C:WindowsSystem32>telnet 10.20.71.65 22222
telnet个端口IP组合以及应用程序请求和redis-cli表现一致。
求问,为什么最希望访问的组合 VIP+22122(proxy端口)不能访问?????