Redis三主三从集群搭建

本文详细介绍了如何在Linux环境下,特别是Centos系统上搭建Redis的三主三从集群。通过步骤包括系统环境准备、安装Redis、配置集群、解决搭建过程中遇到的问题以及测试集群的稳定性和故障转移功能。
摘要由CSDN通过智能技术生成

一,Redis的的的的简介

官网给的定义大概意思是:Redis的的的的是一个开源,内存数据结构存储,用作数据库,缓存和消息代理它支持的数据结构有:字符串,哈希,列表,集合,有序集合,位图,超级日志和具有半径查询的地理空间索引.Redis是一个高性能的支持主从同步的键 - 值数据库。


二,集群搭建

1>系统环境 

本地用的VirtualBox虚拟虚拟的安装三台配置一样的的的Centos下的虚拟机




查看版本:



2>三主三从架构说明

三台服务器,启动6个实例,形成三主三从,其中存储相同数据的主从节点不能落在同一台机器上,目的是防止部署的Redis的的的的虚拟机宕机从而造成主从节点全部失效实验机器的地址与端口如下:


         IP端口

10.252.21.154 7000

10.252.21.154 7001

10.252.21.156 7000

10.252.21.156 7001

10.252.21.157 7000

10.252.21.157 7001


3>安装

在三台机器上全部执行如下操作:

搭建 Redis 三主三集群的命令如下: 1. 启动 6 个 Redis 服务,分别监听不同的端口(例如 7000、7001、7002、7003、7004、7005): ``` redis-server /path/to/redis.conf ``` 2. 创建 6 个 Redis 配置文件,分别配置监听端口、数据存储路径、集群节点信息等: ``` port 7000 cluster-enabled yes cluster-config-file nodes-7000.conf cluster-node-timeout 5000 appendonly yes dir /path/to/data/7000/ port 7001 cluster-enabled yes cluster-config-file nodes-7001.conf cluster-node-timeout 5000 appendonly yes dir /path/to/data/7001/ port 7002 cluster-enabled yes cluster-config-file nodes-7002.conf cluster-node-timeout 5000 appendonly yes dir /path/to/data/7002/ port 7003 cluster-enabled yes cluster-config-file nodes-7003.conf cluster-node-timeout 5000 appendonly yes dir /path/to/data/7003/ port 7004 cluster-enabled yes cluster-config-file nodes-7004.conf cluster-node-timeout 5000 appendonly yes dir /path/to/data/7004/ port 7005 cluster-enabled yes cluster-config-file nodes-7005.conf cluster-node-timeout 5000 appendonly yes dir /path/to/data/7005/ ``` 3. 将 6 个 Redis 节点加入到集群中: ``` redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 \ 127.0.0.1:7002 127.0.0.1:7003 \ 127.0.0.1:7004 127.0.0.1:7005 --cluster-replicas 1 ``` 其中,`--cluster-replicas 1` 表示每个节点一个节点。 4. 验证集群是否搭建成功: ``` redis-cli -c > cluster info > cluster nodes ``` 如果输出信息中没有出现错误,说明 Redis 集群搭建成功。
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值