1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Pythonからredis SentinelのMaster確認

Last updated at Posted at 2019-09-04

ローカルのredisにPythonから接続確認ができます。

>>> from redis.sentinel import Sentinel
>>> sentinel = Sentinel([('localhost', 26379)], stream_timeout=0.1)
>>> sentinel.discover_master('mymaster')
('xxx.xxx.xxx.xxx', 6379)

接続できてないときはNotFoundErrorが出ます。

>>> sentinel.discover_master('mymaster')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/redis/sentinel.py", line 220, in discover_master
redis.sentinel.MasterNotFoundError: No master found for 'mymaster'

その他詳しくはこちら
https://pypi.org/project/redis/

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?