In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Redis Sentinel mode, in popular words, is a "Sentinel Robot". After configuring the "Sentinel Robot", this "robot" can work 24 hours a day, and it can automatically help you do some things, such as monitoring, reminding, automatically handling failures, and so on.
Introduction to Redis-sentinel
Redis-sentinel is the author of Redis, antirez. Because Redis clusters are used by companies, each company has to write its own cluster management tool, so antirez spent several weeks writing Redis-sentinel.
Redis's Sentinel system is used to manage multiple Redis servers (instance), and Redis's Sentinel provides high availability for Redis. Use Sentinel mode to create a Redis deployment that can deal with various failures without human intervention.
The system performs the following three tasks:
Monitoring: Sentinel will constantly check whether your master server and slave server are allowed to work properly. Reminder (Notification): when there is a problem with a monitored Redis server, Sentinel can send notifications to administrators or other applications through API. Automatic failover (Automatic failover): (1) when a master server does not work properly, Sentinel will start an automatic failover operation. He will upgrade one of the failed master servers from the slave server to the new master server and let the other slave servers of the failed master server replicate the new master server. (2) when the client tries to connect to the failed master server, the cluster will also return the address of the new master server to the customer server. Yes, the cluster can use the new master server instead of the failed server.
Distributed characteristics of sentinel
Redis Sentinel is a distributed system where you can run multiple Sentinel processes (progress) in a single architecture, which use the rumor protocol (gossip protocols) to receive information about whether the master server is offline, and use the voting protocol (agreement protocols) to decide whether to perform automatic failover and which slave server to choose as the new master server.
It is unreliable for a single sentinel process to monitor the redis cluster. When the sentinel process is down (sentinel itself has a single point of problem, single-point-of-failure), the whole cluster system will not run as expected. So it is necessary to cluster sentinel, which has several benefits:
Some sentinel processes are down, and the active / standby switching of the redis cluster can still be carried out; if there is only one sentinel process, if this process runs wrong, or if the network is blocked, then the active / standby switching of the redis cluster cannot be realized (single point problem); if there are multiple sentinel,redis clients, they can connect to any sentinel at will to get information about the redis cluster.
A robust deployment requires at least three Sentinel instances.
Three Sentinel instances should be placed on a computer or virtual machine where the customer identifies the failure independently. For example, different physical machines or virtual machines in different availability zones. This lecture is built on a machine, and multi-level is the same reason.
Background
Recent project requirements, come into contact with the construction of Redis, and simply record the holes encountered in the construction process
Overall configuration
192.168.1.100 master192.168.1.101:6379-> slave192.168.1.102:6379-> slave192.168.1.100:26379-> sentinel192.168.1.101:26379-> sentinel192.168.1.102:26379-> sentinel
Building steps
1. Install redis
# decompress tar-xvf / usr/local/redis-3.2.11.tar.gzmkdir-p / usr/local/redis/bincp / usr/local/redis/src/ {redis-benchmark,redis-check-aof,redis-check-rdb,redis-cli,redis-sentinel,redis-server,redis-trib.rb} / usr/local/redis/binmkdir-p / u01/redis/ {6379 / {log,data,pid,conf}, 26379 / {log,data,pid Conf} # add the environment variable echo "export PATH=/usr/local/redis/bin:$PATH" > > / etc/profilesource / etc/profile
2.redis-6379 configuration
The configuration of the redis node is basically as follows. Cp the following configuration to the / u01/redis/6379/conf/redis_6379.conf of the three virtual machines.
Bind 0.0.0.0protected-mode nodaemonize yespidfile "/ u01/redis/6379/pid/redis_6379.pid" port 6379tcp-backlog 511timeout 0tcp-keepalive 0loglevel noticelogfile "/ u01/redis/6379/log/redis_6379.log" databases 16stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename "dump.rdb" dir "/ u01/redis/6379/data" slave-serve-stale-data yesslave-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-disable-tcp-nodelay noslave-priority 100min-slaves -to-write 1min-slaves-max-lag 10appendonly noappendfilename "appendonly.aof" appendfsync everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mbaof-load-truncated yeslua-time-limit 5000slowlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0notify-keyspace-events "hash-max-ziplist-entries 512hash-max-ziplist-value 64list-max-ziplist-entries 512
Start the service
# execute redis-server / u01/redis/6379/conf/redis_6379.conf on three virtual machines
Establish a master-slave relationship
# at 192.168.1.101redis-cli-p 6379 SLAVEOF 192.168.1.100 637 at 192.168.1.102redis-cli-p 6379 SLAVEOF 192.168.1.100 6379
View Replication
192.168.1.101purl 6379 > info replication# Replicationrole:masterconnected_slaves:2min_slaves_good_slaves:2slave0:ip=192.168.1.102,port=6379,state=online,offset=9577826,lag=1slave1:ip=192.168.1.103,port=6379,state=online,offset=9577965 Lag=0master_repl_offset:9577965repl_backlog_active:1repl_backlog_size:1048576repl_backlog_first_byte_offset:8529390repl_backlog_histlen:1048576192.168.1.102:6379 > info replication# Replicationrole:slavemaster_host:192.168.1.101master_port:6379master_link_status:upmaster_last_io_seconds_ago:0master_sync_in_progress:0slave_repl_offset:9600220slave_priority:100slave_read_only:1connected_slaves:0min_slaves_good_slaves:0master_repl_offset: 0repl_backlog_active:0repl_backlog_size:1048576repl_backlog_first_byte_offset:0repl_backlog_histlen:0192.168.1.103:6379 > info replication# Replicationrole:slavemaster_host:192.168.1.101master_port:6379master_link_status:upmaster_last_io_seconds_ago:0master_sync_in_progress:0slave_repl_offset:9612675slave_priority:100slave_read_only:1connected_slaves:0min_slaves_good_slaves:0master_repl_offset:0repl_backlog_active: 0repl_backlog_size:1048576repl_backlog_first_byte_offset:0repl_backlog_histlen:0
3.sentinel-6379 configuration
The configuration of the sentinel node is basically as follows. Cp the following configuration to the / u01/redis/26379/conf/sentinel_26379.conf of the three virtual machines.
After sentinel monitor mymaster, the master node in redis is monitored, that is, 192.168.1.100, so this file is the same on all three machines.
Port 26379bind 0.0.0.0daemonize yesprotected-mode nodir "/ u01/redis/26379/tmp" logfile "/ u01/redis/26379/log/sentinel_26379.log" sentinel monitor mymaster 192.168.1.100 6379 1
Observe the changes of the / u01/redis/26379/conf/sentinel_26379.conf file after waiting for startup to complete
View sentinel status with info sentinel
Redis-cli-h 192.168.1.100-p 26379 info sentinel# Sentinelsentinel_masters:1sentinel_tilt:0sentinel_running_scripts:0sentinel_scripts_queue_length:0sentinel_simulate_failure_flags:0master0:name=zhuanche01,status=ok,address=192.168.1.100:6379,slaves=2,sentinels=3
Summary
When I built it, I encountered a problem that went wrong for some time after the sentinel on 192.168.1.101 and 192.168.1.102 started, and later found that there was no monitoring of master.
Then there is a problem. Look more at log.
Take more notes in the coming year. As you get older, your memory is getting worse and worse.
The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.