This section describes how to deploy three node Redis Cache 5.0.5 Cluster Deployment. Execute all the steps in each node to install Redis Cache in cluster mode. Redis Cluster setup require atleast 3 master nodes.

Redis Cluster becomes nonoperational if any one redis master process goes down. For master failover, additional 3 redis replica processes can be configured.

You can install Redis in the following three ways:
  1. Use Redis documentation to install Redis.
  2. Use Redis install script to install Redis, which has below procedure automated in the script. You can refer KB article from https://kb.vmware.com/s/article/70718.
  3. Use below manual procedure to install Redis.

Procedure

  1. Stop firewall on all 3 nodes or open ports 6379, 16379, 6380 and 16380 on all 3 nodes.
  2. Set the system configuration parameters by executing below commands:
    1. echo 'sysctl -w net.core.somaxconn=65535' >> /etc/rc.local
    2. sysctl -w net.core.somaxconn=65535
    3. echo never > /sys/kernel/mm/transparent_hugepage/enabled
    4. echo 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' >> /etc/rc.local
    5. chmod +x /etc/rc.local
    6. echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
    7. sysctl vm.overcommit_memory=1
  3. Install Epel-Release, by invoking below command:
  4. Install Yum utilities, by invoking below command:
    yum install -y yum-utils
  5. Install Remi release, by using below commands:
  6. Enable Remi, using below command:
    yum-config-manager --enable remi
  7. Install Redis, by invoking below command:
    yum install -y redis
  8. Verify the Redis version is 5.0.5, by using below command:
    redis-server --version
  9. Copy redis.conf under /etc directory as redis-6379.conf, by using below command:
    cp /etc/redis.conf /etc/redis-6379.conf
  10. Change Owner of /etc/redis-6379.conf to redis, by using below command:
    chown redis:root /etc/redis-6379.conf
  11. Edit /etc/redis-6379.conf file with below configurations:
    1. Change "bind 127.0.0.1" to "bind <IPAddress>"
    2. Change "port 6379" to "port 6379"
    3. Change 'logfile ""' to 'logfile /var/log/redis/redis-6379.log'
    4. Change "dbfilename dump.rdb" to "dbfilename dump-6379.rdb"
    5. Change '# cluster-enabled yes' to 'cluster-enabled yes'
    6. Change '# cluster-config-file nodes-6379.conf' to 'cluster-config-file redis-6379.conf'
    7. Change '# cluster-node-timeout 15000' to 'cluster-node-timeout 5000'
    8. Change '#requirepass' to 'requirepass <password>'
    9. Change '# masterauth <master-password>' to 'masterauth <password>'
    Note: Password for masterauth must be same as requirepass.
  12. For Rhel 7.5 or 7.6, create /usr/lib/systemd/system/redis-6379.service file:
    1. Copy /usr/lib/systemd/system/redis.service to /usr/lib/systemd/system/redis-6379.service and, edit /usr/lib/systemd/system/redis-6379.service file.
    2. Replace 'ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemd' with 'ExecStart=/usr/bin/redis-server /etc/redis-6379.conf --supervised systemd'
    3. Replace 'ExecStop=/usr/libexec/redis-shutdown' with 'ExecStop=/usr/libexec/redis-shutdown redis-6379'
    For Rhel 6.9 or 6.10, create /etc/init.d/redis-6379 service file:
    1. Copy /etc/init.d/redis to /etc/init.d/redis-6379 and, edit /etc/init.d/redis-6379 file.
    2. Replace 'shut="/usr/libexec/redis-shutdown"' with 'shut="/usr/libexec/redis-shutdown redis-6379"'
    3. Replace 'pidfile="/var/run/redis/redis.pid"' with 'pidfile="/var/run/redis/redis-6379.pid"'
    4. Replace 'REDIS_CONFIG="/etc/redis.conf"' with 'REDIS_CONFIG="/etc/redis-6379.conf"'
    5. Replace '[ -e /etc/sysconfig/redis ] && . /etc/sysconfig/redis' with '[ -e /etc/sysconfig/redis-6379 ] && . /etc/sysconfig/redis-6379'
    6. Replace 'lockfile=/var/lock/subsys/redis' with 'lockfile=/var/lock/subsys/redis-6379'
    7. Replace '[ -x $shut ] && $shut' with '$shut'
  13. Enable the service:
    • For RHEL 7.5 or 7.6 command is : systemctl enable redis-6379
    • For RHEL 6.9 or 6.10 command is :
      chkconfig --add redis-6379 
      chkconfig redis-6379 on
  14. Start the service:
    • For RHEL 7.5 or 7.6 command is : systemctl start redis-6379
    • For RHEL 6.9 or 6.10 command is : service redis-6379 start
  15. Verify service status:
    • For RHEL 7.5 or 7.6 command is : systemctl status redis-6379 (service should be running)
    • For RHEL 6.9 or 6.10 command is : service redis-6379 status (service should be running)
  16. Check the redis logs /var/log/redis/redis-6379.log. The log must contains "Ready to accept connections".
  17. Execute step 1 to 15 on all 3 cluster nodes.
  18. Create redis cluster without replication by executing below command from any one cluster node:
    redis-cli -a <password> --cluster create <IP1>:6379 <IP2>:6379 <IP3>:6379
    Enter "Yes" when prompted
    Expected output: "[OK] All 16384 slots covered."
  19. Validate Redis cluster by running below command:
    redis-cli -a <password> -h <IP> -p 6379 cluster nodes
    Output: Should show all master nodes

What to do next

You must create atleast 1 replica for each master for failover.