Redis 3.2.8集群+Sentinel部署

您所在的位置:网站首页 普鲁士的起源与历史 Redis 3.2.8集群+Sentinel部署

Redis 3.2.8集群+Sentinel部署

2024-07-05 14:02:10| 来源: 网络整理| 查看: 265

Redis3.2.8集群搭建

采用官方推荐的三主三从分片方案,本例中所有节点部署在一台主机上。

软件安装:

tar zxvf redis-3.2.8.tar.gz

cd  redis-3.2.8

make

make install 

mkdir redis-cluster

根据端口号,创建六个节点

mkdir redis-cluser/6379、6380、6381、6382、6383、6384

拷贝配置文件到各个节点:

cp redis.conf  redis-cluser/6379、6380、6381、6382、6383、6384

修改配置文件:

vim redis-cluser/6379、6380、6381、6382、6383、6384/redis.conf

port    #端口号

pidfile #pid文件

logfile "/data/local/redis-cluster/6379/redis.log"  #日志文件

cluster-enabled yes  #开启集群模式

cluster-config-file nodes-6380.conf

若需要远程连接,需要注释掉bind 127.0.0.1 改为 bind 0.0.0.0

启动:redis-server 6379、6380、81、82、83、84/redis.conf

 

安装redis-trib.rb工具:

安装依赖组件:yum install ruby ruby-devel rubygems rpm-build

gem install redis

# redis-trib.rb create --replicas 1 127.0.0.1:6379 127.0.0.1:6380 127.0.0.1:6381 127.0.0.1:6382 127.0.0.1:6383 127.0.0.1:6384

创建集群,每个节点有一个从节点

>>> Creating cluster>>> Performing hash slots allocation on 6 nodes...Using 3 masters:127.0.0.1:6379127.0.0.1:6380127.0.0.1:6381Adding replica 127.0.0.1:6382 to 127.0.0.1:6379Adding replica 127.0.0.1:6383 to 127.0.0.1:6380Adding replica 127.0.0.1:6384 to 127.0.0.1:6381M: 46af51f0d193f3e76b322537bc11f9570ca13930 127.0.0.1:6379   slots:0-5460 (5461 slots) masterM: 3caa86acc90199cd882475dc08622fdd522cf9a8 127.0.0.1:6380   slots:5461-10922 (5462 slots) masterM: 01152da2da00e48384714c609241d2f83ca7bdc9 127.0.0.1:6381   slots:10923-16383 (5461 slots) masterS: 825f0c904c8337d6eb8b5685e9b46fe36f7e9e99 127.0.0.1:6382   replicates 46af51f0d193f3e76b322537bc11f9570ca13930S: 0c01889b111948f334950e84aea677658d91f1bc 127.0.0.1:6383   replicates 3caa86acc90199cd882475dc08622fdd522cf9a8S: 567f1760b13de130a63396cc4e6983af5f6bca24 127.0.0.1:6384   replicates 01152da2da00e48384714c609241d2f83ca7bdc9Can I set the above configuration? (type 'yes' to accept):

yes:

>>> Nodes configuration updated>>> Assign a different config epoch to each node>>> Sending CLUSTER MEET messages to join the clusterWaiting for the cluster to join..>>> Performing Cluster Check (using node 127.0.0.1:6379)M: 46af51f0d193f3e76b322537bc11f9570ca13930 127.0.0.1:6379   slots:0-5460 (5461 slots) master   1 additional replica(s)S: 0c01889b111948f334950e84aea677658d91f1bc 127.0.0.1:6383   slots: (0 slots) slave   replicates 3caa86acc90199cd882475dc08622fdd522cf9a8S: 825f0c904c8337d6eb8b5685e9b46fe36f7e9e99 127.0.0.1:6382   slots: (0 slots) slave   replicates 46af51f0d193f3e76b322537bc11f9570ca13930S: 567f1760b13de130a63396cc4e6983af5f6bca24 127.0.0.1:6384   slots: (0 slots) slave   replicates 01152da2da00e48384714c609241d2f83ca7bdc9M: 3caa86acc90199cd882475dc08622fdd522cf9a8 127.0.0.1:6380   slots:5461-10922 (5462 slots) master   1 additional replica(s)M: 01152da2da00e48384714c609241d2f83ca7bdc9 127.0.0.1:6381   slots:10923-16383 (5461 slots) master   1 additional replica(s)[OK] All nodes agree about slots configuration.>>> Check for open slots...>>> Check slots coverage...[OK] All 16384 slots covered.

 

注:使用redis-trib.rb create --replicas 1 这种方式创建主从集群的前提是,至少有6个节点,3主3从

 sentinel

sentinel.conf:

注释默认相关配置,添加master监控:

sentinel monitor master1 127.0.0.1 6379 2sentinel down-after-milliseconds master1 60000sentinel failover-timeout master1 180000sentinel parallel-syncs master1 1sentinel monitor master2 127.0.0.1 6380 2sentinel down-after-milliseconds master2 60000sentinel failover-timeout master2 180000sentinel parallel-syncs master2 1sentinel monitor master3 127.0.0.1 6381 2sentinel down-after-milliseconds master3 60000sentinel failover-timeout master3 180000sentinel parallel-syncs master3 1

 #redis-server sentinel.conf --sentinel &

98310:X 21 Apr 09:50:47.694 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.98310:X 21 Apr 09:50:47.695 # Sentinel ID is 5c014c848accbbec31b53187b9434356f27ad07498310:X 21 Apr 09:50:47.695 # +monitor master master2 127.0.0.1 6380 quorum 298310:X 21 Apr 09:50:47.695 # +monitor master master3 127.0.0.1 6381 quorum 298310:X 21 Apr 09:50:47.695 # +monitor master master1 127.0.0.1 6379 quorum 2

 

配置后台启动:

sentinel.conf,添加:

daemonize yes

启动:

#redis-server sentinel.conf --sentinel 

 

 ========================华丽分割======================

 

Redis 3.2 1主1从配置:

主:

cluster-enabled no

logfile /data/local/redis-cluster/6379/redis.log

requirepass password

从:

cluster-enabled no

logfile /data/local/redis-cluster/6380/redis.log

requirepass password

slaveof 127.0.0.1 6379

masterauth password   必须要注定同步master时的认证密码,否则同步失败。

 

启动redis,查看主从状态:

#redis-cli -p 6380>auth password>info ...# Replicationrole:slavemaster_host:127.0.0.1master_port:6379master_link_status:up...

 



【本文地址】

公司简介

联系我们

今日新闻


点击排行

实验室常用的仪器、试剂和
说到实验室常用到的东西,主要就分为仪器、试剂和耗
不用再找了,全球10大实验
01、赛默飞世尔科技(热电)Thermo Fisher Scientif
三代水柜的量产巅峰T-72坦
作者:寞寒最近,西边闹腾挺大,本来小寞以为忙完这
通风柜跟实验室通风系统有
说到通风柜跟实验室通风,不少人都纠结二者到底是不
集消毒杀菌、烘干收纳为一
厨房是家里细菌较多的地方,潮湿的环境、没有完全密
实验室设备之全钢实验台如
全钢实验台是实验室家具中较为重要的家具之一,很多

推荐新闻


图片新闻

实验室药品柜的特性有哪些
实验室药品柜是实验室家具的重要组成部分之一,主要
小学科学实验中有哪些教学
计算机 计算器 一般 打孔器 打气筒 仪器车 显微镜
实验室各种仪器原理动图讲
1.紫外分光光谱UV分析原理:吸收紫外光能量,引起分
高中化学常见仪器及实验装
1、可加热仪器:2、计量仪器:(1)仪器A的名称:量
微生物操作主要设备和器具
今天盘点一下微生物操作主要设备和器具,别嫌我啰嗦
浅谈通风柜使用基本常识
 众所周知,通风柜功能中最主要的就是排气功能。在

专题文章

    CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭