windows上安装配置redis群集-创新互联
1. 安装Redis
10余年的玉州网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。成都全网营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整玉州建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联从事“玉州网站设计”,“玉州网站推广”以来,每个客户项目都认真落实执行。https://redis.io/download
将Redis安装在D:\Program Files\Redis\
目录下,然后将exe的可执行文件copy到当前的bin目录,然后配置系统环境变量。
2. 安装Ruby
http://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.2.4-x64.exe
这里将Ruby安装在C:\Ruby22-x64
目录下。
3. 安装Redis的Ruby库
gem install redis
4. 配置Redis Node
copy6份Redis安装目录下的redis.windows-service.conf
文件依次重命名为redis7001.conf、redis7002.conf、redis7003.conf、redis8001.conf、redis8002.conf、redis8003.conf。并分别修改这6个配置文件。具体修改内容如下:
redis7001.conf
port 7001 appendonly yes appendfilename "appendonly7001.aof" cluster-enabled yes cluster-config-file nodes-7001.conf cluster-node-timeout 15000 cluster-slave-validity-factor 10 cluster-migration-barrier 1 cluster-require-full-coverage yes
5. 编辑写以下几个简单的脚步,以方便日常维护。
(1) 安装redis服务脚本:
@echo off echo install redis services "D:\Program Files\Redis\bin\redis-server.exe" --service-install F:\Redis_cluster\7001\redis7001.conf --service-name redis7001 "D:\Program Files\Redis\bin\redis-server.exe" --service-install F:\Redis_cluster\7002\redis7002.conf --service-name redis7002 "D:\Program Files\Redis\bin\redis-server.exe" --service-install F:\Redis_cluster\7003\redis7003.conf --service-name redis7003 "D:\Program Files\Redis\bin\redis-server.exe" --service-install F:\Redis_cluster\8001\redis8001.conf --service-name redis8001 "D:\Program Files\Redis\bin\redis-server.exe" --service-install F:\Redis_cluster\8002\redis8002.conf --service-name redis8002 "D:\Program Files\Redis\bin\redis-server.exe" --service-install F:\Redis_cluster\8003\redis8003.conf --service-name redis8003 @pause
(2) 卸载redis服务脚本:
@echo off echo uninstall redis services "D:\Program Files\Redis\bin\redis-server.exe" --service-uninstall --service-name redis7001 "D:\Program Files\Redis\bin\redis-server.exe" --service-uninstall --service-name redis7002 "D:\Program Files\Redis\bin\redis-server.exe" --service-uninstall --service-name redis7003 "D:\Program Files\Redis\bin\redis-server.exe" --service-uninstall --service-name redis8001 "D:\Program Files\Redis\bin\redis-server.exe" --service-uninstall --service-name redis8002 "D:\Program Files\Redis\bin\redis-server.exe" --service-uninstall --service-name redis8003 @pause
(3) 启动redis 服务脚本
@echo off echo start redis .... "D:\Program Files\Redis\bin\redis-server.exe" --service-start --service-name redis7001 "D:\Program Files\Redis\bin\redis-server.exe" --service-start --service-name redis7002 "D:\Program Files\Redis\bin\redis-server.exe" --service-start --service-name redis7003 "D:\Program Files\Redis\bin\redis-server.exe" --service-start --service-name redis8001 "D:\Program Files\Redis\bin\redis-server.exe" --service-start --service-name redis8002 "D:\Program Files\Redis\bin\redis-server.exe" --service-start --service-name redis8003 echo start redis success @pause
(4) 停止redis服务脚本
@echo off echo stop redis .... "D:\Program Files\Redis\bin\redis-server.exe" --service-stop --service-name redis7001 "D:\Program Files\Redis\bin\redis-server.exe" --service-stop --service-name redis7002 "D:\Program Files\Redis\bin\redis-server.exe" --service-stop --service-name redis7003 "D:\Program Files\Redis\bin\redis-server.exe" --service-stop --service-name redis8001 "D:\Program Files\Redis\bin\redis-server.exe" --service-stop --service-name redis8002 "D:\Program Files\Redis\bin\redis-server.exe" --service-stop --service-name redis8003 echo stop redis success @pause
(5)浏览启动的端口
@echo off echo view redis startup ports netstat -an |find "7001" netstat -an |find "7002" netstat -an |find "7003" netstat -an |find "8001" netstat -an |find "8002" netstat -an |find "8003" @pause
6. 创建Redis Cluster
下载 https://raw.githubusercontent.com/MSOpenTech/redis/3.0/src/redis-trib.rb 脚本到Redis安装目录
D:\Program Files\Redis\bin>redis-trib.rb create --replicas 1 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:8001 127.0.0.1:8002 127.0.0.1:8003 >>> Creating cluster Connecting to node 127.0.0.1:7001: OK Connecting to node 127.0.0.1:7002: OK Connecting to node 127.0.0.1:7003: OK Connecting to node 127.0.0.1:8001: OK Connecting to node 127.0.0.1:8002: OK Connecting to node 127.0.0.1:8003: OK >>> Performing hash slots allocation on 6 nodes... Using 3 masters: 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 Adding replica 127.0.0.1:7001 to 127.0.0.1:8001 Adding replica 127.0.0.1:7002 to 127.0.0.1:8002 Adding replica 127.0.0.1:7003 to 127.0.0.1:8002 M: 49060b7f06bd3839895919a06ba43d0508b1149f 127.0.0.1:7001 slots:0-5460 (5461 slots) master M: 0bfbefc15a586f1a893ef150af43031a7ce04a9f 127.0.0.1:7002 slots:5461-10922 (5462 slots) master M: 5fb098d997e0f0b9e723b09400604344ec65179b 127.0.0.1:7003 slots:10923-16383 (5461 slots) master S: e2d74cfcccf88aef1dec16b1922ca2ad6dc16195 127.0.0.1:8001 replicates 49060b7f06bd3839895919a06ba43d0508b1149f S: bcbe8bf76a5b0d37768556ed752e30dcfea069f6 127.0.0.1:8002 replicates 0bfbefc15a586f1a893ef150af43031a7ce04a9f S: bbfc7026df6822bf3cfd8e4a3549b02ca57f7393 127.0.0.1:8003 replicates 5fb098d997e0f0b9e723b09400604344ec65179b 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 127.0.0.1:7001) M: 49060b7f06bd3839895919a06ba43d0508b1149f 127.0.0.1:7001 slots:0-5460 (5461 slots) master M: 0bfbefc15a586f1a893ef150af43031a7ce04a9f 127.0.0.1:7002 slots:5461-10922 (5462 slots) master M: 5fb098d997e0f0b9e723b09400604344ec65179b 127.0.0.1:7003 slots:10923-16383 (5461 slots) master M: e2d74cfcccf88aef1dec16b1922ca2ad6dc16195 127.0.0.1:8001 slots: (0 slots) master replicates 49060b7f06bd3839895919a06ba43d0508b1149f M: bcbe8bf76a5b0d37768556ed752e30dcfea069f6 127.0.0.1:8002 slots: (0 slots) master replicates 0bfbefc15a586f1a893ef150af43031a7ce04a9f M: bbfc7026df6822bf3cfd8e4a3549b02ca57f7393 127.0.0.1:8003 slots: (0 slots) master replicates 5fb098d997e0f0b9e723b09400604344ec65179b [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered. D:\Program Files\Redis\bin>
到此创建redis cluster 大功告成!
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
标题名称:windows上安装配置redis群集-创新互联
链接分享:http://scyanting.com/article/dsgeoc.html