lvs keepalived DR搭建高可用集群

2022-08-30 09:21:11 字數 3784 閱讀 6875

lvs+keepalived+dr搭建高可用集群

環境準備:

lvsserver1  192.168.1.10

lvsserver2  192.168.1.11

vip                   192.168.1.15

rs1                   192.168.1.12

rs2                   192.168.1.13

lvsserver1和lvsserver2操作:

開啟路由**

臨時生效  echo "1" > /proc/sys/net/ipv4/ip_forward

永久生效  vim /etc/sysctl.conf

net.ipv4.ip_forward = 1

1

安裝ipvsadm以及keepadlived

2[root@lvs1 ~]# yum install gcc* c++ * autoconf automake zlib* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* popt-devel libnl-devel kernel-devel ipvsadm

3[root@lvs1 ~]# wget //不推薦使用最新版本

4[root@lvs1 ~]# tar -xf keepalived-1.1.19.tar.gz

5[root@lvs1 ~]# ./configure

6keepalived configuration78

------------------------910

keepalived version : 1.1.17

11compiler : gcc

12compiler flags : -g -o2

13extra lib : -lpopt -lssl -lcrypto

14use ipvs framework : no **使用ipvs框架,也就是負載均衡模組

15ipvs sync daemon support : no **啟用ipvs同步功能

16use vrrp framework : yes **實現高可用的必須模組

17use linkwatch : no

18use debug flags : no

1920

當出現這兩個為no的時候,則需以下操作

2122

[root@lvs1 ~]# ./configure --with-kernel-dir=/usr/src/kernels/2.6.32-754.11.1.el6.x86_64/

23[root@lvs1 ~]# make

24[root@lvs1 ~]# make install

25[root@lvs1 ~]# cp -a /usr/local/etc/rc.d/init.d/keepalived /etc/init.d/

26[root@lvs1 ~]# cp -a /usr/local/etc/sysconfig/keepalived /etc/sysconfig/

27[root@lvs1 ~]# mkdir -p /etc/keepalived

28[root@lvs1 ~]# cp -a /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/

29[root@lvs1 ~]# cp -a /usr/local/sbin/keepalived /usr/bin/

30[root@lvs1 ~]# cd /etc/keepalived && cp -a keepalived.conf keepalived.conf.bak

31[root@lvs1 ~]# cat keepalived.conf

32[root@lvs1 ~]# cat /etc/keepalived/keepalived.conf

33! configuration file for keepalived

3435

global_defs

3839

vrrp_instance vi_1

50virtual_ipaddress 53}

5455

virtual_server 192.168.1.15 443 71}

7273

real_server 192.168.1.13 443 81}

82}8384

virtual_server 192.168.1.15 2222

100}

101102

real_server 192.168.1.13 2222

110}

111}

112113

兩台機器都啟動keepalived以及ipvsadm

114 [root@lvs1 ~]# ip addr **檢視vip在哪

rs1和rs2操作:

1

[root@lvs-nginx1 ~]# cat /etc/init.d/lvs

2#!/bin/bash34

vip=192.168.1.1556

/etc/rc.d/init.d/functions78

case "$1" in910

start)

11echo "start lvs of realserver dr"

12/sbin/ifconfig lo:0 $vip broadcast $vip netmask 255.255.255.255 up

13echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore

14echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce

15echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore

16echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce

17;;

18stop)

19/sbin/ifconfig lo:0 down

20echo "close lvs of realserver dr"

21echo "0" >/proc/sys/net/ipv4/conf/lo/arp_ignore

22echo "0" >/proc/sys/net/ipv4/conf/lo/arp_announce

23echo "0" >/proc/sys/net/ipv4/conf/all/arp_ignore

24echo "0" >/proc/sys/net/ipv4/conf/all/arp_announce

25;;

26*)

27echo "usage: $0 "

28exit 1

29esac

3031

exit 0

3233

[root@lvs-nginx1 ~]# /etc/init.d/lvs start

34 [root@lvs-nginx1 ~]# echo "/etc/init.d/lvs start" >> /etc/rc.d/rc.local

最後使用ipvsadm -l檢視結果以及切換演練

nginx.conf 開啟 stream 

#stream

upstream aaa_ssl

server

server

#}

milvus高可用搭建

基於keepalived部署milvus高可用問題 雙寫冷備 兩個寫節點不能同時啟動,否則會導致資料重複,通過增加與閘道器的連通性來解決可能同時啟動的問題,但不能完全保證沒有特殊情況的存在。另外宕機時可能會導致資料丟失。一寫一讀 可以同時啟動,但是寫節點宕機時,資料不能寫入。基於minio的共享儲存...

mysql keepalived搭建高可用環境

假設已經搭建好了mysql並且存在正常狀態的主主複製 1 安裝keepalived並且根據業務的vip及主機網絡卡,ip配置好 etc keepalived keepalived.conf,具體操作已在 框中實現 1 安裝環境 謹慎,建議先編譯,能通過就不要進行第一步了 yum y install ...

搭建eureka高可用

1.設定伺服器之間的host,測試環境是在window10上搭建的,所以去修改c windows system32 drivers etc檔案,如下 2.建立專案 一組服務需要使用相同的服務名稱,才能被識別為一組!name eureka server eureka client 集群模式需要設定為t...