主从模式 / 哨兵模式

最后更新于:2022-04-02 04:01:00

[TOC] ## 概述 高可用的主从 ## 主从模式(一主多从) redis.6371.conf ``` port 6371 bind 0.0.0.0 logfile "6371.log" dbfilename 6371dump.rdb ``` redis.6372.conf ``` port 6372 bind 0.0.0.0 logfile "6372.log" dbfilename 6372dump.rdb slaveof 127.0.0.1 6371 ``` 运行 ``` //主 redis-server.exe redis.6371.conf //从,从可起多个 redis-server.exe redis.6372.conf ``` ## 配置 ### 添加redis redis.6371.conf ``` port 6371 bind 0.0.0.0 logfile "6371.log" dbfilename 6371dump.rdb ``` redis.6372.conf ``` port 6372 bind 0.0.0.0 logfile "6372.log" dbfilename 6372dump.rdb ``` redis.6373.conf ``` port 6373 bind 0.0.0.0 logfile "6373.log" dbfilename 6373dump.rdb ``` ### 添加哨兵配置 sentinel6370.conf ``` port 6370 bind 0.0.0.0 logfile "6370.log" dbfilename 6370dump.rdb dir sentinel sentinel monitor mymaster 127.0.0.1 6371 1 sentinel down-after-milliseconds mymaster 60000 sentinel failover-timeout mymaster 180000 sentinel parallel-syncs mymaster 1 ```
';