keepalived

主備之間不一樣的地方僅有兩處:優先級和狀態

主:[root@node7_1 keepalived]# cat keepalived.conf

! Configuration File for keepalived


global_defs {

   notification_email {

     root@localhost

   }

   notification_email_from keepalived@localhost

   smtp_server 172.0.0.1

   smtp_connect_timeout 30

   router_id node1

   vrrp_mcast_group4 224.0.100.19

}


vrrp_instance VI_1 {

    state BACKUP 

    interface eno16777728

    virtual_router_id 1 

    priority 10

    advert_int 1

    authentication {

        auth_type PASS

        auth_pass cb77b8da

    }

    virtual_ipaddress {

        192.168.1.251/32 dev eno16777728  #此處寫DR模型中的VIP地址

    }

    notify_master "/etc/keepalived/notify.sh master"

    notify_backup "/etc/keepalived/notify.sh backup"

    notify_fault "/etc/keepalived/notify.sh fault"

}


virtual_server 192.168.1.251 80 { #此處寫DR模型中的VIP地址

    delay_loop 3

    lb_algo rr

    lb_kind DR

    protocol TCP


    real_server 192.168.1.161 80 {

        weight 1

        HTTP_GET {

            url {

              path /

              status_code 200

            }

            connect_timeout 1

            nb_get_retry 3

            delay_before_retry 1

        }

    }


    real_server 192.168.1.162 80 {

        weight 1

        HTTP_GET {

            url {

              path /

              status_code 200

            }

            connect_timeout 1

            nb_get_retry 3

            delay_before_retry 1

        }

    }

}


備:

! Configuration File for keepalived


global_defs {

   notification_email {

     root@localhost

   }

   notification_email_from keepalived@localhost

   smtp_server 172.0.0.1

   smtp_connect_timeout 30

   router_id node1

   vrrp_mcast_group4 224.0.100.19

}


vrrp_instance VI_1 {

    state MASTER

    interface eno16777728

    virtual_router_id 1

    priority 100

    advert_int 1

    authentication {

        auth_type PASS

        auth_pass cb77b8da

    }

    virtual_ipaddress {

        192.168.1.251/32 dev eno16777728  #此處寫DR模型中的VIP地址

    }

    notify_master "/etc/keepalived/notify.sh master"

    notify_backup "/etc/keepalived/notify.sh backup"

    notify_fault "/etc/keepalived/notify.sh fault"

}


virtual_server 192.168.1.251 80 { #此處寫DR模型中的VIP地址

    delay_loop 3

    lb_algo rr

    lb_kind DR

    protocol TCP


    real_server 192.168.1.161 80 {

        weight 1

        HTTP_GET {

            url {

              path /

              status_code 200

            }

            connect_timeout 1

            nb_get_retry 3

            delay_before_retry 1

        }

    }


    real_server 192.168.1.162 80 {

        weight 1

        HTTP_GET {

            url {

              path /

              status_code 200

            }

            connect_timeout 1

            nb_get_retry 3

            delay_before_retry 1

        }

    }

}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章