指令碼VIP更改為keepalive

2022-05-28 15:09:14 字數 1832 閱讀 9398

兩個節點安裝 keepalived

wget

tar xf keepalived-1.2.12.tar.gz           

cd keepalived-1.2.12

./configure --prefix=/usr/local/keepalived

make && make install

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

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

mkdir /etc/keepalived

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

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

配置keepalived的配置檔案,在master上配置

cat /etc/keepalived/keepalived.conf

! configuration file for keepalived

global_defs

vrrp_instance vi_21

virtual_ipaddress

}在候選master上配置

cat /etc/keepalived/keepalived.conf 

! configuration file for keepalived

global_defs

vrrp_instance vi_21

virtual_ipaddress

}把 /usr/bin/master_ip_failover 和 /usr/bin/master_ip_online_change 指令碼修改: 

`/usr/bin/ssh -t root\@$ "ifconfig ens160:0 172.16.0.127 netmask 255.255.255.0 down"`;

`/usr/bin/ssh -t root\@$ "ifconfig ens160:0 172.16.0.127 netmask 255.255.255.0 up"`;

修改為:

`/usr/bin/ssh -t root\@$ "service keepalived stop"`;

`/usr/bin/ssh -t root\@$ "service keepalived start"`;

啟動keepalived服務,在master上啟動並檢視日誌

/etc/init.d/keepalived start; tail -f /var/log/messages

在另外一台伺服器,候選master上啟動keepalived服務,並觀察

/etc/init.d/keepalived start ; tail -f /var/log/messages

注意:上面兩台伺服器的keepalived都設定為了backup模式,在keepalived中2種模式,分別是master->backup模式和backup->backup模式。這兩種模式有很大區別。在master->backup模式下,一旦主庫宕機,虛擬ip會自動漂移到從庫,當主庫修復後,keepalived啟動後,還會把虛擬ip搶占過來,即使設定了非搶占模式(nopreempt)搶占ip的動作也會發生。在backup->backup模式下,當主庫宕機後虛擬ip會自動漂移到從庫上,當原主庫恢復和keepalived服務啟動後,並不會搶占新主的虛擬ip,即使是優先順序高於從庫的優先級別,也不會發生搶占。為了減少ip漂移次數,通常是把修復好的主庫當做新的備庫。

win builds更改為本地源方法

win builds軟體預設源十分的慢,開ssr 不知是什麼原因無法使用!pkg install wget wget r no parent no host directories 提取碼 pj30 更多可以參考官網 然後斷網啟動程式再改變源為本地資料夾 此處有坑,請隨機應變 不斷網會導致很難等到左...

DELL BIOS中UEFI更改為Legacy

1.secure boot secure boot enable 將右側這項改為disable 2.切換到 sercurity ppt sercutity 右側將ppt on前面的勾取消 general advanced boot options enable legacy option roms ...

將網絡卡更改為混雜模式

網絡卡工作模式有4種,分別是 廣播 broadcast 模式 多播 multicast 模式 單播模式 unicast 混雜模式 promiscuous 在混雜模式下的網絡卡能夠接收一切通過它的資料,而不管該資料目的位址是否是它。如果通過程式將網絡卡的工作模式設定為 混雜模式 那麼網絡卡將接受所有流...