当前位置:网站首页>windows下Redis-cluster集群搭建
windows下Redis-cluster集群搭建
2022-07-05 04:26:00 【十一姐】
一、下載安裝
需要下載如下三個:
Redis、Ruby語言運行環境、Redis的Ruby驅動redis-3.2.2.gem1、Redis-x64-5.0.14.1.zip 下載, 6 臺 redis 服務器,搭建偽集群,並運行在不同的端口 6380-6385

2、Ruby下載,ruby脚本來實現集群搭建,一路next,最後取消勾選,finish,然後cmd裏面輸出
ruby -v代錶安裝成功


3、安裝Redis的Ruby驅動rubygems下載,是一個用於對 Ruby組件進行打包的 Ruby 打包系統;下載後解壓,然後打開命令窗口切換到解壓目錄中,執行命令
ruby setup.rb

二、搭建Redis集群
要讓集群正常運作至少需要3個主節點,建議配置3個主節點,其餘3個作為各個主節點的從節點(也是官網推薦的模式),通過同一臺電腦不同端口模擬
1、新建一個文件夾Redis-cluster,並將前面下載的
Redis-x64-5.0.14.1.zip進行解壓,並將文件夾重命名為6380
2、打開6380目錄下的文件
redis.windows.conf,修改裏面的端口號port為6380,主要改了如下五處,1. port 6380 //修改為與當前文件夾名字一樣的端口號 2. appendonly yes //指定是否在每次更新操作後進行日志記錄,Redis在 默認情况下是异步的把數據寫入磁盤,如果不開啟,可能會在斷電時導4. 致一段時間內的數據丟失。 yes錶示:存儲方式,aof,將寫操作記錄保存到日志中 3. cluster-enabled yes //開啟集群模式 4. cluster-config-file nodes-6380.conf //保存節點配置,自動創建,自動更新(建議命名時加上端口號) 5. cluster-node-timeout 15000 //集群超時時間,節點超過這個時間沒反應就斷定是宕機
3、在6380目錄下新建文件
start.bat,內容如下,用來進入每個端口命名的文件夾下啟動服務title redis-6380 redis-server.exe redis.windows.conf
4、複制6380文件夾,並分別重命名為6381-6385,同時修改各自目錄下的
redis.windows.con與start.bat文件裏面的端口號,將6380替換成對應的6381-6385
5、打開任意cmd窗口執行
gem install redis
6、構建集群脚本,從6380目錄下複制粘貼
redis-cli.exe到Redis-cluster目錄下,同時6380~6385每個目錄下的start.bat文件雙擊運行並不要關閉!!!

7、然後在當前Redis-cluster目錄下打開cmd窗口,執行如下命令,到此集群構建完畢
redis-cli --cluster create 127.0.0.1:6380 127.0.0.1:6381 127.0.0.1:6382 127.0.0.1:6383 127.0.0.1:6384 127.0.0.1:6385 --cluster-replicas 1
三、集群環境測試
- 參考文檔
redis-cli -c -h 127.0.0.1 -p 6380- 查看集群信息:
cluster info - 查看主從關系:
info replication, 集群節點按照從主到從的方式從左到右依次排列6個redis 節點,因此也可以看出6380,6381,6382三個是主節點,6383,6384,6385是三個從節點,對應關系是:主6380從6383 - 查看各個節點分配slot:
cluster nodes
四、將redis-cluster注册生windows服務
控制臺啟動redis server如果控制臺關閉了之後redis server也會一同被關閉,那麼我們就需要讓redis在後臺運行需要將redis server注册為windows服務,然後再start
所以我們用如下方式可以解决上面的問題,到6380-6385目錄下分別重命名服務,並啟動,
請至少保證三個主節點服務已經啟動在後臺,否則會導致連接上redis-cluster,但是連不上裏面的db0# 通過service-name啟動redis服務: redis-server --service-install redis.windows.conf --service-name redis6380 --loglevel verbose redis-server --service-start --service-name redis6380 # 通過service-name停止redis服務: redis-server --service-stop --service-name redis6380

如果服務啟動失敗,以管理員身份打開cmd執行
SC delete 服務名稱,然後當對應目錄重新建服務
五、打開redis可視化工具,如圖連接成功
- 如圖,測試連接成功

- 默認是127.0.0.1可以訪問,如下修改.conf,可以修改bind指定局域網ip訪問,
修改配置後,需要重啟服務方可生效

边栏推荐
- 【虚幻引擎UE】打包报错出现!FindPin错误的解决办法
- About the project error reporting solution of mpaas Pb access mode adapting to 64 bit CPU architecture
- Judge whether the stack order is reasonable according to the stack order
- Hexadecimal to octal
- Longyuan war "epidemic" 2021 network security competition web easyjaba
- web资源部署后navigator获取不到mediaDevices实例的解决方案(navigator.mediaDevices为undefined)
- WGS84 coordinate system, web Mercator, gcj02 coordinate system, bd09 coordinate system - brief introduction to common coordinate systems
- 【虚幻引擎UE】运行和启动的区别,常见问题分析
- Ctfshow web entry code audit
- [illusory engine UE] method to realize close-range rotation of operating objects under fuzzy background and pit recording
猜你喜欢

Sequence diagram of single sign on Certification Center

Function (basic: parameter, return value)

Aperçu en direct | Services de conteneurs ACK flexible Prediction Best Practices

Kwai, Tiktok, video number, battle content payment

Mxnet imports various libcudarts * so、 libcuda*. So not found

Fonction (sujette aux erreurs)

官宣!第三届云原生编程挑战赛正式启动!

Looking back on 2021, looking forward to 2022 | a year between CSDN and me

Threejs factory model 3DMAX model obj+mtl format, source file download

蛇形矩阵
随机推荐
mxnet导入报各种libcudart*.so、 libcuda*.so找不到
How can CIOs use business analysis to build business value?
Threejs implements labels and displays labels with custom styles
Threejs rendering obj+mtl model source code, 3D factory model
Sequelize. JS and hasmany - belongsto vs hasmany in serialize js
MacBook installation postgresql+postgis
Threejs loads the city obj model, loads the character gltf model, and tweetjs realizes the movement of characters according to the planned route
[phantom engine UE] package error appears! Solutions to findpin errors
[moteur illusoire UE] il ne faut que six étapes pour réaliser le déploiement du flux de pixels ue5 et éviter les détours! (4.26 et 4.27 principes similaires)
[untitled]
[untitled]
函数(易错)
Technical tutorial: how to use easydss to push live streaming to qiniu cloud?
机器学习 --- 决策树
防护电路中的元器件
Rome chain analysis
网络安全-记录web漏洞修复
概率论与数理统计考试重点复习路线
Observable time series data downsampling practice in Prometheus
Open graph protocol