網站首頁 編程語言 正文
docker 部署redis集群
1、創建redis網卡
docker network create redis --subnet 172.38.0.0/16 查看網卡信息 docker network ls docker network inspect redis
2、創建redis配置
#使用腳本創建6個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
啟動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 #使用命令啟動六個 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、創建redis集群
使用cluster 集群配置
#進入某一個redis容器后執行 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
測試
redis-cli -c #連接redis集群 cluster info #查看集群信息 cluster nodes #查看主從信息 set a 11 #查看存入到那個ip中 停掉服務后 在get get a
原文鏈接:https://www.cnblogs.com/Kuju/p/15979295.html
相關推薦
- 2023-10-12 nvm的作用、下載、使用、以及Mac使用時遇到commond not found:nvm如何解決
- 2022-12-08 python?datetime?和時間戳互相轉換問題_python
- 2022-03-19 K8S中五種控制器的介紹以及使用_云其它
- 2022-08-28 詳解Python獲取線程返回值的三種方式_python
- 2022-10-28 UpdateLayeredWindow實現任意異形窗口使用詳解_C#教程
- 2022-01-16 meteor node node-gyp bindings.node dll報錯解決方案
- 2024-04-06 linux中redis重啟,啟動,停止的sh腳本
- 2022-08-07 C++文件的數據寫入和文件的數據讀取的方法實現_C 語言
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支