Redis主从搭建
huifer opened this issue · 1 comments
huifer commented
实现redis主从搭建
huifer commented
实现方式为单机多端口
master配置
master端口:6380配置如下
# 端口
port 6380
# 是否后台启动
daemonize yes
# pid地址
pidfile /var/run/redis_6380.pid
# 数据文件地址
dbfilename dump-master-6380.rdb
# 数据文件存放地址
dir /home/huifer/huifer/data/redis-data/
# 密码
requirepass master
slave配置
2个slave端口分别为6381,6382
port 6381
daemonize yes
dbfilename dump-slave-1-6381.rdb
dir /home/huifer/huifer/data/redis-data/
# 主master地址
replicaof 127.0.0.1 6380
# 主master链接密码
masterauth master
启动
redis-server xxx.conf
redis-server redis-master-6380.conf
cli链接
redis-cli -p 6380
# 链接密码
auth master
info Replication
启动完成了 😊
哨兵
三个哨兵的端口、日志、pid不同其他都是相同配置,端口号分别为26380,26381,26382
port 26380
daemonize yes
pidfile "/var/run/redis-sentinel-master-26380.pid"
logfile "/home/huifer/huifer/log/redis/redis-sentinel-26380.log"
sentinel monitor mymaster 127.0.0.1 6380 2
sentinel auth-pass mymaster master
sentinel config-epoch mymaster 0
sentinel leader-epoch mymaster 0
启动
redis-sentinel sentinel-***.conf
redis-sentinel sentinel-master-80.conf