配置 Keepalived 主備

2022-08-26 05:00:07 字數 1578 閱讀 3931

1. 通過命令vim keepalived.conf開啟配置檔案

global_defs 

vrrp_instance vi_1

# 虛擬出來的ip,可以有多個(vip)

virtual_ipaddress

}

附:檢視網絡卡名稱

2. 啟動 keepalived

在sbin目錄中進行啟動(同nginx),如下圖:

3. 檢視程序

4. 檢視vip

在網絡卡ens33下,多了乙個192.168.1.161,這個就是虛擬ip

備用節點:

1. 通過命令vim keepalived.conf開啟配置檔案

global_defs 

vrrp_instance vi_1

virtual_ipaddress

}

2. 啟動 keepalived

# 啟動keepalived

systemctl start keepalived

# 停止keepalived

systemctl stop keepalived

# 重啟keepalived

systemctl restart keepalived

3. 檢視程序

規則:以乙個虛擬ip分組歸為同乙個路由

主節點配置:

global_defs 

vrrp_instance vi_1

virtual_ipaddress

}vrrp_instance vi_2

virtual_ipaddress

}

備用節點配置

global_defs 

vrrp_instance vi_1

virtual_ipaddress

}vrrp_instance vi_2

virtual_ipaddress

}

別忘記分別重啟兩條keepalived

# 重啟keepalived

systemctl restart keepalived

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

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

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...

Keepalived部署雙主熱備

二 配置keepalived主和從 2.2 配置keepalived 從 2.3 啟動keepalived 三 keepalived註冊為系統服務 四 keepalived配置nginx自動重啟 五 配置keepalived雙主熱備 上傳壓縮包 scp keppalived.tar.gz root ...