Centos 6.9 Redis 4.0.1 主从配置

来源:互联网 发布:ubuntu配置网关 编辑:程序博客网 时间:2024/06/05 05:14
依赖包
yum install gcc gcc-c++ make cmake zlib zlib-devel readline readline-devel tkutil tk tkutil-devel tk-devel openssl openssl-devel wget ntp vim tcl -y

下载
wget http://download.redis.io/releases/redis-4.0.1.tar.gz

解压
tar -zxvf redis-4.0.1.tar.gz

拷贝到目录
mv redis-4.0.1 /usr/local/redis

cd /usr/local/redis

make && make install

创建一个redis实力
/usr/local/redis/utils
sh ./install_server.sh
6379 端口

修改默认(Master)redis IP
vi /etc/redis/6379.conf
# line 70: change to own IP or 0.0.0.0
bind 0.0.0.0

# line 377: add follows if you need
# min-slaves-to-write : if number of slave Hosts are online, Master Host accepts write requests
# min-slaves-max-lag : decision time(sec) for online if Slave Hosts return answer within specified time
min-slaves-to-write 2
min-slaves-max-lag 10

重启服务
/etc/init.d/redis_6379 restart

修改默认(Slave)redis IP
vi /etc/redis/6379.conf
# line 70: change to own IP or 0.0.0.0
bind 0.0.0.0

# line 206: add Master server's IP and port
slaveof 172.16.19.12 6379

# line 213: add connection password set on Master Host
masterauth password

# line 241: verify parameter (set Slave Hosts read-only)
slave-read-only yes

重启服务
/etc/init.d/redis_6379 restart

验证主机
redis-cli info Replication

获取钥匙
redis-cli get key_on_master
原创粉丝点击