Windows一键搭建redis集群

创建docker-compose.yml文件

version: '3'

services:

redis-1:

image: redis

container_name: redis-1

ports:

- "7001:7001"

- "17001:17001"

command: redis-server --cluster-enabled yes --cluster-config-file nodes.conf --cluster-node-timeout 5000 --appendonly yes --port 7001 --cluster-announce-ip 11.13.153.169

redis-2:

image: redis

container_name: redis-2

ports:

- "7002:7002"

- "17002:17002"

command: redis-server --cluster-enabled yes --cluster-config-file nodes.conf --cluster-node-timeout 5000 --appendonly yes --port 7002 --cluster-announce-ip 11.13.153.169

redis-3:

image: redis

container_name: redis-3

ports:

- "7003:7003"

- "17003:17003"

command: redis-server --cluster-enabled yes --cluster-config-file nodes.conf --cluster-node-timeout 5000 --appendonly yes --port 7003 --cluster-announce-ip 11.13.153.169

redis-4:

image: redis

container_name: redis-4

ports:

- "7004:7004"

- "17004:17004"

command: redis-server --cluster-enabled yes --cluster-config-file nodes.conf --cluster-node-timeout 5000 --appendonly yes --port 7004 --cluster-announce-ip 11.13.153.169

redis-5:

image: redis

container_name: redis-5

ports:

- "7005:7005"

- "17005:17005"

command: redis-server --cluster-enabled yes --cluster-config-file nodes.conf --cluster-node-timeout 5000 --appendonly yes --port 7005 --cluster-announce-ip 11.13.153.169

redis-6:

image: redis

container_name: redis-6

ports:

- "7006:7006"

- "17006:17006"

command: redis-server --cluster-enabled yes --cluster-config-file nodes.conf --cluster-node-

timeout 5000 --appendonly yes --port 7006 --cluster-announce-ip 11.13.153.169

 其中11.13.153.169为本地局域网ip

创建好文件后在文件目录调用控制台,直接执行docker-compose up -d 

启动成功后随便选个redis容器进入执行

命令redis-cli --cluster create 11.13.153.169:7003 11.13.153.169:7001 11.13.153.169:7002 11.13.153.169:7004 11.13.153.169:7005 11.13.153.169:7006 --cluster-replicas 1

执行后直接输入yes

看到这个就成功了

  • 9
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
一键配置Redis集群通常涉及到使用自动化工具和配置管理脚本来简化集群的部署过程。以下是一个概述: 1. **Redis源码编译**:首先,你需要从Redis官网下载源代码,并按照官方文档编译带有集群支持的版本。 2. **安装和配置**: - **安装**:安装所有需要的依赖,如编译器、系统库等。 - **配置**:创建一个Redis配置文件(例如`/etc/redis/redis.conf`),设置相关参数,如`cluster-enabled yes`开启集群模式,`bind`设置监听地址等。 3. **启动 Sentinel**:Sentinel是Redis的高可用解决方案,用于监控集群节点。你需要安装并配置Sentinel服务,指定被监控的集群节点。 4. **创建集群**: - 使用`redis-cli`或`redis-trib`命令行工具,创建一个新的Redis集群。例如:`redis-trib create --replicas N`,其中`N`是副本数量。 - 分配节点到Sentinel监控组,确保它们可以自动发现故障并进行替换。 5. **脚本自动化**: - 利用Shell、Python或Ansible、Puppet等配置管理工具编写脚本,自动化上述步骤。脚本可能会包括检查节点状态、配置同步、加入或移除节点等操作。 6. **验证和测试**: - 验证集群是否正常运行,通过客户端连接各个节点,执行一些操作以确认数据一致性。 相关问题: 1. Redis集群中Sentinel的主要职责是什么? 2. 如何通过脚本自动化处理Redis节点的添加或删除? 3. 有没有现成的工具或包可以直接一键部署Redis集群
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值