keepalived實現Nginx高可用

2021-09-26 08:06:34 字數 1836 閱讀 7312

tar -zxvf keepalived-2.0.15.tar.gz -c /usr/local/src/
進入到keepalived目錄

cd /usr/local/src/keepalived-2.0.15/
指定keepalived安裝錄了

./configure --prefix=/usr/local/keepalived
編譯安裝

make && make install
將keepalived新增到系統服務中

cp /usr/local/keepalived/sbin/keepalived /usr/sbin/

cp -r /usr/local/src/keepalived-2.0.15/keepalived/etc/init.d /etc/init.d/keepalived

cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/

mkdir -p /etc/keepalived

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

chmod +x /etc/init.d/keepalived

chkconfig --add keepalived

chkconfig keepalived on

新增到系統伺服器可以通過以下命令操作keepalived

service keepalived start  # 啟動keepalived

service keepalived stop # 停止keepalived

service keepalived restart # 重啟keepalived

service keepalived status # 檢視keepalived狀態

修改keepalived配置檔案

global_defs 

notification_email_from [email protected]

smtp_server 192.168.200.1

smtp_connect_timeout 30

router_id lvs_devel

vrrp_skip_check_adv_addr

#vrrp_strict #注釋掉這一行,不然ping不通

vrrp_garp_interval 0

vrrp_gna_interval 0

}vrrp_instance vi_1

virtual_ipaddress

}

global_defs 

notification_email_from [email protected]

smtp_server 192.168.200.1

smtp_connect_timeout 30

router_id lvs_devel

vrrp_skip_check_adv_addr

#vrrp_strict #注釋掉這一行,不然ping不通

vrrp_garp_interval 0

vrrp_gna_interval 0

}vrrp_instance vi_1

virtual_ipaddress

}

Keepalived 實現高可用

對於主負載均衡伺服器,修改配置檔案 vim etc keepalived keepalived.conf configuration file for keepalived global defs vrrp instance vi 1 virtual ipaddress 備用負載均衡伺服器 vim ...

keepalived實現高可用

一.keepalived是什麼 keepalived最初是為lvs負載均衡設計的,用於監控lvs集群系統中的各個節點的服務狀態。後來又加入了基於vrrp的高可用功能,所以也可以作為nginx,mysql等服務的高可用解決方案使用。vrrp virtual router redundancy prot...

keepalived實現主備切換

wget tar zxvf keepalived 1.2.18 tar.gz c usr local yum install y openssl openssl devel cd keepalived 1.2.18 configure prefix usr local keepalived make...