Redis [7] sentinel for redis node high availability monitoring

You and other students 2022-02-13 08:08:49 阅读数:867

redis sentinel redis node high

This article has been arranged since childhood d Class notes and java Advanced warehouse , any similarity , Most of them are written by others

java Advanced warehouse :

Redis Node high availability monitoring Sentinel

  • background

  • A master-slave... Is built in front , When the primary server goes down , You need to manually switch one from the server to the primary server , Manual intervention is laborious , It will also make the service unavailable for a period of time

  • Introduction to sentinel mode

    • Redis The order of the sentry , It's an independent process
    • principle Sentinels send commands to multiple nodes , wait for Redis Server response , So as to monitor the operation of multiple Redis The operation of the instance
    • When the Sentinels detect master Downtime , Will automatically slave Switch to master, By notifying other slave servers , Change the host configuration file
  • Sentinel Three major tasks

    • monitor (Monitoring)
      • Sentinel Constantly check whether your master and slave servers are working properly
    • remind (Notification)
      • When someone is being monitored Redis When there's a problem with the server , Sentinel Can pass API Send notifications to administrators or other applications
    • Automatic failover (Automatic failover)
      • When a primary server doesn't work , Sentinel An automatic failover operation will start , It will upgrade one of the failed master servers from the server to the new master server , And let the other slave servers of the failed master server copy the new master server
      • When a client tries to connect to a failed primary server , The cluster will also return the address of the new primary server to the client , So that the cluster can use the new master server instead of the failed server
  • problem

    • A sentinel process on Redis The server monitors , There may be problems
    • Generally, multiple sentinels are used for monitoring , There will be surveillance between the Sentinels , Form a multi sentry mode
  • Introduction to offline name of multi sentry mode

    • Subjective offline (Subjectively Down, abbreviation SDOWN)
      • It's a single Sentinel Instance of the server to make a referral judgment , For example, network problems, failure to receive notifications, etc
      • A server is not down-after-milliseconds Within the time specified by the option , Yes send it PING Ordered Sentinel Return a valid reply (valid reply), that Sentinel This server will be marked as subjective offline
    • Objective offline (Objectively Down, abbreviation ODOWN)
      • multiple Sentinel The instance is made to the same server SDOWN Judge , And through SENTINEL is-master-down-by-addr After the orders communicated with each other , Get the server offline judgment
      • One Sentinel You can do this by going to the other Sentinel send out SENTINEL is-master-down-by-addr Command to ask if the given server is considered offline
      • The objective logoff condition only applies to the primary server
    • arbitration qurum
      • Sentinel Within a given time frame , From the other Sentinel It received 【 Enough 】 Main server offline report , that Sentinel It will change the status of the primary server from subjective offline to objective offline
      • This 【 Enough 】 Is the value in the configuration file , It's usually Sentinel Half the number plus 1, such as 3 individual Sentinel Set to 2
      • down-after-milliseconds It's a sentry who still doesn't get a response after exceeding the specified time , Think the host is not available
      • When the Sentinels who think they are offline reach sentinel monitor When the configured quantity , A vote will be launched , Conduct failover

Sentinel sentry

  • The core processes
    • Per second ping, No response after time It is considered subjective
    • Satisfy many , It is considered to be objective
    • Vote to select the master node
    • If not enough nodes agree master Offline , The status will be removed

Master-slave +Sentinel The sentry cluster

  • Start the sentry cluster
./redis-server /usr/local/redis/conf/sentinel-1.conf --sentinel
./redis-server /usr/local/redis/conf/sentinel-2.conf --sentinel
./redis-server /usr/local/redis/conf/sentinel-3.conf --sentinel
  • The network security group needs an open port
  • advantage
    • Master and slave can switch automatically , Higher availability
  • shortcoming
    • The master-slave switch will lose short-term data
    • The write capacity and storage capacity of the primary node are limited
copyright:author[You and other students],Please bring the original link to reprint, thank you.