久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      介紹Redis三種集群模式(Cluster集群模式)

      下面由Redis教程欄目給大家介紹Redis三種集群模式-Cluster集群模式,希望對需要的朋友有所幫助!

      介紹Redis三種集群模式(Cluster集群模式)

      Redis三種集群模式-Cluster集群模式

      一、  在之前有看到過redis集群部署的三種方案,不過性能最高的還是redis官方推薦的redis-cluster,性能最高,下面介紹一下redis-cluster這種模式。

      1、redis-cluster

      A、采用去中心化的思想,沒有中心節(jié)點(diǎn)的說法,它使用hash slot方式將16348個hash slot覆蓋到所有節(jié)點(diǎn)上,對于存儲的每個key值,使用CRC16(KEY)&16348=slot得到他對應(yīng)的hash slot,

      并在訪問key的時候就去找他的hash slot在哪一個節(jié)點(diǎn)上,然后由當(dāng)前訪問節(jié)點(diǎn)從實(shí)際被分配了這個hash slot的節(jié)點(diǎn)去取數(shù)據(jù),節(jié)點(diǎn)之間使用輕量協(xié)議通信 減少帶寬占用 性能很高,

      自動實(shí)現(xiàn)負(fù)載均衡與高可用,自動實(shí)現(xiàn)failover并且支持動態(tài)擴(kuò)展。

      B、其內(nèi)部中也需要配置主從,并且內(nèi)部也是采用哨兵模式,如果有半數(shù)節(jié)點(diǎn)發(fā)現(xiàn)某個異常節(jié)點(diǎn),共同決定更改異常節(jié)點(diǎn)的狀態(tài),如果改節(jié)點(diǎn)是主節(jié)點(diǎn),則對應(yīng)的從節(jié)點(diǎn)自動頂替為主節(jié)點(diǎn),當(dāng)原先的主節(jié)點(diǎn)上線后,則會變?yōu)閺墓?jié)點(diǎn)。

      如果集群中的master沒有slave節(jié)點(diǎn),則master掛掉后整個集群就會進(jìn)入fail狀態(tài),因?yàn)榧旱膕lot映射不完整。如果集群超過半數(shù)以上的master掛掉,無論是否有slave,集群都會進(jìn)入fail狀態(tài)。

      C、根據(jù)官方推薦 集群部署至少要3臺以上的master節(jié)點(diǎn)。那么接下來就開始部署吧

      2、在每一路徑下我們添加一下配置文件

      都為: redis.conf

      二、集群配置 

        cd /usr/software/redis/redis-cluster/ 

        1.創(chuàng)建目錄

          /usr/software/redis/redis-cluster/1001

          /usr/software/redis/redis-cluster/1002

           /usr/software/redis/redis-cluster/1003

          /usr/software/redis/redis-cluster/1004

          /usr/software/redis/redis-cluster/1005

          /usr/software/redis/redis-cluster/1006

        2.修改redis.conf

          cd /usr/software/redis/redis-cluster/1001

          vim redis.conf

          #修改如下鍵值對 

      ################################## NETWORK ##################################### #bind 127.0.0.1protected-mode no port 1001################################# GENERAL ##################################### daemonize yes pidfile "/var/run/redis_1001.pid"logfile "/usr/software/redis/redis-cluster/1001/log/redis.log"################################ SNAPSHOTTING  ################################dir "/usr/software/redis/redis-cluster/1001/data"################################ REDIS CLUSTER  ############################### cluster-enabled yes cluster-config-file nodes-1001.conf cluster-node-timeout 15000################################## SECURITY ################################### requirepass "ww"

      其他幾個實(shí)例的配置文件修改以下配置即可(需要自己創(chuàng)建log,data目錄):

      port 100x"/var/run/redis_100x.pid"  logfile "/usr/software/redis/redis-cluster/100x/log/redis.log""/usr/software/redis/redis-cluster/100x/data"-config-file nodes-100x.conf

      三、集群啟動

      1、使用redis-server /usr/software/redis/redis-cluster/1001/redis.conf …將所有節(jié)點(diǎn)啟動

      2、啟動后我們就可以創(chuàng)建集群啦

      注意:在redis5.0后 創(chuàng)建集群統(tǒng)一使用redis-cli,之前的版本使用redis-trib.rb,但是需要安裝ruby軟件相對復(fù)雜,相比之前的版本5.0不需要安裝額外的軟件,方便。具體的可以參照redis官方網(wǎng)站查看 https://redis.io/topics/cluster-tutorial

      創(chuàng)建集群命令:其中 cluster-replicas 1 代表 一個master后有幾個slave,1代表為1個slave節(jié)點(diǎn)

      redis-cli --cluster create 127.0.0.1:1001  127.0.0.1:1002 127.0.0.1:1003 127.0.0.1:1004 127.0.0.1:1005 127.0.0.1:1006 --cluster-replicas 1 -a ww

      第一次由于沒有設(shè)置 -a ww 添加密碼,集群創(chuàng)建失敗,

      過程中會提示以下內(nèi)容,輸入 yes 繼續(xù);

      Can I set the above configuration? (type 'yes' to accept): yes

      介紹Redis三種集群模式(Cluster集群模式)

      集群自動分配結(jié)果如下:

      介紹Redis三種集群模式(Cluster集群模式)

      3、驗(yàn)證集群是否創(chuàng)建成功

      首先查看一下主從配對情況

      介紹Redis三種集群模式(Cluster集群模式)

      執(zhí)行 :redis-cli -c -p 1001 -a ww

      數(shù)據(jù)自動分配到1002節(jié)點(diǎn),連接也轉(zhuǎn)移到1002 節(jié)點(diǎn)

      介紹Redis三種集群模式(Cluster集群模式)

      4、驗(yàn)證故障轉(zhuǎn)移

      結(jié)論是主節(jié)點(diǎn)故障后,下掛從節(jié)點(diǎn)會升級成主節(jié)點(diǎn),并接替主節(jié)點(diǎn)的槽位。舊主節(jié)點(diǎn)上線后,也只能作為其從節(jié)點(diǎn)。

      kill 掉1001 ,發(fā)現(xiàn)其從節(jié)點(diǎn)1004轉(zhuǎn)為了master

      介紹Redis三種集群模式(Cluster集群模式)  

      重新啟動1001,其變成slave節(jié)點(diǎn)

      介紹Redis三種集群模式(Cluster集群模式)

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號