国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > CentOS > 正文

Centos部署Keepalive高可用軟件

2024-06-28 14:31:42
字體:
供稿:網(wǎng)友

Keepalive安裝部署

 

一.環(huán)境介紹

 

1)Centos6.4

2) keepalived-1.2.12

3) 主備機的ip

Master:172.31.100.5

Slave: 172.31.100.54

Virtault ip:172.31.100.1

 

二.部署安裝

計劃具體部署步驟:

步驟1:安裝

步驟2:配置

步驟3:運行

步驟4:檢查

 

現(xiàn)在開始:

1)安裝

$ yum install -y gcc make openssl openssl-devel$ wget http://www.keepalived.org/software/keepalived-1.2.12.tar.gz$ tar zxvf keepalived-1.2.12.tar.gz$ cd keepalived-1.2.12$ ./configure --PRefix=/usr/local/keepalived$ make && make install

 

 

2)配置

$ cp /usr/local/keepalived/sbin/keepalived /usr/sbin/$ cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/$ cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/$ cp -rf /usr/local/keepalived/etc/keepalived /etc/

 

 

AMaster:

$ vi /etc/keepalived/keepalived.conf! Configuration File for keepalivedglobal_defs {    router_id LVS_DEVEL } vrrp_script chk_haproxy {           script "/etc/keepalived/chk_haproxy.sh"           interval 2           weight 2 } vrrp_instance VI_1 {           interface eth0          state BACKUP          priority 101          virtual_router_id 50          garp_master_delay 1          authentication {                       auth_type PASS                       auth_pass Hc8scrRddsLsc3          }           virtual_ipaddress {                       172.31.100.1          }           track_script {                       chk_haproxy          }         #notify_master "/etc/keepalived/Mailnotify.py backup"        #notify_backup "/etc/keepalived/Mailnotify.py master"        #notify_fault "/etc/keepalived/Mailnotify.py fault" }

 

 

 

 

BSlave:

$ vi /etc/keepalived/keepalived.conf! Configuration File for keepalivedglobal_defs {    router_id LVS_DEVEL } vrrp_script chk_haproxy {           script "/etc/keepalived/chk_haproxy.sh"           interval 2           weight 2 } vrrp_instance VI_1 {           interface eth0          state BACKUP          priority 100          virtual_router_id 50          garp_master_delay 1           authentication {                       auth_type PASS                       auth_pass Hc8scrRddsLsc3          }           virtual_ipaddress {                       172.31.100.1          }           track_script {                       chk_haproxy          }         notify_master "/etc/keepalived/Mailnotify.py backup"        notify_backup "/etc/keepalived/Mailnotify.py master"        #notify_fault "/etc/keepalived/Mailnotify.py fault" }

 

 

 

C)主備兩邊都需要的檢測腳本和郵件報警腳本:

 

#keepalive調(diào)用該腳本檢測haproxy是否停止$ vi /etc/keepalived/chk_haproxy.sh#!/bin/bashstatus=$(ps aux|grep haproxy | grep -v grep | grep -v bash | wc -l)if [ "${status}" = "0" ]; then    /etc/init.d/haproxy start    status2=$(ps aux|grep haproxy | grep -v grep | grep -v bash |wc -l)    if [ "${status2}" = "0"  ]; then            /etc/init.d/keepalived stop    fifi

 

#郵件報警腳本 來自網(wǎng)絡劉天斯大牛$ vi /etc/keepalived/chk_haproxy.sh#!/usr/bin/env python#coding: utf-8 from email.MIMEMultipart import MIMEMultipart from email.MIMEText import MIMEText from email.MIMEImage import MIMEImage from email.header import Header import sys import smtplib strFrom = 'xxxxx@126.com'      #郵件來自哪里strTo = 'receive@Gmail.com'    #收件箱smtp_server='smtp.126.com'     #郵件服務器地址smtp_user='send@126.com'       #發(fā)件箱smtp_pass='passwdxx'           #密碼if sys.argv[1]!="master" and sys.argv[1]!="backup"  and sys.argv[1]!="fault":     sys.exit() else:     notify_type=sys.argv[1] mail_title='[緊急]負載均衡器郵件通知' mail_body_plain=notify_type+'被激活,請做好應急處理。' mail_body_html='<b><font color=red>'+notify_type+'被激活,請做好應急處理。</font></b>' msgRoot = MIMEMultipart('related') msgRoot['Subject'] =Header(mail_title,'utf-8') msgRoot['From'] = strFrom msgRoot['To'] = strTo msgAlternative = MIMEMultipart('alternative') msgRoot.attach(msgAlternative) msgText = MIMEText(mail_body_plain, 'plain', 'utf-8') msgAlternative.attach(msgText) msgText = MIMEText(mail_body_html, 'html','utf-8') msgAlternative.attach(msgText)  smtp = smtplib.SMTP() smtp.connect(smtp_server) smtp.login(smtp_user,smtp_pass) smtp.sendmail(strFrom, strTo, msgRoot.as_string()) smtp.quit()

 

 

3)運行

$ /etc/init.d/keepalived start$ chkconfig keepalived on

 

4)檢查

$ ps aux|grep keeepalived #查看進程$ ip addr show            #用來查看地址是否切換的

 

三.結(jié)尾

 

以上是該軟件的全部部署過程


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 明星| 和田县| 宜阳县| 民权县| 广汉市| 镇远县| 门源| 分宜县| 克什克腾旗| 成都市| 乐都县| 疏附县| 靖西县| 区。| 大安市| 蒙城县| 阜平县| 盖州市| 邯郸市| 庄浪县| 饶阳县| 商河县| 曲沃县| 茶陵县| 六安市| 台东县| 黄冈市| 府谷县| 宣威市| 于田县| 沧源| 定襄县| 锡林郭勒盟| 弥渡县| 重庆市| 华坪县| 阳信县| 汝州市| 安福县| 辰溪县| 黎平县|