redis哨兵の簡単な配置
3034 ワード
redis
:
redis :6.0.4
1 (master)、1 (slave)、3 (sentinel) 。
yum , yum redis,
redis tar.gz , redis src
make & make install。
centos7 gcc 4.8.5, make redis gcc .
1.
(1)master (ip: 192.168.0.1)
bind 0.0.0.0
port 6379
daemonize yes
masterauth "123456"
requirepass 123456
replica-read-only yes
(2)slave (ip: 192.168.0.2)
bind 0.0.0.0
port 6379
daemonize yes
masterauth "123456"
requirepass 123456
replicaof 192.168.0.1 6379
replica-read-only yes
(3)sentinel (ip: 192.168.0.3;192.168.0.4;192.168.0.5)
port 26379
daemonize yes
sentinel monitor mymaster 192.168.0.1 6379 2
sentinel auth-pass mymaster 123456
sentinel down-after-milliseconds mymaster 30000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 180000
2. ( )
master:/opt/redis/bin/redis-server /etc/redis/redis.conf
slave:/opt/redis/bin/redis-server /etc/redis/redis.conf
4 sentinel:/opt/redis/bin/redis-sentinel /etc/redis/redis-sentinel.conf
3. ( redis, , )
(1) , slave, HA( ), 1 slave;
(2) redis :/opt/redis/bin/redis-server --version
(3) redis :info replication ( redis-cli , role)
(4) (sdown): down-after-milliseconds mymaster , 30s sdown,redis 30s
(5) (odown): , , quorum 2 , odwon
(6) , quorum( ) 2, 3 2 odwon
(7) , location, redis server vm box ,
(8) master :
30s : master , rdb ,master write , , aof
30s : master , sdown, odown, slave master,
master , , slave
(9)master down 30s , master/slave / , master , , aof,
( timeout connect refuse ), smtp alert
(10)slave (replica-read-only no), , ,
slave replica-read-only , master side, master
slave, slave master, 。
(12) nginx upstream LB, , nginx LB ( master , ),
app QPS , redis benchmark 10w request , ,
odown 30s ,redis ( master)
(13)app redis connect pool, pool client ,
(14)app redis sentinel 3 sentinel, sentinel master ,
sentinel redis client, client redis (python flask_redis_sentinel)
(15) 3 3 , doc 3 example,
(16) redis + nginx
(17) (master-slave replication) master sync slave side
(18)redis , 16 database, database 0
(19) requirepass, sentinel.conf sentinel auth-pass sentinel monitor
4.
https://redis.io/topics/sentinel
https://github.com/underyx/flask-redis
https://github.com/exponea/flask-redis-sentinel
https://redis-py.readthedocs.io/en/stable/_modules/redis/client.html