微信登录

主从模式+哨兵模式 - slave切换master

概念

  1. 可以:
  2. 主服务负责写
  3. 从服务负责读
  4. 从服务下可以多个从服务

查看主从关系

  1. redis-cli -h 127.0.0.1 -p 6378 info Replication
  2. 默认-p 6379

3个配置文件

redis_1.conf

  1. port 6379
  2. bind 172.16.0.1
  3. daemonize yes
  4. pidfile 6379.pid
  5. cluster-enabled yes
  6. cluster-config-file 6379_node.conf
  7. cluster-node-timeout 15000
  8. appendonly yes

redis_2.conf

  1. port 6379
  2. bind 172.16.0.2
  3. daemonize yes
  4. pidfile 6379.pid
  5. cluster-enabled yes
  6. cluster-config-file 6379_node.conf
  7. cluster-node-timeout 15000
  8. appendonly yes

redis_3.conf

  1. port 6379
  2. bind 172.16.0.3
  3. daemonize yes
  4. pidfile 6379.pid
  5. cluster-enabled yes
  6. cluster-config-file 6379_node.conf
  7. cluster-node-timeout 15000
  8. appendonly yes
  1. 启动命令
  2. redis-server redis_1.conf
  3. redis-server redis_2.conf
  4. redis-server redis_3.conf