原创文章转载请注明来源:https://blog.csdn.net/weixin_41756573/article/details/88782438
#监控主节点名称[name]
#监控主节点IP[host]
#监控主节点[port]
#[n]:至少有n个sentinel节点发现master有故障,才会自动进行sentinel故障转移
#[milliseconds]毫秒ping不同,则主观认为该节点有故障
故障转移后重新进行主从复制
#[n] = 1:代表串行,一个复制完成后,另一个才能复制
#[n] = 2或>2:代表并行,2个同时复制,或者多个同时复制
#从故障转移开始milliseconds毫秒没有完成转移操作,则视为转移失败
daemonize yes
port 26379
bind 0.0.0.0
sentinel monitor mymaster 192.168.145.128 6666 2
sentinel down-after-milliseconds mymaster 30000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 15000
启动sentinel服务的命令:./src/redis-sentinel [配置文件]
./src/redis-cli -p [sentinel服务的端口号]
在sentinel客户端输入 info 命令会出现sentinel节点的相关信息
# Server
redis_version:5.0.3
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:129165fe599a95d
redis_mode:sentinel
os:Linux 3.10.0-862.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:4.8.5
process_id:3852
run_id:7314d5bb4d634df94656b905b15aa4ae9ee32343
tcp_port:26379
uptime_in_seconds:537
uptime_in_days:0
hz:18
configured_hz:10
lru_clock:9993431
executable:/usr/software/redis-5.0.3/./src/redis-sentinel
config_file:/usr/software/redis-5.0.3/sentinel.custom26379.conf
# Clients
connected_clients:3
client_recent_max_input_buffer:2
client_recent_max_output_buffer:0
blocked_clients:0
# CPU
used_cpu_sys:1.650110
used_cpu_user:1.141941
used_cpu_sys_children:0.000000
used_cpu_user_children:0.000000
# Stats
total_connections_received:3
total_commands_processed:1352
instantaneous_ops_per_sec:3
total_net_input_bytes:78650
total_net_output_bytes:8155
instantaneous_input_kbps:0.28
instantaneous_output_kbps:0.02
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
expired_stale_perc:0.00
expired_time_cap_reached_count:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
migrate_cached_sockets:0
slave_expires_tracked_keys:0
active_defrag_hits:0
active_defrag_misses:0
active_defrag_key_hits:0
active_defrag_key_misses:0
# Sentinel
# 主节点
sentinel_masters:1
sentinel_tilt:0
sentinel_running_scripts:0
sentinel_scripts_queue_length:0
sentinel_simulate_failure_flags:0
#主节点的描述信息,slaves=2:两个从节点,sentinels=3:三个sentinel节点
master0:name=mymaster,status=ok,address=192.168.145.128:6666,slaves=2,sentinels=3
3-1:sentinel节点是如何获取以上信息的? →都指向master,获取master中的信息
daemonize yes
port 26379
bind 0.0.0.0
sentinel myid a0b40c1e998b341bfa3ed3cf4e78c5cf226fae38
sentinel deny-scripts-reconfig yes
sentinel monitor mymaster 192.168.145.128 6666 2
sentinel failover-timeout mymaster 15000
# Generated by CONFIG REWRITE
dir "/usr/software/redis-5.0.3"
protected-mode no
sentinel config-epoch mymaster 0
sentinel leader-epoch mymaster 0
# 从节点的信息
sentinel known-replica mymaster 192.168.145.128 6668
sentinel known-replica mymaster 192.168.145.128 6667
#其他sentinel的信息
sentinel known-sentinel mymaster 192.168.145.128 26381 20d86425d742e85cedd8a86e576da58d90b08b21
sentinel known-sentinel mymaster 192.168.145.128 26380 7f2886c479a783119b4bb580704ab5b8215dcb87
sentinel current-epoch 0