草庐IT

notifications - Redis 哨兵 : Master name in notifications

coder 2023-11-08 原文

当 Redis Sentinel 通知事件时,它不会提供 Redis 主节点的名称。

配置摘录:

# sentinel notification-script <master-name> <script-path>
#
# Call the specified notification script for any sentinel event that is
# generated in the WARNING level (for instance -sdown, -odown, and so forth).
# This script should notify the system administrator via email, SMS, or any
# other messaging system, that there is something wrong with the monitored
# Redis systems.
#
# The script is called with just two arguments: the first is the event type
# and the second the event description.

所以只有事件类型(例如 +odown )和事件描述,在 +odown 的情况下就是master .不知何故,我觉得这缺少重要信息。我们不仅要通知用户发生了某些变化,还要通知用户变化的位置

您不能注册带有附加参数的脚本,例如

sentinel notification-script <master-name> "<script-path> <master-name>"

Redis会把这个值作为一个整体来使用,检查它是否存在,是否可执行。

我们通过创建小包装脚本解决了这个问题,每个主实例一个。

$ cat /some/path/notify-master42.sh
#!/bin/sh
/some/path/notify.sh master42 $1 $2

然后这个包装器脚本附加到主服务器:

sentinel notification-script <master-name> notification-script /some/path/notify-<master-name>.sh

这有点不舒服,但还不算太糟糕,只要您有固定数量的母版并且不通过网络即时创建它们即可。

您只需通过网络与哨兵交互即可注册新主人。 ( redis-cli -h <host> -p <port> sentinel whatever... ) 但是创建这些包装器脚本更加复杂。并不是说这是不可能的,但感觉就像是白白跳了起来。

有没有办法通知包括主名称:

  • 不给redis打补丁
  • 没有包装脚本

?

最佳答案

是的,您可以通过使用正确的事件来完成。

“所以只有事件类型(例如 +odown)和事件描述,在 +odown 的情况下就是 master。不知怎的,我觉得这缺少重要信息。我们不只是想通知用户某些事情变了,但变了的地方。”

在 +odown 的情况下, 没有其他信息。所有+odown 的意思是主服务器宕机了。在这一点上没有其他事情发生。如果您想根据故障转移(发生在+odown之后)更新某些内容,您需要查看相应的事件:< strong="">开关大师。 switch-master 事件是故障转移完成时发生的事情。

直接取自documentation :

switch-master <master name> <oldip> <oldport> <newip> <newport> -- The master new IP and address is the specified one after a configuration change. This is the message most external users are interested in.

因此,让您的脚本查找并根据 switch-master 事件采取行动,以获取有关更改内容的信息。不再需要跳过燃烧的铁环。

关于notifications - Redis 哨兵 : Master name in notifications,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32222221/

有关notifications - Redis 哨兵 : Master name in notifications的更多相关文章

  1. ruby-on-rails - 将 Amazon Simple Notification service SNS 与 ruby​​ 结合使用 - 2

    很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visitthehelpcenter.关闭9年前。我需要从基于ruby​​的应用程序使用AmazonSimpleNotificationService,但不知道从哪里开始。您对从哪里开始有什么建议吗?

  2. ruby - 扩展 ActiveSupport::Notifications.subscribe, instantiation.active_record 钩子(Hook) - 2

    我正在探索ActiveSupport::Notifications,并且想要更多关于'instantiation.active_record'的信息,而不仅仅是:record_count和:类名[1].例如,ActiveSupport::Notifications.subscribe/instantiation.active_record/do|*args|args.status#DatabaseorActiveRecordreturnstatusargs.result#Theactualresultsetreturnedargs.etc..#AnyotherinfoIcancolle

  3. ruby-on-rails - 发生异常时发送电子邮件不起作用,使用 exception_notification - 2

    我正在从rails2.3迁移到rails3.1,我试图在生成异常时发送电子邮件。我正在使用exception_notificationgem。我的其余电子邮件都在工作。但是异常邮件不会被解雇。以下是我的staging.rb文件中的设置。config.action_mailer.perform_deliveries=trueconfig.action_mailer.raise_delivery_errors=true下面是application.rb中的代码C::Application.config.middleware.useExceptionNotification::Rack,:e

  4. Redis序列化和java存入Redis数据序列化反序列化总结 - 2

    背景:最近考虑java代码数据在保存redis时,通常要配置序列化,才能保存到redis中,然而我们知道Redis中也有序列化(RDB和AoF两种形式),有点混淆总结一下。java中数据保存redis过程序列化的原因是什么?解释:java虚拟机内存和redis内存是两块独立的内存空间,分属于两个不同的进程,不同的两个应用,在网络传输层表现为数据传输是用TCP二进制流进行传输的序列化最终的目的是为了对象可以跨平台存储,和进行网络传输。 而跨平台存储和网络传输的方式就是IO,而我们的IO支持的数据格式就是字节数组。java中如何序列化?packagecom.gisquest.cloud.oauth

  5. javascript - iPad 的 Safari 上的 Firebase;找不到变量 : Notification - 2

    我使用Firebase的云消息传递,但它不适用于iPad和iPhone。这是我能用它做的最简单的用法。我刚刚完成了所有关于异地通知的教程,但我直接在Firebase的脚本中得到了这个错误. 最佳答案 iOS不支持通知APIhttps://caniuse.com/#search=Notification我创建了一个函数,让您知道用户的浏览器是否支持它。constisSupported=()=>'Notification'inwindow&&'serviceWorker'innavigator&&'PushManager'inwindo

  6. javascript - 恩伯斯 : how to display loading spinner and notification messages on model operations - 2

    我正在使用ember.js1.2,在对我的模型进行CRUD操作期间尝试显示加载微调器和通知消息时遇到问题。代码如下:varMyModelController=Ember.ObjectController.extend({needs:['application'],application:Ember.computed.alias("controllers.application"),actions:{save:function(){var_this=this;//Displaythespinnerthis.get('application').get('loading').trigger

  7. javascript - ionic 2 : Local notification icon - 2

    我使用这个插件来获得本地通知:https://github.com/katzer/cordova-plugin-local-notifications/wiki/03.-Installation我想在我的通知中有一个特定的图标。它位于我的/www/assets/images/文件夹中。我尝试过这种方式,但它不起作用,我有一个带铃铛的方形图标:publicschedule(){cordova.plugins.notification.local.schedule({title:"NewMessage",message:"Hi,areyouready?Wearewaiting.",soun

  8. javascript - node.js + socket.io + redis + rails — 实时应用程序 - 2

    我需要向我的应用程序(RubyOnRails)添加实时性,因此,我认为更好的方法是使用node.js+socket.io+redis。我在后端(node.js)中有这个application.js文件varapp=require('http').createServer();vario=require('socket.io');varredis=require('redis').createClient();var_=require('underscore')._;io=io.listen(app);io.configure(function(){io.set("transports"

  9. javascript - 使用 chrome.notifications.create 时出错 "Uncaught TypeError: Cannot read property ' create' of undefined" - 2

    您好,我在chrome应用的js函数中调用chrome.notifications.create时出错。可以在函数外部正常使用,但在函数内部时出现以下错误:UncaughtTypeError:Cannotreadproperty'create'ofundefined代码如下:document.addEventListener('DOMContentLoaded',function(){document.getElementById('submit').addEventListener('click',submit);});functionsubmit(){varoptions={typ

  10. Redis【缓存雪崩,缓存穿透,缓存击穿】详解 - 2

    用户请求的缓存正常流程图 上图是一个正常的简单的缓存流程!!!土豆用户去访问某宝,某宝请求redis看看缓存中有没有土豆用户请求的数据,如果redis中有该数据的缓存,则直接返回数据展示出来供应用户的需求,如果redis中没有该用户请求的数据,redis就会做一件事,去数据库中进行查找,数据库中查到值了之后做两件事情,第一件事:把数据返回到redis缓存中。第二件事:把查询到的数据返回到某宝中供用户的需求缓存雪崩: 举个例子:用户在双十二的时候,想去某宝抢购商品,用户点进去进入首页展示出了各种各样的商品,这些商品大部分都是缓存在redis中,对应了着很多key,加入这些key的缓存时间是三个小

随机推荐