1. 程式人生 > 其它 >redis叢集配置要點

redis叢集配置要點

1、需要修改的配置檔案項 redis.conf(1、埠prot:6380 2、pid:pidfile /var/run/redis_6380.pid 3、logfile "6380.log" 4、dbfilename dump6380.rdb)

2、啟動 redis-server  配置檔案  info replication

3、命令 人老大 從機中配置 slaveof host port  然後info replication  檢視 -----可以在配置檔案中配置 replication 選項 replicaof <masterip> <masterport> 如果有密碼  需要配置masterauth <master-password>

4、shutdown 主機斷開後叢機還是有資料儲存 需要手動修改叢機變為主機。slaveof no one 把自己變為主機master;

5、開啟哨兵模式:配置 sentinel.conf (sentinel monitor 被監控的主機名:myredis  地址:192.168.1.7  埠:6379  投票的數量1)   配置:sentinel monitor myredis 192.168.1.7 6379 1

https://blog.csdn.net/a1282379904/article/details/52335051

https://blog.csdn.net/open1024/article/details/121828253?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_default&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_default&utm_relevant_index=1

哨兵1

port 26379
bind 0.0.0.0
daemonize yes
pidfile "/var/run/redis-sentinel-1.pid"
logfile "/var/log/redis/sentinel_26379.log"
dir "/tmp"
sentinel monitor mymaster 8.129.113.233 6379
2
sentinel down-after-milliseconds mymaster
5000
sentinel auth-pass mymaster 123456
sentinel failover-timeout mymaster 30000

哨兵2

port 26380
bind 0.0.0.0
daemonize yes
pidfile "/var/run/redis-sentinel-2.pid"
logfile "/var/log/redis/sentinel_26380.log"
dir "/tmp"
sentinel monitor mymaster 8.129.113.233 6379
2
sentinel down-after-milliseconds mymaster
5000
sentinel auth-pass mymaster 123456
sentinel failover-timeout mymaster 30000
哨兵 3

port 26381
bind 0.0.0.0
daemonize yes
pidfile "/var/run/redis-sentinel-3.pid"
logfile "/var/log/redis/sentinel_26381.log"
dir "/tmp"
sentinel monitor mymaster 8.129.113.233 6379
2
sentinel down-after-milliseconds mymaster
5000
sentinel auth-pass mymaster 123456
sentinel failover-timeout mymaster 30000