亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

keepalived雙主以及nginx+keepalived實現高可用

發布時間:2020-08-14 10:02:53 來源:網絡 閱讀:403 作者:不會運維 欄目:系統運維

一、keepalive實現雙主:
1.1實驗準備
2臺主機地址分別為:172.20.10.9,172.20.10.10,
vip1為172.20.10.10,vip2為172.20.10.11
1.2通知腳本:

[root@node5 /]# vim /etc/keepalived/notify.sh 
#!/bin/bash
contact='root@localhost'
notify() {
    local mailsubject="$(hostname) to be $1, vip floating"
    local mailbody="$(date +'%F %T'): vrrp transition, $(hostname) changed to be $1"
    echo "$mailbody" | mail -s "$mailsubject" $contact
}
case $1 in
master)
    notify master
    ;;
backup) 
    notify backup
    ;;   
fault)    
    notify fault
    ;;  
*)
   echo "Usage: $(basename $0) {master|backup|fault}"
   exit 1
   ;;
esac

1.3配置node5為vip1地址的主節點,vip2地址的備節點

[root@node5 ~]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived

global_defs {
   notification_email {
      root@localhost
   }
   notification_email_from keepalived@localhost
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id node5
   vrrp_mcast_group4 224.0.100.19
}

vrrp_instance VI_1 {
    state MASTER
    interface ens33
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        172.20.10.10/28 dev ens33 label ens33:0
    }
   notify_master "/etc/keepalived/notify.sh master"
   notify_backup "/etc/keepalived/notify.sh backup"
   notify_fault "/etc/keepalived/notify.sh fault"
}
vrrp_instance VI_2 {
    state BACKUP
    interface ens33
    virtual_router_id 52
    priority 98
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        172.20.10.11/28 dev ens33 label ens33:1
    }
   notify_master "/etc/keepalived/notify.sh master"
   notify_backup "/etc/keepalived/notify.sh backup"
   notify_fault "/etc/keepalived/notify.sh fault"
}

1.4配置node6為vip1地址的備節點,vip2地址的主節點

[root@node6 ~]# vim /etc/keepalived/keepalived.conf 
! Configuration File for keepalived

global_defs {
   notification_email {
      root@localhost
   }
   notification_email_from keepalived@localhost
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id node5
   vrrp_mcast_group4 224.0.100.19
}

vrrp_instance VI_1 {
    state BACKUP
    interface ens33
    virtual_router_id 51
    priority 98
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        172.20.10.10/28 dev ens33 label ens33:0
    }
   notify_master "/etc/keepalived/notify.sh master"
   notify_backup "/etc/keepalived/notify.sh backup"
   notify_fault "/etc/keepalived/notify.sh fault"
}
vrrp_instance VI_2 {
    state MASTER
    interface ens33
    virtual_router_id 52
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        172.20.10.11/28 dev ens33 label ens33:1
    }
   notify_master "/etc/keepalived/notify.sh master"
   notify_backup "/etc/keepalived/notify.sh backup"
   notify_fault "/etc/keepalived/notify.sh fault"
}

1.5驗證:
(1)先開啟node6節點的keepalived服務,查看IP地址,狀態:
2個VIP地址都在node6節點上:
keepalived雙主以及nginx+keepalived實現高可用
keepalived雙主以及nginx+keepalived實現高可用

(2)再開啟node5節點keepalived服務,查看IP地址和狀態:
VIP1地址已經飄到了node5節點上了
keepalived雙主以及nginx+keepalived實現高可用
keepalived雙主以及nginx+keepalived實現高可用
二,Nginx+Keepalived實現站點高可用
2.1實驗準備:
2臺主機:node5地址為172.20.10.9,node6的節點為172.20.10.8
vip地址為172.20.10.10
2.2nginx配置
(1)node5節點

[root@node5 ~]# yum install nginx -y
[root@node5 /]# vim /usr/share/nginx/html/index.html 
node5 web page
[root@node5 ~]# systemctl  start nginx

(2)node6節點

[root@node6 /]# yum install -y  nginx
[root@node6 /]# vim /usr/share/nginx/html/index.html 
node6 web page
[root@node6 ~]# systemctl  start nginx

2.3配置node5為vip的主節點,配置檢查nginx的監控腳本:

[root@node5 /]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
   notification_email {
      root@localhost
   }
   notification_email_from keepalived@localhost
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id node5
   vrrp_mcast_group4 224.0.100.19
}
vrrp_script chk_nginx {
    script "/usr/bin/killall -0 nginx &&  exit 0 || exit 1 "
    interval 1
    weight -5
    fall 2
    rise 1
}
vrrp_instance VI_1 {
    state MASTER
    interface ens33
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        172.20.10.10/28 dev ens33 label ens33:0
    }
    track_script {
        chk_nginx
    }
    track_interface {
        ens33
    }
   notify_master "/etc/keepalived/notify.sh master"
   notify_backup "/etc/keepalived/notify.sh backup"
   notify_fault "/etc/keepalived/notify.sh fault"
}
[root@node5 keepalived]# systemctl  start   keepalived

2.4配置node6為vip的備節點,配置檢查nginx的監控腳本:

[root@node6 /]# vim /etc/keepalived/keepalived.conf 
! Configuration File for keepalived
global_defs {
   notification_email {
      root@localhost
   }
   notification_email_from keepalived@localhost
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id node5
   vrrp_mcast_group4 224.0.100.19
}
vrrp_script chk_nginx {
    script "/usr/bin/killall -0 nginx &&  exit 0 || exit 1 "
    interval 1
    weight -5
    fall 2
    rise 1
}
vrrp_instance VI_1 {
    state BACKUP
    interface ens33
    virtual_router_id 51
    priority 98
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        172.20.10.10/28 dev ens33 label ens33:0
    }
    track_script {
        chk_nginx
    }
    track_interface {
        ens33
    }
   notify_master "/etc/keepalived/notify.sh master"
   notify_backup "/etc/keepalived/notify.sh backup"
   notify_fault "/etc/keepalived/notify.sh fault"
}
[root@node6 html]# systemctl  start   keepalived

3.驗證:
3.1當服務都正常時,vip地址在node5節點上,測試訪問172.20.10.10的情況:
keepalived雙主以及nginx+keepalived實現高可用
keepalived雙主以及nginx+keepalived實現高可用
3.2當down掉node5節點上nginx服務時,觀察vip地址和其訪問情況:
vip地址飄到node6節點上,curl172.20.10.10,則訪問的時node6節點
keepalived雙主以及nginx+keepalived實現高可用

keepalived雙主以及nginx+keepalived實現高可用
3.3當恢復node5節點上nginx服務時,vip地址飄到node5節點上,訪問172.20.10.10則是node5上nginx
keepalived雙主以及nginx+keepalived實現高可用
keepalived雙主以及nginx+keepalived實現高可用

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

古浪县| 安丘市| 休宁县| 饶河县| 呼和浩特市| 迁西县| 科技| 安丘市| 防城港市| 遂溪县| 犍为县| 华池县| 连平县| 弋阳县| 东平县| 城市| 甘德县| 巴中市| 徐汇区| 无锡市| 环江| 临武县| 城市| 商河县| 永寿县| 秦皇岛市| 通山县| 福海县| 兴化市| 许昌市| 嘉峪关市| 肃北| 鄯善县| 四子王旗| 绥芬河市| 安岳县| 九江市| 长丰县| 左权县| 忻州市| 延边|