sky11qq
2015-08-27 09:09 阅读 1.0k

keepalived+twemproxy +redis问题求教

自己搭了玩的,2台虚拟机
10.20.71.150(redis2个实例分别是端口6379,6389 twemproxy 监听22122 -s22222
此外还有keepalived (只装了这一个没有master/slave。就有问题了))
10.20.71.161(redis2个实例分别是端口6379,6389 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 keepalived

global_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 *:6379

root 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 22122
Could not connect to Redis at 10.20.71.65:22122: Connection timed out
not connected> 



```真实IP+22122可以访问(应该能证明twemproxy没有问题吧)
[root@dev2 src]# ./redis-cli -h 10.20.71.150 -p 22122
10.20.71.150:22122> set oo 11
OK
10.20.71.150:22122> get oo
"11"
10.20.71.150:22122> 

```真实IP+redis端口也是可以的(redis应该也没装错)
[root@dev2 src]# ./redis-cli -h 10.20.71.150 -p 6389
10.20.71.150:6389> set pp pp
OK
10.20.71.150:6389> get pp
"pp"


```最后VIP+redis端口也是可以的
[root@dev2 src]# ./redis-cli -h 10.20.71.65 -p 6389
10.20.71.65:6389> keys *
1) "m"
2) "pp"
3) "redisinstallredord"
4) "1"


{"service":"nutcracker", "source":"dev2", "version":"0.3.0", "uptime":2934, "tim
estamp":1440665580, "total_connections":955, "curr_connections":2, "alpha": {"cl
ient_eof":0, "client_err":951, "client_connections":1, "server_ejects":0, "forwa
rd_error":0, "fragments":0, "127.0.0.1:6379": {"server_eof":0, "server_err":0, "
server_timedout":0, "server_connections":1, "server_ejected_at":0, "requests":4,
 "request_bytes":109, "responses":4, "response_bytes":26, "in_queue":0, "in_queu
e_bytes":0, "out_queue":0, "out_queue_bytes":0},"127.0.0.1:6389": {"server_eof":
0, "server_err":0, "server_timedout":0, "server_connections":0, "server_ejected_
at":0, "requests":0, "request_bytes":0, "responses":0, "response_bytes":0, "in_q
ueue":0, "in_queue_bytes":0, "out_queue":0, "out_queue_bytes":0},"10.20.71.161:6
379": {"server_eof":0, "server_err":0, "server_timedout":0, "server_connections"
:0, "server_ejected_at":0, "requests":0, "request_bytes":0, "responses":0, "resp
onse_bytes":0, "in_queue":0, "in_queue_bytes":0, "out_queue":0, "out_queue_bytes
":0},"10.20.71.161:6389": {"server_eof":0, "server_err":0, "server_timedout":0,
"server_connections":0, "server_ejected_at":0, "requests":0, "request_bytes":0,
"responses":0, "response_bytes":0, "in_queue":0, "in_queue_bytes":0, "out_queue"
:0, "out_queue_bytes":0}}}


Connection to host lost.

C:\Windows\System32>telnet 10.20.71.65 22222

telnet个端口IP组合以及应用程序请求和redis-cli表现一致。

求问,为什么最希望访问的组合 VIP+22122(proxy端口)不能访问?????









  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

相关推荐