redis 主从架构配置(水平扩展) Veröffentlicht am 2018-01-27 | Words count in article 270 字 | Reading time 1 分钟 1redis 主从架构配置(水平扩展) 1234准备redis环境 1,prel 2,192.168.58.01 (master) 198.168.58.02(slave 01) 198.168.58.02(slave 02) 3,redis端口都是6379 部署到三台物理机上面。(或者docker run 三个redis 服务器 端口不同就行了,) 123redis master 必须开启 RDB 和AOF 持久化。 redis默认开启是RDB开启AOF appendonly yes aof 策略 fsynexec 1234198.168.58.02 redis slave改redis.conf slaveof <master> <port>改为 198.168.52.01 6379 1234198.168.58.03 redis slave改redis.conf slaveof <master> <port 改为 198.168.52.01 6379 1234567891011121314151617在部署在redis master的物理机上面测试redis-cli执行info 出现# Replicationrole:masterconnected_slaves:2slave0:ip=192.168.68.01,port=6379,state=online,offset=8892,lag=0slave1:ip=192.168.68.02,port=6379,state=online,offset=8892,lag=0master_repl_offset:8892repl_backlog_active:1repl_backlog_size:1048576repl_backlog_first_byte_offset:2repl_backlog_histlen:8891可见两个slave 分别为 slave01 slave02 1234567891011121314151617181920212223在部署在redis slave的物理机上面测试redis-cli执行info 出现# Replicationrole:slavemaster_host:192.168.58.01master_port:6379master_link_status:upmaster_last_io_seconds_ago:10master_sync_in_progress:0slave_repl_offset:9102slave_priority:100slave_read_only:1connected_slaves:0master_repl_offset:0repl_backlog_active:0repl_backlog_size:1048576repl_backlog_first_byte_offset:0repl_backlog_histlen:0可见次角色为slave master主机为192.168.58.01 端口6379 123至此,redis 主从架构实现。可支撑 10w+ QPSThanks Look !!!