目标: 一主一从,往主节点去写,在从节点去读,可以读到,主从架构就搭建成功了

1、启用复制,部署slave node(参照单机版redis的搭建)

注意一下:在slave node上配置:slaveof 192.168.1.1 6379,即可

reids集群搭建

2、强制读写分离

基于主从复制架构,实现读写分离,redis slave node只读,默认开启,slave-read-only,开启了只读的redis slave node,会拒绝所有的写操作,这样可以强制搭建成读写分离的架构

reids集群搭建

3、集群安全认证

master上启用安全认证,requirepass
reids集群搭建

slave连接口令,masterauth

reids集群搭建

4.修改redis.conf(6379.conf)

1. bind 127.0.0.1 -> 本地的开发调试的模式,就只能127.0.0.1本地才能访问到6379的端口
2. 每个redis.conf中的bind 127.0.0.1 -> bind自己的ip地址
3. 在每个节点上都: iptables -A INPUT -ptcp --dport  6379 -j ACCEPT(开放6379,防止没有开放端口)

reids集群搭建

5、读写分离架构的测试

先启动主节点,eshop-cache01上的redis实例
再启动从节点,eshop-cache02上的redis实例
redis-cli -a redis-pass -h 172.16.1.185
redis-cli -h ipaddr
info replication

相关文章:

  • 2021-10-19
  • 2021-09-15
  • 2021-11-17
  • 2021-06-06
  • 2021-09-22
  • 2021-12-03
  • 2021-08-31
  • 2022-03-08
猜你喜欢
  • 2021-07-04
  • 2021-07-24
  • 2021-08-09
  • 2021-04-03
  • 2022-12-23
  • 2022-01-07
相关资源
相似解决方案