项目作者: minyk

项目描述 :
Redis Sentinel cluster HA tester.
高级语言: Java
项目地址: git://github.com/minyk/redis-sentinel-test.git
创建时间: 2019-01-20T02:19:12Z
项目社区:https://github.com/minyk/redis-sentinel-test

开源协议:

下载


How to build

  1. $ mvn clean compile jib:build

How to run

  • parameters:
  1. $ java -cp ./target/redis-sentinel-test-0.1.jar com.github.minyk.redis.sentinel.test.RedisSentinelTest --help
  2. usage: CLITester
  3. -l,--library <arg> Redis client library. 'jedis' or 'redisson'
  4. only.
  5. -m,--master-name <arg> Master name.
  6. -p,--password <arg> Password for master server
  7. -s,--sentinels <arg> Sentinel hosts. Comma seperated string.
  8. -t,--sleep-time <arg> Sleep time between requests in milliseconds.

Test with Redisson library

  1. $ java -Xms1g -Xmx1g \
  2. -cp ./target/redis-sentinel-test-0.1.jar \
  3. com.github.minyk.redis.sentinel.test.RedisSentinelTest \
  4. -s redis://127.0.0.1:26379 \
  5. -t 1000 \
  6. -m mymaster \
  7. -p pass \
  8. -l redisson

Test with Jedis library

  1. % java -Xms1g -Xmx1g \
  2. -cp ./target/redis-sentinel-test-0.1.jar \
  3. com.github.minyk.redis.sentinel.test.RedisSentinelTest \
  4. -s 127.0.0.1:26379 \
  5. -t 1000 \
  6. -m mymaster \
  7. -p pass \
  8. -l jedis

Test sample

redisson

  1. 0 [main] INFO org.redisson.Version - Redisson 3.5.5
  2. 576 [main] INFO org.redisson.connection.SentinelConnectionManager - master: redis://172.17.0.2:6379 added
  3. 590 [main] INFO org.redisson.connection.SentinelConnectionManager - slave: redis://172.17.0.3:6379 added
  4. 590 [main] INFO org.redisson.connection.SentinelConnectionManager - slave: redis://172.17.0.8:6379 added
  5. 645 [redisson-netty-1-2] INFO org.redisson.connection.pool.PubSubConnectionPool - 1 connections initialized for /172.17.0.8:6379
  6. 645 [redisson-netty-1-3] INFO org.redisson.connection.pool.PubSubConnectionPool - 1 connections initialized for /172.17.0.3:6379
  7. 648 [redisson-netty-1-1] INFO org.redisson.connection.pool.SlaveConnectionPool - 10 connections initialized for /172.17.0.8:6379
  8. 649 [redisson-netty-1-2] INFO org.redisson.connection.pool.SlaveConnectionPool - 10 connections initialized for /172.17.0.3:6379
  9. 659 [redisson-netty-1-5] INFO org.redisson.connection.pool.MasterConnectionPool - 10 connections initialized for /172.17.0.2:6379
  10. 677 [redisson-netty-1-3] INFO org.redisson.connection.SentinelConnectionManager - sentinel: sentinel:26379 added
  11. 679 [main] INFO com.github.minyk.redis.sentinel.test.SentinelTest - starting REDISSON client with sentinel hosts: redis://sentinel:26379 master: mymaster
  12. .1720 [main] INFO com.github.minyk.redis.sentinel.test.SentinelTest - Sat Jan 19 07:53:44 UTC 2019
  13. ..................22963 [pool-1-thread-1] ERROR org.redisson.connection.pool.MasterConnectionPool - host /172.17.0.2:6379 disconnected due to failedAttempts=3 limit reached
  14. 27493 [redisson-3-1] INFO org.redisson.connection.MasterSlaveEntry - master /172.17.0.8:6379 excluded from slaves
  15. 27493 [redisson-3-1] INFO org.redisson.connection.SentinelConnectionManager - slave: 172.17.0.2:6379 has up
  16. 27507 [redisson-netty-1-6] INFO org.redisson.connection.pool.MasterConnectionPool - 10 connections initialized for /172.17.0.8:6379
  17. 27512 [redisson-netty-1-6] INFO org.redisson.connection.MasterSlaveEntry - master /172.17.0.2:6379 has changed to redis://172.17.0.8:6379
  18. ...............42709 [redisson-3-1] INFO org.redisson.connection.MasterSlaveEntry - master /172.17.0.8:6379 excluded from slaves
  19. 42709 [redisson-3-1] INFO org.redisson.connection.SentinelConnectionManager - slave: 172.17.0.2:6379 has up
  20. ..................

jedis

  1. 0 [main] INFO com.github.minyk.redis.sentinel.test.SentinelTest - starting JEDIS sentinel pool with sentinel hosts: sentinel:26379 master: mymaster
  2. 8 [main] INFO redis.clients.jedis.JedisSentinelPool - Trying to find master from available Sentinels...
  3. 90 [main] INFO redis.clients.jedis.JedisSentinelPool - Redis master running at 172.17.0.2:6379, starting Sentinel listeners...
  4. 315 [main] INFO redis.clients.jedis.JedisSentinelPool - Created JedisPool to master at 172.17.0.2:6379
  5. .1326 [main] INFO com.github.minyk.redis.sentinel.test.SentinelTest - Sat Jan 19 07:57:01 UTC 2019
  6. .........13361 [main] INFO com.github.minyk.redis.sentinel.test.SentinelTest - SERVER DOWN
  7. 13361 [main] INFO com.github.minyk.redis.sentinel.test.SentinelTest - SERVER is still down.
  8. 16366 [main] INFO com.github.minyk.redis.sentinel.test.SentinelTest - SERVER is still down.
  9. 17131 [MasterListener-mymaster-[sentinel:26379]] INFO redis.clients.jedis.JedisSentinelPool - Created JedisPool to master at 172.17.0.3:6379
  10. .17370 [main] INFO com.github.minyk.redis.sentinel.test.SentinelTest - SERVER UP, was down for 4009 ms, failed commands: 2
  11. .................

Acknowledgements

This repo is inspired by https://github.com/noise/redis-sentinel-tests