----------------------
Standalone Redis on Centos 7 | yum install -y epel-release yum install -y redis systemctl start redis redis-cli pong |
Redis Cluster on Centos 7 | 1. Install redis on all nodes yum install -y epel-release yum install -y redis
2. Configure master vi /etc/redis.conf # update the following line: bind 127.0.0.1 <put IP of Master here> firewall-cmd --add-port=6379/tcp
3. Configure slaves vi /etc/redis.conf # update the following line: slaveof <IP of Master> 6379
4. Restart and enable redis on all nodes systemctl enable --now redis
5. Login to master and create a key to validate 127.0.0.1:6379> info replication 127.0.0.1:6379> redis-cli 127.0.0.1:6379> set 'a' 1
6. verify on the nodes that the replication is working 127.0.0.1:6379> redis-cli 127.0.0.1:6379> get 'a' # you must get correct value set from the master 127.0.0.1:6379> info replication |
Administration
--------------
Copying data from another redis instance | RDB ---
This task will copy DB from redis2 to redis1
1. SSH to redis2 and get .rdb file from /var/lib/redis
2. Stop redis1 since it will since it will overwrite the current DB when it exits. Copy the .rdb file to redis1 /var/lib/redis
3. Start redis services in redis1
4. Notice that the .rdb file in redis1 is now much larger, redis will compress it in time.
|
Upgrading redis w/o downtime | - If you have a new server, set it up as slave of the current master - If using a single server, make sure slave is started on a different port - Wait for sync to finish - Make sure all keys are replicated and the slave is replying to your commands - Allow writes to slave using "CONFIG SET slave-read-only no" - Configure all clients to use new slave - Make sure there are no more writes present on the master (use "redis-cli monitor") - Elect the new slave as the new master using "SLAVEOF NO ONE" and shutdown master - When using redis sentinel or redis cluster, upgrade slaves first then promote the upgraded slave as the new master then continue on the next slave and last on the original master - Redis cluster 4.0 is not compatible w/ Redis cluster 3.2 so a mass restart is needed |
No comments:
Post a Comment