Centos 7 上对 Redis Cluster 进行压测

环境准备

  1. Centos 7
  2. Redis Cluster 6.0

Centos 7 安装 Redis 7.0

由于 Redis Benchmark 要最新版 redis 支持,首先要安装最新的 Redis-Cluster

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum install -y https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/7/remi/x86_64/redis-7.0.3-1.el7.remi.x86_64.rpm

如需要安装其它版本,可以访问版本列表

https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/7/remi/x86_64/repoview/redis.html

Centos 7 安装运行 Redis Cluster 7.0

使用 Docker compose 安装 Redis Cluster 7.0

docker-compose.yml 如下

version: '2'

networks:
  redis-cluster:
    ipam:
      config:
        - subnet: 172.10.0.0/16

services:
  redis-cli:
    image: docker.io/bitnami/redis-cluster:7.0
    volumes:
      - /Users/shuhai/wwwroot/redis-cluster:/wwwroot
    command:
      - redis-server

  redis-node-0:
    image: docker.io/bitnami/redis-cluster:7.0
    volumes:
      - redis-cluster_data-0:/bitnami/redis/data
    environment:
      - 'REDIS_PASSWORD=bitnami'
      - 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'

  redis-node-1:
    image: docker.io/bitnami/redis-cluster:7.0
    volumes:
      - redis-cluster_data-1:/bitnami/redis/data
    environment:
      - 'REDIS_PASSWORD=bitnami'
      - 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'

  redis-node-2:
    image: docker.io/bitnami/redis-cluster:7.0
    volumes:
      - redis-cluster_data-2:/bitnami/redis/data
    environment:
      - 'REDIS_PASSWORD=bitnami'
      - 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'

  redis-node-3:
    image: docker.io/bitnami/redis-cluster:7.0
    volumes:
      - redis-cluster_data-3:/bitnami/redis/data
    environment:
      - 'REDIS_PASSWORD=bitnami'
      - 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'

  redis-node-4:
    image: docker.io/bitnami/redis-cluster:7.0
    volumes:
      - redis-cluster_data-4:/bitnami/redis/data
    environment:
      - 'REDIS_PASSWORD=bitnami'
      - 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'

  redis-node-5:
    image: docker.io/bitnami/redis-cluster:7.0
    volumes:
      - redis-cluster_data-5:/bitnami/redis/data
    depends_on:
      - redis-node-0
      - redis-node-1
      - redis-node-2
      - redis-node-3
      - redis-node-4
    environment:
      - 'REDIS_PASSWORD=bitnami'
      - 'REDISCLI_AUTH=bitnami'
      - 'REDIS_CLUSTER_REPLICAS=1'
      - 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
      - 'REDIS_CLUSTER_CREATOR=yes'

volumes:
  redis-cluster_data-0:
    driver: local
  redis-cluster_data-1:
    driver: local
  redis-cluster_data-2:
    driver: local
  redis-cluster_data-3:
    driver: local
  redis-cluster_data-4:
    driver: local
  redis-cluster_data-5:
    driver: local

Centos 7 压测 Redis Cluster 7.0

redis-benchmark --cluster -q -t get,set -h redis-cluster.redis-cluster -a Redis@Passwd