首页 > 其他分享 >docker 高可用集群搭建 sentinel

docker 高可用集群搭建 sentinel

时间:2022-09-07 16:35:10浏览次数:81  
标签:mydata redis etc 集群 conf sentinel -- docker data

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 

3 启动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



4 启动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

 

 

标签:mydata,redis,etc,集群,conf,sentinel,--,docker,data
From: https://www.cnblogs.com/Lcch/p/16665006.html

相关文章

  • Docker笔记
    1.Docker入门1.1.Docker概述Docker为什么出现?一款产品:开发–上线两套环境应用环境应用配置!开发—运维问题:我在我的电脑上可以运行版本更新导致服务不......
  • 搭建Docker的图形化管理工具——Portainer
    一、下载Portainer镜像#查询Portainer镜像,这里选择stars最高的,第二个是汉化版,可自行选择dockersearchportainer#拉取镜像dockerpullportainer/portainer二......
  • redis集群部署文档
    1.部署的服务器ip地址172.16.0.151172.16.0.173172.16.0.2202.redis版本wgethttps://download.redis.io/releases/redis-6.2.5.tar.gz3.部署架......
  • kafka集群部署
    kafka集群1.部署的服务器ip地址 172.16.0.220 172.16.0.66 172.16.0.252.kafka版本 https://www.apache.org/dyn/closer.cgi?path=/kafka/3.2.0/kafka_2.13-3.2.0......
  • etcd集群部署文档
    1.部署的服务器ip地址172.16.0.151172.16.0.173172.16.0.2202.etcd版本 wgethttps://github.com/etcd-io/etcd/releases/download/v3.5.0/etcd-v3.5.0-li......
  • mongos集群部署
    mongos分片服务器https://blog.csdn.net/weixin_49724150/article/details/1217483651.部署的服务器ip地址172.16.0.151172.16.0.173172.16.0.2202.......
  • zookeeper集群部署
    1.部署的服务器ip地址172.16.0.151172.16.0.173172.16.0.2202.zookeeper版本wgethttps://mirrors.bfsu.edu.cn/apache/zookeeper/zookeeper-3.7.1/ap......
  • 【2022.09.07】使用docker搭建一个mastodon
    前提准备一个公网ip的服务器(得要有80端口的转发,因此homelab很难实现)我这里使用的是腾讯云的1核2G的学生机域名,及其SSL证书宝塔安装因为嫌麻烦,所以采用了宝塔的方案,顺......
  • Ceph集群应用基础-CephFS文件存储
    在mgr1上安装ceph-mds服务,可以和其他服务器混用(如ceph-mon、ceph-mgr)root@mgr1:~#apt-cachemadisonceph-mdsroot@mgr1:~#aptinstallceph-md=16.2.10-1bionic把mgr......
  • redis 集群安装
    1.前期准备安装ruby升级ruby参见前一篇前期准备#EPEL源安装ruby支持yuminstallrubyrubygems-y使用国内源gemsource-ahttp://mirrors.aliyun.com/rubyge......