伺服器架構配置keepalived 雙機熱備

2021-08-31 16:04:57 字數 2028 閱讀 6282

mkdir /usr/local/keepalived/

tar -zxvf keepalived-2.0.6.tar.gz -c /usr/local/keepalived

cd /usr/local/keepalived/keepalived-2.0.6

./configure

make

make install

cp -r keepalived /etc/init.d/keepalived

mkdir /etc/keepalived/

cd /usr/local/keepalived/keepalived-2.0.6/keepalived/etc/keepalived

cp keepalived.conf /etc/keepalived/

cd /usr/local/keepalived/keepalived-2.0.6/keepalived/etc/sysconfig/

cp keepalived /etc/sysconfig/keepalived

cp /usr/local/keepalived/keepalived-2.0.6/bin/keepalived /usr/sbin

vi /etc/keepalived/keepalived.conf #以下是配置的內容

vrrp_instance vi_1

virtual_ipaddress

}以上修改了如下三項

1.priority 101 #master值要大於bakcup

2.更改網路介面

vrrp_instance vi_1 中inte***ce:eno16777736(ip addr命令中的網路)

3.192.168.67.100 是虛擬ip

啟動keepalived

service keepalived start或者systemctl start keepalived

備用排程伺服器 只有一項不同

priority 100

同樣配置完畢後啟動keepalived

注意:#vrrp_strict #這個注釋掉,否則可能造成物理機的瀏覽器無法訪問應用

啟動keepalived

service keepalived start

設定開機自啟動

systemctl enable keepalived.service

如果nginx死掉,虛擬ip不會自動切換,如果要nginx停止執行後虛擬ip自動切換,需要設定指令碼:

#增加keepalived配置檔案

vi /etc/keepalived/keepalived.conf

#修改配置

! configuration file for 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

vrrp_garp_interval 0

vrrp_gna_interval 0

} vrrp_script chk_nginx

vrrp_instance vi_1

virtual_ipaddress

track_script

}#建立 vi /root/nginx_chk.sh,輸入指令碼

#!/bin/bash

if [ "$(ps aux | grep "nginx: master process"|grep -v grep)" == "" ]

then

#/etc/init.d/keepalived/keepalived stop

service keepalived stop

fi

伺服器架構 TCP IP協議配置

伺服器架構 什麼是伺服器 能夠為其他計算機提供服務的更高階的電腦 機架式塔式 機櫃式刀片式 典型服務模式 c s,client server 架構由伺服器提供資源或某種功能 客戶機使用資源或功能 客戶機 請求資源 功能 伺服器 提供資源 功能 tcp ip協議配置 tcp ip是最廣泛支援的通訊協議...

Linux SSH伺服器架構

1.ssh伺服器簡介 隨著網路應用的不斷普及,網路傳輸的資訊會越來越多,在保證資訊傳輸的同時,安全性也相當的重要。為了保證可靠的資料傳輸,一般都採用加密技術,而採用ssh進行加密,然後進行資料傳輸,這樣,資訊的安全性就得到了極大的提高。ssh是 secure shell安全外殼協議 ssh協議有兩個...

聊天伺服器架構

im系統種類 1.單聊 已讀未讀,端到端加密,離線訊息,2.群聊 大群 萬人群 記錄乙份聊天記錄。小群 200人以下群,使用者體驗不同,功能更多,可以在小群內做已讀未讀訊息,隱私訊息 小群 已讀未讀,使用mongodb記錄狀態。msgid,user 11110001 1 3.聊天室 沒有離線訊息的概...