ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

docker-compose部署redis-cluster

2019-09-04 14:03:04  阅读:319  来源: 互联网

标签:compose etc redis cluster home docker local smb


node1-node6

1.到http://download.redis.io/redis-stable/redis.conf下载官方redis.conf文件

2.修改对应端口

# bind 127.0.0.1 //加上注释#
protected-mode no //关闭保护模式
port 6061  //绑定自定义端口
# daemonize yes //禁止redis后台运行
pidfile /var/run/redis_6061.pid 
cluster-enabled yes //开启集群 把注释#去掉
cluster-config-file nodes_6061.conf //集群的配置 配置文件首次启动自动生成 
appendonly yes //开启aof
cluster-announce-ip 10.xx.xx.xx   //要宣布的IP地址。nat模式要指定宿主机IP
cluster-announce-port 6061  //要宣布的数据端口。
cluster-announce-bus-port 16061  //要宣布的集群总线端口

3.docker-compose.yml

version: '3.4'
services:
  node1:
    image: redis:5.0.5
    container_name: redis-node1
    restart: always
    ports:
      - 6061:6061
      - 16061:16061
    volumes:
      - /home/smb/data/redis-cluster/node1:/data
      - /home/smb/config/redis-cluster/node1:/usr/local/etc/redis
    command:
      redis-server /usr/local/etc/redis/redis.conf
      
  node2:
    image: redis:5.0.5
    container_name: redis-node2
    restart: always
    ports:
      - 6062:6062
      - 16062:16062
    volumes:
      - /home/smb/data/redis-cluster/node2:/data
      - /home/smb/config/redis-cluster/node2:/usr/local/etc/redis
    command:
      redis-server /usr/local/etc/redis/redis.conf
      
      
  node3:
    image: redis:5.0.5
    container_name: redis-node3
    restart: always
    ports:
      - 6063:6063
      - 16063:16063
    volumes:
      - /home/smb/data/redis-cluster/node3:/data
      - /home/smb/config/redis-cluster/node3:/usr/local/etc/redis
    command:
      redis-server /usr/local/etc/redis/redis.conf
      
  node4:
    image: redis:5.0.5
    container_name: redis-node4
    restart: always
    ports:
      - 6064:6064
      - 16064:16064
    volumes:
      - /home/smb/data/redis-cluster/node4:/data
      - /home/smb/config/redis-cluster/node4:/usr/local/etc/redis 
    command:
      redis-server /usr/local/etc/redis/redis.conf
      
  node5:
    image: redis:5.0.5
    container_name: redis-node5
    restart: always
    ports:
      - 6065:6065
      - 16065:16065
    volumes:
      - /home/smb/data/redis-cluster/node5:/data
      - /home/smb/config/redis-cluster/node5:/usr/local/etc/redis
    command:
      redis-server /usr/local/etc/redis/redis.conf
      
  node6:
    image: redis:5.0.5
    container_name: redis-node6
    restart: always
    ports:
      - 6066:6066
      - 16066:16066
    volumes:
      - /home/smb/data/redis-cluster/node6:/data
      - /home/smb/config/redis-cluster/node6:/usr/local/etc/redis
    command:
      redis-server /usr/local/etc/redis/redis.conf

4. docker run --rm -it zvelo/redis-trib create --replicas 1 ip1:6061 ip2:6062 ip3:6063 ip4:6064 ip5:6065 ip6:6066

标签:compose,etc,redis,cluster,home,docker,local,smb
来源: https://www.cnblogs.com/tswcypy/p/11458704.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有