redis 配置主从

1.主服务器配置

 绑定本机端口

2.从服务器配置

    sudo cp redis.conf slave.conf

    

  2.2 配置从服务器配置文件

  bing:主服务器地址

  prot:任意(与主服务器不一致)

  replicaof 主ip 主端口

  

  

  

3.启动

  启动主:sudo redis-server /etc/redis/redis.conf

  启动从:sudo redis-server /etc/redis/slave.conf

  

  查看主从关系:redis-cli -h xxx.xxx.xxx.xxx -p 6379 info Replication

  

4.启动客户端,测试主从

  启动主客户端插入数据

  

  启动从客户端查看数据

  从,只能读,不能设置值

  

5.应用场景,读写分离

  

  

转载注明出处:https://www.cnblogs.com/jum-bolg/p/11316147.html

原文地址:https://www.cnblogs.com/jum-bolg/p/11316147.html