在Mac上安装Sentinel

這是中文的背景.

在正在开发中的Web系统中,我们使用Redis-Sentinel来实现Redis的冗余备份。由于在共通部分中将会话管理设置为使用Redis-Sentinel,所以改变开发环境的配置是困难的。因此,我们进行了调研,提出了在开发环境中也运行Sentinel的想法。

方式

brew install redis
brew services start redis
redis-sentinel /usr/local/etc/redis-sentinel.conf

请注意

    • 上記だけではSentinelはログイン時に起動はしません(Redisだけ)

 

    redid-sentinel /usr〜で、フォアグラウンドで動作しますが、ターミナル閉じると停止しちゃいます

建立的环境 de

Redis
IP:127.0.0.1
PORT:6379

Sentinel
IP:127.0.0.1
PORT:6379
Master名:mymaster

确认动作的方式

Sentinelへ接続
redis-cli -p 26379

Redisのmasterの情報を取得
sentinel masters

Sentinelと接続解除
quit

Redisへ接続
redis-cli -p 6379

Redisの全key情報を取得
keys *

cloud portal-wwwのTomcatを起動して、ブラウザでアクセス&ログイン

Redisの全key情報を取得して、値が帰ってきていればOK
keys *

以下事项

我最初考虑使用Docker来构建,但由于虚拟网络(在Mac中是docker0?)的原因,Sentinel回答的IP地址会变成虚拟IP地址,所以我放弃了。
作为解决提示,我认为可能是Sentinel配置的ANNOUNCE_IP和Docker网络的host network的设置。
如果有在Mac x Docker上成功搭建Sentinel的朋友,请告诉我。

附加说明

只有在默认安装的情况下才可以通过设置以下文件自动启动Sentinel。

~/Library/LaunchAgents/homebrew.mxcl.redis-sentinel.plist 的中文意思是什么?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>KeepAlive</key>
    <dict>
      <key>SuccessfulExit</key>
      <false/>
    </dict>
    <key>Label</key>
    <string>homebrew.mxcl.redis-sentinel</string>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/local/opt/redis/bin/redis-sentinel</string>
      <string>/usr/local/etc/redis-sentinel.conf</string>
      <string>--daemonize no</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>WorkingDirectory</key>
    <string>/usr/local/var</string>
    <key>StandardErrorPath</key>
    <string>/usr/local/var/log/redis-sentinel.log</string>
    <key>StandardOutPath</key>
    <string>/usr/local/var/log/redis-sentinel.log</string>
  </dict>
</plist>