Redis4叢集安裝部署實戰_redis

來源:互聯網
上載者:User

redis伺服器的叢集主從配置,從redis的安裝到執行個體開啟,到叢集建立。叢集配置如圖:

Redis叢集優點摘自官網

So in practical terms, what you get with Redis Cluster?

The ability to automatically split your dataset among multiple nodes.
The ability to continue operations when a subset of the nodes are experiencing failures or are unable to communicate with the rest of the cluster. 1.安裝redis,下載Redis並編譯 在三台伺服器上分別安裝redis,進行如下操作:

ubuntu需要安裝 sudo apt install tcl8.6

$ wget http://download.redis.io/releases/redis-4.0.1.tar.gz$ tar xzf redis-4.0.1.tar.gz$ cd redis-4.0.1$ make$ mv /opt/

$ make test

2.叢集檔案配置 resdis叢集整體架構


三台伺服器,配置如上圖,在每台伺服器上配置如下(以伺服器3為列)

$ /opt/redis-4.0.1# mkdir redis-cluster$ /opt/redis-4.0.1# mkdir redis-cluster/nodes-7004$ /opt/redis-4.0.1# mkdir redis-cluster/nodes-7005$ /opt/redis-4.0.1# cp redis.conf redis-cluster/nodes-7004$ /opt/redis-4.0.1# cp redis.conf redis-cluster/nodes-7005

依次配置redis.conf(以nodes-7005為列)

$ /opt/redis-4.0.1# vim redis-cluster/nodes-7005/redis.conf
port 7005 #在不同的伺服器和nodes-xx中,連接埠也不同cluster-enabled yesbind 10.80.67.238# daemonize yes #redis後台運行cluster-config-file nodes-7005.confcluster-node-timeout 5000appendonly yes
3.依次啟動redis執行個體
src/redis-server redis-cluster/nodes-7000/redis.conf

後台啟動

nohup src/redis-server redis-cluster/nodes-7000/redis.conf > redis-cluster/nodes-7000/redis-server.out 2>&1 &

nohup(no hang up) 不掛起,後台運行程式。並將輸出資訊重新導向到redis-cluster/nodes-7000/redis-server.out

如何關閉。
查看pidps aux | grep redis關閉進程kill -9 pid

每個redis執行個體都有獨立唯一都id,啟動和關閉不會改變id。如上依次開啟6個redis執行個體。 4.建立叢集 只需在redis-cluster1伺服器上操作

僅需要在redis-cluster1伺服器上安裝gem redis (為來redis-trib可以執行),其他伺服器不用。

gem install redis #預設安裝的版本上3.3(無所謂)

開啟叢集

src/redis-trib.rb create --replicas 1 10.80.67.225:7000 10.80.67.225:7001 10.80.67.230:7002 10.80.67.230:7003 10.80.67.238:7004 10.80.67.238:7005

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

叢集建立完成,運行正常。

[OK] All 16384 slots covered.意味著叢集中的16384個槽至少有一個主節點在處理。

參考Redis叢集官方文檔

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.