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

相關文章
相關標籤/搜索