lvs的高可用部署

2021-09-19 09:28:35 字數 3337 閱讀 4650

避免單點故障(vs故障),需要高可用 – 多個排程器。可用keepalived來實現

vrrp是一種容錯協議,它保證當主機的下一跳路由器出現故障時,由另一台路由器來代替出現故障的路由器進行工作,從而保持網路通訊的連續性和可靠性。

tar -zxvf keepalived-2.0.6.tar.gz

進入keepalived-2.0.6目錄,安裝keepalived的支援元件

cd keepalived-2.0.6

yum install -y gcc openssl-devel

原始碼編譯安裝

./configure --prefix=/usr/local/keepalived --with-init=sysv

make && make install

cd /usr/local/

scp -r keepalived server4:/usr/local/ server4可直接將包的目錄拷過去

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

chmod +x keepalived

做鏈結

ln -s /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/

ln -s /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig

ln -s /usr/local/keepalived/etc/keepalived /etc

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

配置keepalived

vim /etc/keepalived/keepalived.conf

keepalived配置檔案詳解:

keepalived的所有配置都在乙個配置檔案裡面設定,支援的配置項主要分三類:

全域性配置(global configuration):作用於整個keepalived服務

vrrpd配置:keepalived的核心

虛擬服務配置:指定服務與負載均衡 配置檔案都是以塊(block)形式組織的,每個塊都在包圍的範圍內

#和!開頭的行都是注釋

! configuration file for keepalived

#全域性配置

global_defs

#設定郵件的傳送位址

notification_email_from keepalived@localhost

smtp_server 127.0.01 #設定 smtp server 位址

smtp_connect_timeout 30 #設定連線 smtp 伺服器超時時間

router_id lvs_devel #load balancer 的標識 id,用於 email 警報

vrrp_skip_check_adv_addr

#vrrp_strict

vrrp_garp_interval 0

vrrp_gna_interval 0}

#vrrpd配置

vrrp_instance vi_1

##指定漂移位址(vip),即切換到master時,這些ip會被新增,切換到backup時,這些ip會被刪除(傳給ip addr命令),所以每台伺服器可以不用繫結任何的虛擬位址。

virtual_ipaddress }

##虛擬服務配置

virtual_server 172.25.254.100 80

}real_server 172.25.254.3 80

}}

開啟服務

/etc/init.d/keepalived start

server4同上(配置檔案略有區別)

[root@server1 init.d]# ip a

1: lo: mtu 16436 qdisc noqueue state unknown

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

inet6 ::1/128 scope host

valid_lft forever preferred_lft forever

2: eth3:

mtu 1500 qdisc pfifo_fast state up qlen 1000

link/ether 52:54:00:09:8c:2e brd ff:ff:ff:ff:ff:ff

inet 172.25.254.1/24 brd 172.25.254.255 scope global eth3

inet 172.25.254.100/32scope global eth3

inet6 fe80::5054:ff:fe09:8c2e/64 scope link

valid_lft forever preferred_lft forever

當server1掛掉之後。

[root@server4 ~]# ip a

1: lo: mtu 16436 qdisc noqueue state unknown

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

inet6 ::1/128 scope host

valid_lft forever preferred_lft forever

2: eth1:

mtu 1500 qdisc pfifo_fast state up qlen 1000

link/ether 52:54:00:63:e6:c8 brd ff:ff:ff:ff:ff:ff

inet 172.25.254.4/24 brd 172.25.254.255 scope global eth1

inet 172.25.254.100/32 scope global eth1

inet6 fe80::5054:ff:fe63:e6c8/64 scope link

valid_lft forever preferred_lft forever

同時keepalived也可實現高可用。

通過keepalived搭建LVS高可用集群

通過keepalived搭建lvs高可用集群 實驗環境 主director server 192.168.163.3 備director server 192.168.163.4 real server1 192.168.163.5 real server2 192.168.163.6 vip 19...

lvs負載均衡高可用集群

集群的概念 圖中所示傳統模式存在很多弊端,比如無法承受大規模的併發訪問或資料流量。當伺服器出現問題宕機之後,所有的業務都會受到影響。又或當業務量增多時,伺服器得到處理能力到達瓶頸,需要對伺服器進行擴充套件。對伺服器的擴充套件可從兩個方面,縱向擴充套件或者是橫向擴充套件。縱向擴充套件是從硬體上提公升伺...

nginx,keepalived高可用部署

環境 172.16.91.218 主 172.16.91.219 安裝包版本 nginx 1.14.0.tar.gz keepalived 2.0.7.tar.gz 把 nginx,keepalived 壓縮包 上傳到 usr local src 兩個機器 都 安裝 nginx 安裝 依賴 包 yu...