網(wǎng)站首頁(yè) 編程語(yǔ)言 正文
docker 部署redis集群
1、創(chuàng)建redis網(wǎng)卡
docker network create redis --subnet 172.38.0.0/16 查看網(wǎng)卡信息 docker network ls docker network inspect redis
2、創(chuàng)建redis配置
#使用腳本創(chuàng)建6個(gè)redis配置 for port in $(seq 1 6); \ do \ mkdir -p /Users/nlsg/sinan/workCode/docker/redis/node-${port}/conf touch /Users/nlsg/sinan/workCode/docker/redis/node-${port}/conf/redis.conf cat << EOF >>/Users/nlsg/sinan/workCode/docker/redis/node-${port}/conf/redis.conf port 6379 bind 0.0.0.0 cluster-enabled yes cluster-config-file nodes.conf cluster-node-timeout 5000 cluster-announce-port 6379 cluster-announce-bus-port 16379 appendonly yes EOF done
啟動(dòng)redis
docker run -p 6371:6379 -p 16371:16379 --name redis-1 \ -v /Users/nlsg/sinan/workCode/docker/redis/node-1/data:/data \ -v /Users/nlsg/sinan/workCode/docker/redis/node-1/conf/redis.conf:/etc/redis/redis.conf \ -d --net redis --ip 172.38.0.11 redis:5.0.9-alpine3.11 redis-server /etc/redis/redis.conf #使用命令啟動(dòng)六個(gè) for port in $(seq 1 6); \ do \ docker run -p 637${port}:6379 -p 1637${port}:16379 --name redis-${port} \ -v /Users/nlsg/sinan/workCode/docker/redis/node-${port}/data:/data \ -v /Users/nlsg/sinan/workCode/docker/redis/node-${port}/conf/redis.conf:/etc/redis/redis.conf \ -d --net redis --ip 172.38.0.1${port} redis:5.0.9-alpine3.11 redis-server /etc/redis/redis.conf done
3、創(chuàng)建redis集群
使用cluster 集群配置
#進(jìn)入某一個(gè)redis容器后執(zhí)行 docker exec -it redis-1 /bin/sh #/bin/bash redis-cli --cluster create 172.38.0.11:6379 172.38.0.12:6379 172.38.0.13:6379 172.38.0.14:6379 172.38.0.15:6379 172.38.0.16:6379 --cluster-replicas 1
測(cè)試
redis-cli -c #連接redis集群 cluster info #查看集群信息 cluster nodes #查看主從信息 set a 11 #查看存入到那個(gè)ip中 停掉服務(wù)后 在get get a
原文鏈接:https://www.cnblogs.com/Kuju/p/15979295.html
相關(guān)推薦
- 2022-08-17 WPF實(shí)現(xiàn)Interaction框架的Behavior擴(kuò)展_C#教程
- 2024-07-13 spring實(shí)現(xiàn)定時(shí)任務(wù)的動(dòng)態(tài)可配置、可刪除、可啟用停用功能
- 2022-06-25 pytorch中permute()函數(shù)用法補(bǔ)充說明(矩陣維度變化過程)_python
- 2022-05-06 Python實(shí)現(xiàn)提取Excel指定關(guān)鍵詞的行數(shù)據(jù)_python
- 2023-06-02 關(guān)于pip安裝opencv-python遇到的問題_python
- 2022-07-19 Python?assert斷言聲明,遇到錯(cuò)誤則立即返回問題_python
- 2022-07-18 Linux文件系統(tǒng)和日志分析
- 2023-03-26 數(shù)據(jù)結(jié)構(gòu)TypeScript之鄰接表實(shí)現(xiàn)示例詳解_其它
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲(chǔ)小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡(jiǎn)單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對(duì)象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支