redis5.0.9哨兵模式redis-sentinel

環境規劃部署
ip地址 規劃節點
192.168.31.177 Master redis-sentinel
192.168.31.178 Slave1 redis-sentinel
192.168.31.179 Slave2 redis-sentinel

部署redis 配置主從

我這裏是安裝一鍵部署的
    wget -c http://mirrors.linuxeye.com/oneinstack-full.tar.gz
配置主從(192.168.31.178和192.168.31.179配置)
192.168.31.178 配置
      bind 127.0.0.1 192.168.31.178    #修改
      slaveof 192.168.31.177 6379        #新增
      masterauth  # #這裏填寫客戶端設置的密碼    requirepass 我這裏沒有設置密碼
192.168.31.179 配置 
       bind 127.0.0.1 192.168.31.179    #修改
       slaveof  192.168.31.177 6379        #新增
       masterauth   #這裏填寫客戶端設置的密碼    requirepass 我這裏沒有設置密碼
                 重啓各自的redis-server即可

部署redis-sentinel環境(192.168.31.177)

[root@server1 etc]# cat sentinel.conf 
   # 端口
   port 26379
   # 日誌文件
   logfile "/usr/local/redis/var/sentinel.log"
  #放後臺啓動
   daemonize yes
  # 哨兵監控主節點的IP和端口   2表示至少一個節點認爲主節點down了,纔開始選舉新節點
   sentinel monitor hanye 192.168.31.177 6379 2
  # 多少毫秒沒有接收到主節點的反饋,認爲主節點down
   sentinel down-after-milliseconds hanye 15000
  #數據存放位置
   dir "/usr/local/redis/etc"
   protected-mode no
   # failover過期時間
   sentinel failover-timeout hanye 120000
   # 配置哨兵連接主節點的認證密碼。(主節點配置的requirepass)
   #sentinel auth-pass hanye null     
 然後把此配置文件複製其他server
 [root@server1 etc]# scp  /usr/local/redis/etc/sentinel.conf  192.168.31.178:/usr/local/redis/etc/
 [root@server1 etc]# scp  /usr/local/redis/etc/sentinel.conf  192.168.31.179:/usr/local/redis/etc/     

啓動redis-sentinel(全部主機)

 /usr/local/redis/bin/redis-sentinel  /usr/local/redis/etc/sentinel.conf
啓動完畢  redis-sentine 會在各自的配置文件添加數據

   [root@server2 ~]# cat /usr/local/redis/etc/sentinel.conf 
 # 端口
 port 26379
 # 日誌文件
 logfile "/usr/local/redis/var/sentinel.log"
 daemonize yes
 sentinel myid 0e45194a89320d71313365f6163b691f1c9af021
 sentinel deny-scripts-reconfig yes
 sentinel monitor hanye 192.168.31.178 6379 2
 sentinel down-after-milliseconds hanye 15000
 # Generated by CONFIG REWRITE
 dir "/usr/local/redis/etc"
 protected-mode no
 sentinel failover-timeout hanye 120000
 sentinel config-epoch hanye 3
 sentinel leader-epoch hanye 3
 sentinel known-replica hanye 192.168.31.179 6379
 sentinel known-replica hanye 192.168.31.177 6379
 sentinel known-sentinel hanye 192.168.31.179 26379 1129fde41103b653b80efa8aeab519b36860f5b6
 sentinel known-sentinel hanye 192.168.31.177 26379 ee5750ab52459c60b9f9ccb6d11f5ecf219f9ffe
 sentinel current-epoch 3

檢測redis-sentinel結果

停止192.168.1.177的redis
  [root@server1 etc]# kilall redis-server

redis5.0.9哨兵模式redis-sentinel

停止178 redis-server

redis5.0.9哨兵模式redis-sentinel

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章