准备工作
Redis各节点简单配置保证可用
$ mkdir -p /etc/redis/{6379,6380,6381,26379,26380,26381}
# 批量复制redis配置
$ echo /etc/redis/6* | xargs -n 1 cp -v /redis安装路径/redis.conf
# 批量复制哨兵配置
$ echo /etc/redis/26* | xargs -n 1 cp -v /redis安装路径/sentinel.conf
# 后台运行
daemonize yes
# 运行端口
port 6379
# 主节点密码
masterauth 123456
# 当前节点密码
requirepass 123456
protected-mode yes
# 绑定IP 0.0.0.0代表所有IP可访问
bind 0.0.0.0
daemonize yes
# 从节点IP
## port 6381
port 6380
masterauth 123456
requirepass 123456
protected-mode yes
bind 0.0.0.0
# 属于那个主节点
slaveof 127.0.0.1 6379
# 后台运行
daemonize yes
# 哨兵节点端口26379、26380、26381
port 26379
# 主节点信息
sentinel monitor mymaster 127.0.0.1 6379 2
# 主节点密码
sentinel auth-pass mymaster 123456
sentinel down-after-milliseconds mymaster 15000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 80000
bind 0.0.0.0
protected-mode yes
$ redis-server /etc/redis/6379/redis.conf
$ redis-server /etc/redis/6380/redis.conf
$ redis-server /etc/redis/6381/redis.conf
$ redis-sentinel /etc/redis/26379/sentinel.conf
$ redis-sentinel /etc/redis/26380/sentinel.conf
$ redis-sentinel /etc/redis/26381/sentinel.conf
# 本机内网IP
IP=10.0.4.16
## 1:HOST 2:CLUSTER 3:SENTINEL
## 2暂不支持
REDIS_TYPE=1
REDIS_PORT=6379
REDIS_SENTINEL_PORT=26379
# 主节点IP
REDIS_MASTER=10.0.4.16
REDIS_PASS=Hanshow123!@#
Copyright © 2024 妖气游戏网 www.17u1u.com All Rights Reserved