redis 配置主从

1.主服务器配置

 绑定本机端口html

 

2.从服务器配置

 

    sudo cp redis.conf slave.confredis

    

  2.2 配置从服务器配置文件服务器

  bing:主服务器地址测试

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

  replicaof 主ip 主端口3d

  

  

  

3.启动

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

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

  

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

  

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

  启动主客户端插入数据ip

  

 

  启动从客户端查看数据

  从,只能读,不能设置值

  

5.应用场景,读写分离

  

  

 

转载注明出处:http://www.javashuo.com/article/p-eecscvzp-du.html

相关文章
相关标签/搜索