redis-cluster安裝比較簡單,主要的過程為
修改redis.conf,需要幾台機器就新建幾個資料夾,我這起了6個
配置如下:
3.啟動節點,配置了幾個節點就啟動幾個
redis-5.0.4/src/redis-server ~/nodes/6379/redis.conf
redis-5.0.4/src/redis-server ~/nodes/6380/redis.conf
redis-5.0.4/src/redis-server ~/nodes/6381/redis.conf
redis-5.0.4/src/redis-server ~/nodes/6382/redis.conf
redis-5.0.4/src/redis-server ~/nodes/6383/redis.conf
redis-5.0.4/src/redis-server ~/nodes/6384/redis.conf
redis-5.0.4/src/redis-server ~/nodes/6385/redis.conf
4.啟動集群,啟動集群有點麻煩,主要redis-cluster用ruby寫的需要2.3.0以上版本,yum源安裝的ruby在2.0.0,需要先安裝ruby,可以先安裝ruby版本管理工具rvm,可以參考這篇安裝rvm,安裝完ruby後執行
gem install redis
安裝完後就可以啟動集群了,然後啟動redis-cli cluster
,老版本應該是redis-trib.rb
命令,啟動集群
redis-5.0.4/src/redis-cli --cluster create 192.168.245.128:6379 192.168.245.128:6380 192.168.245.128:6381 192.168.245.128:6382 192.168.245.128:6383 192.168.245.128:6384
接著redis會顯示分配槽資訊和集群初始化的資訊:
>>> performing hash slots allocation on 6 nodes...
master[0] -> slots 0 - 2730
master[1] -> slots 2731 - 5460
master[2] -> slots 5461 - 8191
master[3] -> slots 8192 - 10922
master[4] -> slots 10923 - 13652
master[5] -> slots 13653 - 16383
m: 1986ebba976f77b4dab84a44bac17623dc430ab0 192.168.245.128:6379
slots:[0-2730] (2731 slots) master
m: 97241dfe9f5ffb78398b4936268f034821ff1b4f 192.168.245.128:6380
slots:[2731-5460] (2730 slots) master
m: aed493eb5e4cdf1a2e71896b67d2d3df4688002c 192.168.245.128:6381
slots:[5461-8191] (2731 slots) master
m: f1e5c142e04be48ee0b2788ad832d6ef2c6ec939 192.168.245.128:6382
slots:[8192-10922] (2731 slots) master
m: da9c3ad1769082c7c47d16731784de6026e46de0 192.168.245.128:6383
slots:[10923-13652] (2730 slots) master
m: 9a4552a184647f080e9d280e74bceafd974bd1a5 192.168.245.128:6384
slots:[13653-16383] (2731 slots) master
can i set the above configuration? (type 'yes' to accept): yes
>>> nodes configuration updated
>>> assign a different config epoch to each node
>>> sending cluster meet messages to join the cluster
waiting for the cluster to join
.....
>>> performing cluster check (using node 192.168.245.128:6379)
m: 1986ebba976f77b4dab84a44bac17623dc430ab0 192.168.245.128:6379
slots:[0-2730] (2731 slots) master
m: 9a4552a184647f080e9d280e74bceafd974bd1a5 192.168.245.128:6384
slots:[13653-16383] (2731 slots) master
m: 97241dfe9f5ffb78398b4936268f034821ff1b4f 192.168.245.128:6380
slots:[2731-5460] (2730 slots) master
m: f1e5c142e04be48ee0b2788ad832d6ef2c6ec939 192.168.245.128:6382
slots:[8192-10922] (2731 slots) master
m: aed493eb5e4cdf1a2e71896b67d2d3df4688002c 192.168.245.128:6381
slots:[5461-8191] (2731 slots) master
m: da9c3ad1769082c7c47d16731784de6026e46de0 192.168.245.128:6383
slots:[10923-13652] (2730 slots) master
[ok] all nodes agree about slots configuration.
>>> check for open slots...
>>> check slots coverage...
[ok] all 16384 slots covered.
可以看到總共6臺機器,都是主,16384個槽分到了6臺機器上.
客戶端隨便輸入連線到哪台機器上
redis-5.0.4/src/redis-cli -h 192.168.245.128 -p 6379
隨便設乙個值
set pmj 'redis'
redis的返回
(error) moved 10386 192.168.245.128:6382
可以看到redis的去中心化是需要客戶端協助完成的,客戶端隨便連一台機器,設定值後,當前伺服器會這個key是不是本機器,如果不是本機器再告訴客戶端應該去哪台機器上設定,如果我們換到連6382這個節點可以看到值設定成功. LINUX安裝安裝YUM。
解決 bash yum command not found錯誤 步驟如下 第一步 python iniparse 0.3.1 2.1.el6.noarch.rpm yum metadata parser 1.1.2 14.1.el6.x86 64.rpm yum 3.2.29 69.el6.cent...
Mysql安裝(yum安裝)
yi 獲取rpm包 以8.0版本為例 檢視軟體包發現預設開啟了8.0版本,選擇自己要裝的版本,更改repo檔案 etc yum.repos.d mysql community.repo 修改想要安裝的版本和8.0版本的enable值。yiki yum y install mysql mysql se...
nginx安裝(yum安裝)
安裝先決條件 yum install y yum utils要設定yum儲存庫,請建立 etc yum.repos.d nginx.repo 包含以下內容的檔案 true預設情況下,使用穩定的nginx軟體包的儲存庫。如果要使用主線nginx軟體包,請執行以下命令 yum config manage...