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-12-26alpine构建的镜像无法使用docker exec -it 进入内部怎么办?-icode9专业技术文章分享
- 2024-12-24Docker环境部署资料详解
- 2024-12-24Docker环境部署教程:新手入门详解
- 2024-12-24Docker环境部署项目实战教程
- 2024-12-24Docker环境部署学习:初学者指南
- 2024-12-24Docker环境部署入门:新手必读指南
- 2024-12-20Docker部署资料:新手入门教程
- 2024-12-19Docker部署实战:新手入门教程
- 2024-12-19Docker部署教程:新手入门详解
- 2024-12-09云原生周刊:在Docker上部署大语言模型