Redis Upgrade
Upgrading or Restarting a Redis Instance Without Downtime
Redis is designed to be a long-running server process. You can change many configuration options at runtime with the CONFIG SET command, and you can also switch from AOF to RDB snapshot persistence (or the other way around) without a restart. See the output of CONFIG GET * for more information.
Sometimes a restart is still required—for example, to upgrade the Redis process to a newer version, or to change a parameter that the CONFIG command does not currently support.
Follow these steps to avoid downtime:
- Set up the new Redis instance as a replica of the current one. For this you need either a different server, or a server with enough memory to run both Redis instances at the same time.
- If you use a single server, make sure the replica starts on a different port than the master, otherwise the replica will not start.
- Wait for the initial replication sync to finish, and check the replica’s log file.
- Use the
INFOcommand to confirm the master and replica have the same number of keys; useredis-clito verify the replica works as expected and responds to your commands. - Use
CONFIG SET slave-read-only noto allow writes to the replica. - Point all clients at the new instance (the replica). During the switchover you may want to use
CLIENT PAUSEso no client can write to the old master. - Once you confirm the master receives no more queries (you can check with the
MONITORcommand), useREPLICAOF NO ONEto promote the replica to master, then shut down the old master.
If you use Redis Sentinel or Redis Cluster, the easiest way to upgrade to a new version is to upgrade the replicas one at a time. Then perform a manual failover to promote one of the upgraded replicas to master, and finally upgrade the last replica.
Reference: Redis Upgrade