keepalived實現主備切換

2021-08-01 09:31:44 字數 1105 閱讀 7836

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 && make install

將keepalived安裝成linux系統服務

mkdir /etc/keepalived

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

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

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

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

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

可以設定開機啟動:

chkconfig keepalived on,

到此我們安裝完畢!

2.寫乙個shell指令碼,用於檢測nginx是否啟動,如果沒有啟動,嘗試重啟,如果還是不行,則關閉keepalived

指令碼例項:

#!/bin/bash

a=`ps -c nginx --no-header | wc -l`

if [ $a

-eq0 ]

then

/usr/local/nginx/sbin/nginx

b=`ps -c nginx --no-header |wc -l`

if [ $b

-eq0 ]

then

killall keepalived

fifi

配置 Keepalived 主備

1.通過命令vim keepalived.conf開啟配置檔案 global defs vrrp instance vi 1 虛擬出來的ip,可以有多個 vip virtual ipaddress 附 檢視網絡卡名稱 2.啟動 keepalived 在sbin目錄中進行啟動 同nginx 如下圖 3...

keepalived主備排程器的實現

1 實驗原理 在企業中,如果只有一台排程器,那麼如果它出現問題,將造成不可估量的損失,所以企業會使用兩台排程器,主排程器正常工作,如果出現問題那麼輔排程器接替它繼續工作,不會影響業務。2 實驗環境 主和備兩台排程器要有所有主機的解析,包括自己 server1 主排程器 ip 172.25.1.101...

keepalived配置指令碼實現主備切換

環境 vmvare下centos7.2 防火牆開啟 sellinux關閉 1通過yum安裝keepalived 2修改主的 etc keepalived keepalived.conf修改為如下內容 configuration file for keepalived global defs vrrp...