• 主页

  • 投资

  • IT

    🔥
  • 设计

  • 销售

  • 共46篇

    Redis数据库

关闭

返回栏目

关闭

返回Redis数据库栏目

43 - 主从模式 - 复制、读写分离

作者:

贺及楼

成为作者

更新日期:2024-04-03 10:28:41

主从模式 - 复制、读写分离

概念

  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