redis與keepalive合用,檢測機制修訂

來源:互聯網
上載者:User

標籤:redis 與keepalive合用   檢測機制修訂   

近期又被自己造的keepalive檢測機制搞了,直接上最新最佳化後的指令碼:############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目前的判斷為:第一層: 重試兩次 進程訊號判斷。第二層: netstat 及 ps -ef 判斷第三層: /etc/init.d/redis status 返回碼判斷。第四層: redis ping   返回碼判斷。以上每一層失敗,都會列印日誌。失敗後說明redis進程及業務訪問出現問題,正式開始啟動切換操作。測試環境測試效果。日誌記錄:[check_fail_log]Thu May 19 09:46:23 CST 2016killall_bad_twoprocess_bad_threestatus_bad_fourredis-server is stoppedping_bad_five


本文出自 “linux系統維護” 部落格,請務必保留此出處http://linuxadmin.blog.51cto.com/2683824/1774987

redis與keepalive合用,檢測機制修訂

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.