Skip to content

Commit 9518dab

Browse files
authored
Merge pull request #1214 from jdelStrother/jdelStrother-patch-1
Add some more examples of sentinel auth to the readme
2 parents d40e20b + bda5dc9 commit 9518dab

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,25 @@ but a few so that if one is down the client will try the next one. The client
120120
is able to remember the last Sentinel that was able to reply correctly and will
121121
use it for the next requests.
122122

123-
If you want to [authenticate](https://redis.io/topics/sentinel#configuring-sentinel-instances-with-authentication) Sentinel itself, you must specify the `password` option per instance.
123+
To [authenticate](https://redis.io/docs/management/sentinel/#configuring-sentinel-instances-with-authentication) Sentinel itself, you can specify the `username` and `password` options per instance. Exclude the `username` option if you're using password-only authentication.
124124

125125
```ruby
126-
SENTINELS = [{ host: '127.0.0.1', port: 26380, password: 'mysecret' },
127-
{ host: '127.0.0.1', port: 26381, password: 'mysecret' }]
126+
SENTINELS = [{ host: '127.0.0.1', port: 26380, username: 'appuser', password: 'mysecret' },
127+
{ host: '127.0.0.1', port: 26381, username: 'appuser', password: 'mysecret' }]
128128

129129
redis = Redis.new(name: 'mymaster', sentinels: SENTINELS, role: :master)
130130
```
131131

132+
If you specify a username and/or password at the top level for your main Redis instance, Sentinel will default to using those credentials. You can pass nil or override them for each sentinel.
133+
134+
```ruby
135+
# Use 'mysecret' to authenticate against the mymaster instance, but skip authentication for the sentinels:
136+
SENTINELS = [{ host: '127.0.0.1', port: 26380, password: nil },
137+
{ host: '127.0.0.1', port: 26381, password: nil }]
138+
139+
redis = Redis.new(name: 'mymaster', sentinels: SENTINELS, role: :master, password: 'mysecret')
140+
```
141+
132142
Also the name can be passed as an url:
133143

134144
```ruby

0 commit comments

Comments
 (0)