当前位置:网站首页>非关系型数据库之Redis【redis集群详细搭建】
非关系型数据库之Redis【redis集群详细搭建】
2022-07-28 06:06:00 【捌椒】
Redis集群
1 redis-cluster 架构图
2. redis 集群搭建
2.1 安装 ruby
集群管理工具(redis-trib.rb)是使用ruby脚本语言编写的。
第一步:安装ruby
- [[email protected] bin]# yum install ruby
- [[email protected] bin]# yum install rubygems
第二步:上传 ruby 和 redis 接口文件到 linux 系统

第三步:进入文件目录,安装 ruby 和 redis 接口
- 因为上传到了文件的主目录,所以安装前先切换目录

- 安装:[[email protected] ~]#
gem install redis-3.0.0.gem
第四步:将 redis-3.0.0 包下 src 目录中的以下文件拷贝到 redis0707/redis-cluster/,并查看是否拷贝成功

2.2 搭建集群
写在前面:
搭建集群,只是 ip 和端口的问题。我们想在一台主机上搭建集群做测试,只需要修改端口,使每个redis服务器的端口号不一样即可。
搭建集群最少也得需要 3 台主机,如果每台主机再配置一台从机的话,则最少需要 6 台机器。
端口设计如下:7001-7006
- 第一步:复制出一个7001机器

- 第二步:如果存在持久化文件,则删除

- 第三步:设置集群参数并修改端口:
- vim redis.conf
- 输入/cluster检索集群参数,把 no 改为
yes,记住:把注释#去掉 - 修改集群参数后,输入/port检索端口,然后将端口改成7001,并保存退出。



- 第四步:复制出7002-7006机器

- 第五步:进入7002-7006机器各自的
redis.conf文件,修改端口


- 第六步:启动7001-7006这六台机器


- 第七步:修改 startall.sh 文件的权限
原因:当前startall.sh不可执行- chmod u+x startall.sh

- 第八步:启动

- 第九步:创建集群
ip地址为虚拟机的 ip,1是为每个主机创建一个从机,即3个主机3个从机


3. 连接集群
随便进入一个redis服务器,开启客户端即可。
- ./redis-cli -h 192.168.188.127 -p 7001 -c

4. 检测集群

可以看出,数据被根据hash计算存在了7003号redis服务器中。
5. 关闭集群服务器
- 创建一个关闭脚本,方便以后统一关闭和启动。


边栏推荐
- [JVM optimization ultra detailed] common JVM tuning scenarios
- Tutorial (7.0) 06. Zero trust network access ztna * forticlient EMS * Fortinet network security expert NSE 5
- The first common node of two linked lists -- two questions per day
- xmpp 服务研究(二) prosody 创建账户
- 牛客Mysql——SQL必知必会
- CAS vs Database optimistic lock
- [Google] solve the problem that Google browser does not pop up the account and password save box and cannot save login information
- 细说共模干扰和差模干扰
- 调整数组顺序使奇数位于偶数前面——每日两题
- DNA deoxyribonucleic acid modified platinum nanoparticles ptnps DNA | scientific research reagent
猜你喜欢

DNA-Ag2SQDs脱氧核糖核酸DNA修饰硫化银Ag2S量子点的合成方法

Big talk persistence and redolog

Essential performance optimization topics in the interview~

Matplotlib绘图笔记基础直线、折线、曲线

Which of class A and class B is more stringent in EMC?

Earliest deadline first (EDF)

【google】解决google浏览器不弹出账号密码保存框且无法保存登录信息问题

Shortest seek time first (SSTF)

2022年湖南工学院ACM集训第五次周测AD题题解

ArcGIS JS customizes the accessor and uses the watchutils related method to view the attribute
随机推荐
Disassemble Huawei switches and learn Basic EMC operations
DNA modified noble metal nanoparticles | DNA modified copper nanoparticles cunps-dna | research points
Flowable workflow all business concepts
How to understand CMS collector to reduce GC pause time
教程篇(7.0) 06. 零信任网络访问ZTNA * FortiClient EMS * Fortinet 网络安全专家 NSE 5
Mysql查看某个表所占内存大小
The penultimate node in the linked list - Double finger
Collection | combined with my personal experience, I have summarized these seven EMC related knowledge
[JVM optimization ultra detailed] common JVM tuning scenarios
Introduction to magnetic ring selection and EMC rectification skills
指针进阶练习
4.1.4为什么要将成员变量设置为private
[Google] solve the problem that Google browser does not pop up the account and password save box and cannot save login information
Deeply analyze the implementation of singleton mode
项目经历总结
Matplotlib绘图笔记基础直线、折线、曲线
收藏 | 结合个人经验,我总结了这7点EMC相关知识
华为交换机拆解,学EMC基本操作
Modify the conf file through sed
调整数组顺序使奇数位于偶数前面——每日两题