keepalived 의 설치 와 설정

3070 단어 keepalivedvrrpLinux
설치 전 준비:yum-y install gcc-c+autoconf automake yum-y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
1.keepalived 다운로드 방법 1:yum-y install keepalived 방법 2:바 이 너 리 소스 패키지 다운로드:http://www.keepalived.org/download.html#설치 파일 다운로드 wgethttp://www.keepalived.org/software/keepalived-1.4.0.tar.gz -C /user/locl
        #    
        tar -zxvf keepalived-1.40.0.tar.gz

        #  
        cd keepalived-1.40.0/
        #--prefix       
        #/usr/local/keepalived/      ,             ,    
        ./configure --prefix=/usr/local/keepalived/

        #     
        make && make install

편집/etc/keepalived/keepalived.conf
yum       
    vim /ect/keepalived/keepalived.conf
          
    vim /usr/local/keepalived/etc/keepalived/keepalived.conf 
global_defs {
    notification_email {
        #[email protected]       #   keepalived          email    ,    
        #[email protected]
    }
    notification_email_from [email protected]   #      
    smtp_server [email protected]              # smtp      
    smtp_connect_timeout 30               # smtp          
    router_id LVS_1 #          ,   hostname,       hostname,     ,       
    }

vrrp_instance VI_1 {  #     
    state MASTER      #    MASTER BACKUP,       keepalived     priority         MASTER
    interface eth0    #     IP( VIP)   ,   VRRP      
    mcast_src_ip 192.168.0.179 #   ip,    
    virtual_router_id 51 #     ID,   0-255  ,      instance VRRP  ,     ID    ;       ;
    priority 100      #     master ,   master                50  ,       1-255(              100)
    advert_int 1      #        1 , 1     master  (             )
    authentication {  #     ,     PASS HA(IPSEC),    PASS(      8 )
        auth_type PASS  #    PASS  
        auth_pass MrUse # PASS    
    }
    virtual_ipaddress {
        192.168.0.219    #   VIP  ,    
    }
}

3.서비스 시작(1)systemctl start keepalived(yum 설치 시 이 명령 으로 서 비 스 를 시작 합 니 다)(2)소스 패키지 설치 시작 서 비 스 는 다음 과 같은 절 차 를 거 쳐 야 합 니 다\#keepalived 설정 파일 디 렉 터 리 mkdir/etc/keepalived 만 들 기
    #       /etc/keepalived   
    cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/

    #  keepalived   /etc/init.d/   
    cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/ #(   ) 
    #  keepalived   /etc/sysconfig/   
    cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/

    #     
    ln -s /usr/local/keepalived/sbin/keepalived /sbin/

    #       
    chkconfig keepalived on
    #      
    systemctl status keepalived

4.ip 리 트 윗 사용
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
    sysctl -p

5.방화벽 추가 규칙
firewall-cmd --direct --permanent --add-rule ipv4 filter INPUT 0 --in-interface enp196 --destination 224.0.0.18 --protocol vrrp -j ACCEPT
success
# firewall-cmd --direct --permanent --add-rule ipv4 filter OUTPUT 0 \--out-interface enp196 --destination 224.0.0.18 --protocol vrrp -j ACCEPT
success
# firewall-cmd --reload
success

좋은 웹페이지 즐겨찾기