Redis Master-Slave Configuration Guide

1. Software Installation
Here we assume the master server IP is 192.168.1.100, and the slave server is 192.168.1.200
 
yum -y install redis
 
Enable on startup:
 
chkconfig –add redis
chkconfig redis on
 
Add firewall rule:
 
/sbin/iptables -I INPUT -p tcp –dport 6379 -j ACCEPT
/etc/rc.d/init.d/iptables save
service iptables restart

2. Master Server Configuration:
vi /etc/redis.conf
Add authentication password at the end:
requirepass Redis197
Where Redis197 can be changed to anything you prefer
Start the server:
service redis start
 
 
3. Slave Server Configuration:
vi /etc/redis.conf
Add master server information at the end:
slaveof 192.168.1.100 6379     
masterauth Redis197
requirepass Redis197
Start the server:
service redis start
 
 
4. Testing:
Execute on the master server:
redis-cli -h 192.168.1.100 -a Redis197 set test 123456
Execute on the slave server:
redis-cli -h 192.168.1.200 get test
If successful, it will return:
“123456”
 
 
To add multiple slave servers, simply repeat the slave server configuration steps above.
 

Leave a Comment

Your email address will not be published.