博客列表 >redis主从

redis主从

echo
echo原创
2020年05月16日 02:05:29710浏览

主从配置三种方式

1.在从服务器配置文件中加入 slaveof {masterHost} {masterPort} 随redis启动生效

2.在redis-server启动命令后加入 —slaveof {masterHost} {masterPort} 生效

3.直接使用命令: slaveof {masterHost} {masterPort}

4.info replication 查看主从信息

5.SLAVEOF NO ONE 断开主从,重新成为主节点

一主多从配置

主服务器 docker run -itd —name redis_m_150 -v /www/docker/03/masterandslave/master_150:/redis -p 6350:6379 —network=redismasterandslave —ip=192.168.160.150 redis5ms sh

从服务器1 docker run -itd —name redis_s_140 -v /www/docker/03/masterandslave/slave_140:/redis -p 6340:6379 —network=redismasterandslave —ip=192.168.160.140 redis5ms sh

从服务器2 docker run -itd —name redis_s_130 -v /www/docker/03/masterandslave/slave_130:/redis -p 6330:6379 —network=redismasterandslave —ip=192.168.160.130 redis5ms sh

启动redis出错解决办法

1)The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128

2)WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add ‘vm.overcommit_memory = 1‘ to /etc/sysctl.conf and then reboot or run the command ‘sysctl vm.overcommit_memory=1‘ for this to take effect.
解决:
针对这两个问题,都要修改/etc/sysctl.conf文件,在文件末尾加入以下两句:
net.core.somaxconn= 1024
vm.overcommit_memory = 1

3)WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command ‘echo never > /sys/kernel/mm/transparent_hugepage/enabled‘ as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
临时解决:
root用户执行echo never > /sys/kernel/mm/transparent_hugepage/enabled
永久解决:将上面这句话写入到/etc/rc.local文件中。
修改完成后要重启redis。

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议