docker 高可用集群搭建 sentinel
2022/9/7 23:26:45
本文主要是介绍docker 高可用集群搭建 sentinel,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1 首先先准备3 份配置文件 redis6380.conf redis6381.conf redis6382.conf 修改里面的端口号 2 分别启动三台redis 这里设置redis6380为master 因此 我们启动第一台redis的命令为 docker run -d -p 6380:6380 --name node01master -v /mydata/redis/data/:/data -v /mydata/redis/conf/:/etc/redis/ redis redis-server /etc/redis/redis6380.conf 启动redis6381为slave docker run -d -p 6381:6381 --name node02slave -v /mydata/redis/data/:/data -v /mydata/redis/conf/:/etc/redis/ redis redis-server /etc/redis/redis6381.conf --replicaof 192.168.0.137 6380 docker run -d -p 6381:6381 --name node02slave -v /mydata/redis/data:/data -v /mydata/redis/conf/:/etc/redis/ redis redis-server /etc/redis/redis6381.conf --slaveof 192.168.0.137 6380 启动redis6382为slave docker run -d -p 6382:6382 --name node03slave -v /mydata/redis/data/:/data -v /mydata/redis/conf/:/etc/redis/ redis redis-server /etc/redis/redis6382.conf --replicaof 192.168.0.137 6380
docker run -d -p 6382:6382 --name node03slave -v /mydata/redis/data:/data -v /mydata/redis/conf/:/etc/redis/ redis redis-server /etc/redis/redis6382.conf --slaveof 192.168.0.137 6380
、 此时我们三台主从搭建完毕 因为主从无法出现故障时 无法选主 因此我们需要设置哨兵 监控 一旦主节点宕机 我们可以快速选主 实现服务高可用 然后我们需要启动三台哨兵 创建三个配置文件 26380.conf 26381.conf 26382.conf 并分别赋予他们写权限 scp ./26381.conf 192.168.0.138:/mydata/redis/conf 修改端口 和 主机地址
scp ./26382.conf 192.168.0.139:/mydata/redis/conf
chmod 777 26380.conf 然后执行 node01执行 docker run --name redis26380-sentinel -v /mydata/redis/conf/:/etc/redis -d redis redis-server /etc/redis/26380.conf --sentinel docker run -p 26380:26380 --restart=always --name redis26380-sentinel -v /mydata/redis/conf/:/etc/redis -v /mydata/redis/data:/data -d redis redis-sentinel /etc/redis/26380.conf
node02执行 docker run --name redis26381-sentinel -v /mydata/redis/conf/:/etc/redis -d redis redis-server /etc/redis/26381.conf --sentinel
docker run -p 26381:26381 --restart=always --name redis26381-sentinel -v /mydata/redis/conf/:/etc/redis -v /mydata/redis/data:/data -d redis redis-sentinel /etc/redis/26381.conf
node03执行 docker run --name redis26382-sentinel -v /mydata/redis/conf/:/etc/redis -d redis redis-server /etc/redis/26382.conf --sentinel
docker run -p 26382:26382 --restart=always --name redis26382-sentinel -v /mydata/redis/conf/:/etc/redis -v /mydata/redis/data:/data -d redis redis-sentinel /etc/redis/26382.conf
Sep 2022 04:29:57.902 * Running mode=sentinel, port=26379. 1:X 07 Sep 2022 04:29:57.903 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 1:X 07 Sep 2022 04:29:57.903 # Could not create tmp config file (Permission denied) 1:X 07 Sep 2022 04:29:57.904 # WARNING: Sentinel was not able to save the new configuration on disk!!!: Permission denied 1:X 07 Sep 2022 04:29:57.904 # Sentinel ID is 7aa3ddfffe6517d1fac8141588d6420cb18519d0 1:X 07 Sep 2022 04:29:57.904 # +monitor master mymaster 192.168.0.137 6380 quorum 2 1:X 07 Sep 2022 04:29:57.906 * +slave slave 192.168.0.138:6381 192.168.0.138 6381 @ mymaster 192.168.0.137 6380 1:X 07 Sep 2022 04:29:57.906 # Could not create tmp config file (Permission denied) 1:X 07 Sep 2022 04:29:57.906 # WARNING: Sentinel was not able to save the new configuration on disk!!!: Permission denied 1:X 07 Sep 2022 04:29:57.906 * +slave slave 192.168.0.139:6382 192.168.0.139 6382 @ mymaster 192.168.0.137 6380 1:X 07 Sep 2022 04:29:57.906 # Could not create tmp config file (Permission denied) 1:X 07 Sep 2022 04:29:57.906 # WARNING: Sentinel was not able to save the new configuration on disk!!!: Permission denied
这篇关于docker 高可用集群搭建 sentinel的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-14Docker端口:你真的公开了哪些东西?
- 2024-11-14用DOCKER在家里的实验室里搞些酷炫的玩意儿
- 2024-11-05掌握Docker:高效安全的十大最佳实践
- 2024-11-05在 Docker Compose 中怎么设置端口映射-icode9专业技术文章分享
- 2024-11-05在 Docker Compose 中怎么设置环境变量-icode9专业技术文章分享
- 2024-11-04Docker环境部署项目实战:新手入门教程
- 2024-11-04Docker环境部署资料:新手入门教程
- 2024-11-01Docker环境部署教程:新手入门指南
- 2024-11-01超越Docker:苹果芯片上的模拟、编排和虚拟化方案讲解
- 2024-11-01Docker环境部署:新手入门教程