Redis and keepalive, detection mechanism revision

Source: Internet
Author: User

Recently made by oneself keepalive detection mechanism, directly on the latest optimized script: ########### #start  scriptskillall -0 redis-serverif [   "$?"  -eq 0 ]; then        echo good         exit 0else        logfile=/ var/log/keepalived-redis-state.log        echo  "[Check_fail_log]"  >>  $LOGFILE         date >>  $LOGFILE         killall -0 redis-server         if [  "$?"  -ne 0 ]; then                 echo killall_bad_two >> /var/log/keepalived-redis-state.log                 numprocess1= ' Netstat -tnpl | grep 6379 -c '                  numprocess2= ' ps -ef | grep  redis-server | grep -c 6379 '                  if [[ ${numprocess1} -lt 1 ]] &&  [[ ${numprocess2} -lt 1 ]]; then                         echo  process_bad_three >> /var/log/keepalived-redis-state.log                           #start  judge status                         /etc/init.d/redis status                         if  [[ $? -eq 0 ]]; then                                  echo good                                  exit 0                         else                                  echo status_bad_four >> /var/log/keepalived-redis-state.log                                  /etc/init.d/redis status >>  /var/log/keepalived-redis-state.log                                  ### #start  last judge                                  alive= '/usr/bin/redis-cli -p 6379 ping '                                   if [  "$ALIVE"  !=  "PONG"  ]; then                                           echo ping_bad_five >> /var/log/keepalived-redis-state.log                                           exit 1                                 else                                          exit 0                                  fi                                  ## #end  last judge                          fi                          #end  judge status                          else                         exit 0                 fi        else                 exit 0         fifi########### #end  scripts Current judgment is: The first layer:  retry two times   process signal judgment. Second layer: netstat  and  ps -ef  judgment of the third layer: /etc/init.d/redis status  return code. Fourth level: redis ping    return code judgment. Each of these layers fails, and the log is printed. After the failure, the Redis process and business access problems, formally start the switchover operation. Test the environment to test the effect. Log records: [Check_fail_log]thu may 19 09:46:23 cst 2016killall_bad_twoprocess_bad_ Threestatus_bad_fourredis-server is stoppedping_bad_five


This article is from the Linux system maintenance blog, so be sure to keep this source http://linuxadmin.blog.51cto.com/2683824/1774987

Redis and keepalive, detection mechanism revision

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.