溫馨提示×

溫馨提示×

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

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

如何直接用keepalived實現(xiàn)企業(yè)級WEB的負載均衡高可用性

發(fā)布時間:2020-04-20 14:52:45 來源:億速云 閱讀:207 作者:三月 欄目:開發(fā)技術(shù)

下文給大家?guī)砣绾沃苯佑胟eepalived實現(xiàn)企業(yè)級WEB的負載均衡高可用性,希望能夠給大家在實際運用中帶來一定的幫助,負載均衡涉及的東西比較多,理論也不多,網(wǎng)上有很多書籍,今天我們就用億速云在行業(yè)內(nèi)累計的經(jīng)驗做一個解答。

③編輯keepalived.conf文件,直接用keepalived實現(xiàn)負載均衡及高可用性。

a)Keepalved的安裝

a)Keepalved的安裝  

如何直接用keepalived實現(xiàn)企業(yè)級WEB的負載均衡高可用性

  1. #wget http://www.keepalived.org/software/keepalived-1.1.15.tar.gz  

  2. #tar zxvf keepalived-1.1.15.tar.gz  

  3. #cd keepalived-1.1.15  

  4. #./configure  

  5. #make  

  6. #make install

將keepalived做成啟動腳務,方便管理:

  1. #cp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/  

  2. #cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/  

  3. #mkdir /etc/keepalived  

  4. #cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/  

  5. #cp /usr/local/sbin/keepalived /usr/sbin/  

  6. #service keepalived start|stop 

b)Keealived的配置

①分別在主從負載均衡云服務器上配置keepalived.conf ,內(nèi)容分別如下:

  1. ! Configuration File for keepalived  

  2. global_defs {  

  3.    notification_email {  

  4.          yuhongchun027@163.com  

  5.    }  

  6.    notification_email_from sns-lvs@gmail.com  

  7.    smtp_server 127.0.0.1  

  8.    router_id LVS_DEVEL  

  9. }  

  10. vrrp_instance VI_1 {  

  11.     state MASTER               

  12.     interface eth0  

  13.     virtual_router_id 51  

  14.     priority 100      

  15.     advert_int 1  

  16.     authentication {  

  17.         auth_type PASS  

  18.         auth_pass 1111  

  19.     }  

  20.     virtual_ipaddress {  

  21.         192.168.5.188   

  22.     }  

  23. }  

  24. virtual_server 192.168.5.188 80 {  

  25.     delay_loop 6                    

  26.     lb_algo wrr                    

  27.     lb_kind DR                    

  28.     persistence_timeout 60          

  29.     protocol TCP                  

  30.     real_server 192.168.5.104 80 {  

  31.         weight 3                 

  32.         TCP_CHECK {  

  33.         connect_timeout 10         

  34.         nb_get_retry 3  

  35.         delay_before_retry 3  

  36.         connect_port 80  

  37.         }  

  38.     }  

  39.     real_server 192.168.5.105 80 {  

  40.         weight 3  

  41.         TCP_CHECK {  

  42.         connect_timeout 10  

  43.         nb_get_retry 3  

  44.         delay_before_retry 3  

  45.         connect_port 80  

  46.         }  

  47.      }  

  1. ! Configuration File for keepalived  

  2. global_defs {  

  3.    notification_email {  

  4.          yuhongchun027@163.com  

  5.    }  

  6.    notification_email_from sns-lvs@gmail.com  

  7.    smtp_server 127.0.0.1  

  8.    router_id LVS_DEVEL  

  9. }  

  10. vrrp_instance VI_1 {  

  11.     state BACKUP               

  12.     interface eth0  

  13.     virtual_router_id 51  

  14.     priority 99      

  15.     advert_int 1  

  16.     authentication {  

  17.         auth_type PASS  

  18.         auth_pass 1111  

  19.     }  

  20.     virtual_ipaddress {  

  21.         192.168.5.188   

  22.     }  

  23. }  

  24. virtual_server 192.168.5.188 80 {  

  25.     delay_loop 6                    

  26.     lb_algo wrr                    

  27.     lb_kind DR                    

  28.     persistence_timeout 60          

  29.     protocol TCP                  

  30.     real_server 192.168.5.104 80 {  

  31.         weight 3                 

  32.         TCP_CHECK {  

  33.         connect_timeout 10         

  34.         nb_get_retry 3  

  35.         delay_before_retry 3  

  36.         connect_port 80  

  37.         }  

  38.     }  

  39.     real_server 192.168.5.105 80 {  

  40.         weight 3  

  41.         TCP_CHECK {  

  42.         connect_timeout 10  

  43.         nb_get_retry 3  

  44.         delay_before_retry 3  

  45.         connect_port 80  

  46.         }  

  47.      }  

看了以上關(guān)于如何直接用keepalived實現(xiàn)企業(yè)級WEB的負載均衡高可用性,如果大家還有什么地方需要了解的可以在億速云行業(yè)資訊里查找自己感興趣的或者找我們的專業(yè)技術(shù)工程師解答的,億速云技術(shù)工程師在行業(yè)內(nèi)擁有十幾年的經(jīng)驗了。

 

向AI問一下細節(jié)

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

AI