本文主要跟大家講訴的是如何搭建redis集群的方法以及在此過程中需要注意的問題,非常不錯,推薦給大家,有需要的小伙伴可以來參考下
這裡,在一個Linux虛擬機器上搭建6個節點的redis偽集群,思路很簡單,一台虛擬機器上開啟6個redis實例,每個redis實例都有自己的連接埠。這樣的話,相當於模擬出了6台機器了,然後在以這6個實例組成redis集群就可以了。
前提:redis已經安裝,目錄為/usr/local/redis-4.0.1 如不會,可以參考一下文章 windows下安裝redis Linux下安裝redis
redis叢集是用的ruby腳本,所以要想執行該腳本,需要ruby環境。對應redis的源碼src目錄下的redis-trib.rb,redis-trib.rb是redis官方推出的管理redis集群的工具,是基於redis提供的集群命令封裝成簡單、便捷、實用的操作工具。 so
安裝ruby環境:
1.yum install ruby
2 .yum install rubygems
3.gem install redis
〔 # Centos預設支援ruby到2.0.0,redis需要最低是2.2.2。解決方法是先安裝rvm 再把ruby版本升級到2.3.3
1.
sudo yum install curl 〠# install curl
##curl -L get.rvm.io | bash -s stable
source /usr/local/rvm/scripts/rvm
## 4.查看rvm庫中已知的ruby版本
rvm list known
5.安裝一個1by版本
# 5.安裝一個版本
5. ##rvm install 2.3.3
6.使用一個ruby版本
rvm use 2.3.3
#知版本
rvm remove 2.0.0
8.查看版本
ruby --version
#
ruby --version
# # 9.再安裝redis
gem install redis
gem install redis
分別修改節點下redis-conf文件,由於
在一台機器(192.16819.129)上,因此每個實例應該有不同的連接埠;同時,每個實例顯然會有自己的存放資料的地方;開啟AOF模式;開啟叢集配置;開啟後台模式;
開啟redis服務,看看是否能啟動。 ok沒問題。
建立startall.sh腳本(提示permission denied說明權限不足,執行指令chmod 777 startall.sh修改權限)
# 啟動startall.sh腳本
# 建立stopall.sh腳本
- ## 建立叢集
- 接下來,我們要透過Ruby腳本來建立叢集了。
-
- create :建立叢集
- check :檢查叢集
- info :查看叢集資訊
- fix :修正叢集
- ##reshard :線上遷移slot
- rebalance :平衡叢集節點slot數量
- add-node :將新節點加入叢集
- del-node :從叢集中刪除節點#############set-timeout :設定叢集節點間心跳連接的逾時時間##### #######call :在叢集全部節點上執行指令############import :將外部redis資料匯入叢集###
redis-trib.rb mainly has two classes: ClusterNode
and RedisTrib
. ClusterNode
saves the information of each node, RedisTrib
is the implementation of each function of redis-trib.rb
Note: It prompts at least 3 master cluster nodes. It was said that 6 are created before, but in actual operation I only created 3 nodes, so it can be concluded that when we create a redis cluster, we need at least three master nodes, and it should be an odd number, so, no Be lazy and create three more.
Special note: The key here is the optional replicas parameter. --replicas 2 means to allocate 2 slaves to each master. replicas means how many slaves are needed. It can be successfully created without filling in this parameter, so there are three masters. We will introduce the replicas parameter later
First of all, --replicas 1 1 actually represents a ratio, which is the number of master nodes/ The proportion of slave nodes. So think about it, when creating a cluster, which nodes are the master nodes? Which nodes are slave nodes? The answer is that the order of IP:PORT in the command will be followed, first 3 master nodes, then 3 slave nodes.
Secondly, pay attention to the concept of slot in the picture. For Redis cluster, slot is a place to store data, it is a slot. For each Master, there will be a slot range, but the Slave does not. In the Redis cluster, the Master can still read and write, while the Slave can only read. The writing of data is actually distributed and stored in slots, which is different from the previous master-slave mode of 1.X (Master/Slave data storage in master-slave mode is completely consistent), because 3 The data storage of each Master is different. This will be verified in subsequent essays.
以上是redis集群搭建教學及遇到的問題處理的詳細內容。更多資訊請關注PHP中文網其他相關文章!

pythonlistscanStoryDatatepe,ArrayModulearRaysStoreOneType,and numpyArraySareSareAraysareSareAraysareSareComputations.1)列出sareversArversAtileButlessMemory-Felide.2)arraymoduleareareMogeMogeNareSaremogeNormogeNoreSoustAta.3)

WhenyouattempttostoreavalueofthewrongdatatypeinaPythonarray,you'llencounteraTypeError.Thisisduetothearraymodule'sstricttypeenforcement,whichrequiresallelementstobeofthesametypeasspecifiedbythetypecode.Forperformancereasons,arraysaremoreefficientthanl

pythonlistsarepartofthestAndArdLibrary,herilearRaysarenot.listsarebuilt-In,多功能,和Rused ForStoringCollections,而EasaraySaraySaraySaraysaraySaraySaraysaraySaraysarrayModuleandleandleandlesscommonlyusedDduetolimitedFunctionalityFunctionalityFunctionality。

ThescriptisrunningwiththewrongPythonversionduetoincorrectdefaultinterpretersettings.Tofixthis:1)CheckthedefaultPythonversionusingpython--versionorpython3--version.2)Usevirtualenvironmentsbycreatingonewithpython3.9-mvenvmyenv,activatingit,andverifying

Pythonarrayssupportvariousoperations:1)Slicingextractssubsets,2)Appending/Extendingaddselements,3)Insertingplaceselementsatspecificpositions,4)Removingdeleteselements,5)Sorting/Reversingchangesorder,and6)Listcomprehensionscreatenewlistsbasedonexistin

NumPyarraysareessentialforapplicationsrequiringefficientnumericalcomputationsanddatamanipulation.Theyarecrucialindatascience,machinelearning,physics,engineering,andfinanceduetotheirabilitytohandlelarge-scaledataefficiently.Forexample,infinancialanaly

useanArray.ArarayoveralistinpythonwhendeAlingwithHomoGeneData,performance-Caliticalcode,orinterfacingwithccode.1)同質性data:arraysSaveMemorywithTypedElements.2)績效code-performance-calitialcode-calliginal-clitical-clitical-calligation-Critical-Code:Arraysofferferbetterperbetterperperformanceformanceformancefornallancefornalumericalical.3)

不,notalllistoperationsareSupportedByArrays,andviceversa.1)arraysdonotsupportdynamicoperationslikeappendorinsertwithoutresizing,wheremactsperformance.2)listssdonotguaranteeconecontanttanttanttanttanttanttanttanttanttimecomplecomecomplecomecomecomecomecomecomplecomectacccesslectaccesslecrectaccesslerikearraysodo。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

記事本++7.3.1
好用且免費的程式碼編輯器

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

SublimeText3漢化版
中文版,非常好用

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能