Redis 3.0叢集(二)

來源:互聯網
上載者:User

標籤:


 在Redis 3.0叢集(一)中講了Redis叢集的基本搭建。這一節主要講對Redis叢集的操作。

添加Master節點到叢集
  • 按照Redis叢集一的方式,建立連接埠為7006的新執行個體,並啟動該執行個體

  • 將7006添加到叢集:

redis-trib.rb add-node 127.0.0.1:7006 127.0.0.1:7000

    node:新節點沒有包含任何資料, 因為它沒有包含任何slot。新加入的加點是一個主節點, 當叢集需要將某個從節點升級為新的主節點時, 這個新節點不會被選中。

  • 給新節點分配雜湊槽:

redis-trib.rb reshard 127.0.0.1:7000#根據提示選擇要遷移的slot數量(ps:這裡選擇500)How many slots do you want to move (from 1 to 16384)? 500#選擇要接受這些slot的node-idWhat is the receiving node ID? f51e26b5d5ff74f85341f06f28f125b7254e61bf#選擇slot來源:#all表示從所有的master重新分配,#或者資料要提取slot的master節點id,最後用done結束Please enter all the source node IDs.  Type ‘all‘ to use all the nodes as source nodes for the hash slots.  Type ‘done‘ once you entered all the source nodes IDs.Source node #1:3375be2ccc321932e8853234ffa87ee9fde973ffSource node #2:done#列印被移動的slot後,輸入yes開始移動slot以及對應的資料.#Do you want to proceed with the proposed reshard plan (yes/no)? yes#結束
  • 查看操作結果:

redis-cli -c -p 7000cluster nodes

    可以看到返回的叢集資訊中,7006擁有了0-999雜湊槽。

添加Slave節點到叢集
  • 按照Redis叢集一的方式,建立連接埠為7007的新執行個體,並啟動該執行個體

  • 將7007添加到叢集:

redis-trib.rb add-node 127.0.0.1:7007 127.0.0.1:7000
  • 設定為7006的slave:

redis-cli -c -p 7007#參數為master節點的IDcluster replicate 2b9ebcbd627ff0fd7a7bbcc5332fb09e72788835
刪除一個Slave節點
#redis-trib del-node ip:port ‘<node-id>‘  redis-trib.rb del-node 127.0.0.1:7007 ‘c7ee2fca17cb79fe3c9822ced1d4f6c5e169e378‘
刪除一個Master節點

刪除master節點之前首先要使用reshard移除master的全部slot,然後再刪除當前節點(目前只能把被刪除master的slot遷移到一個節點上)

redis-trib.rb reshard 127.0.0.1:7006#根據提示選擇要遷移的slot數量(ps:這裡選擇500)How many slots do you want to move (from 1 to 16384)? 500#選擇要接受這些slot的node-idWhat is the receiving node ID? f51e26b5d5ff74f85341f06f28f125b7254e61bf#選擇slot來源:#all表示從所有的master重新分配,#或者資料要提取slot的master節點id,最後用done結束Please enter all the source node IDs.  Type ‘all‘ to use all the nodes as source nodes for the hash slots.  Type ‘done‘ once you entered all the source nodes IDs.Source node #1:3375be2ccc321932e8853234ffa87ee9fde973ffSource node #2:done#列印被移動的slot後,輸入yes開始移動slot以及對應的資料.#Do you want to proceed with the proposed reshard plan (yes/no)? yes#結束#刪除空master節點redis-trib.rb del-node 127.0.0.1:7006 ‘c7ee2fca17cb79fe3c9822ced1d4f6c5e169e378‘


Redis 3.0叢集(二)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.