当前位置:网站首页>Keepalived configure virtual IP
Keepalived configure virtual IP
2022-06-09 04:18:00 【Little black notes】
YUM install
# yum install
yum -y install keepalived
# Check the installed version
rpm -qa keepalived
# Check the installation path
rpm -ql keepalived
Or use the source code to install
Download here https://www.keepalived.org/download.html
# Installation dependency
yum -y install gcc openssl-devel libnfnetlink-devel
Download source package
wget https://www.keepalived.org/software/keepalived-2.2.7.tar.gz # Here, the version number 2.2.7 Modify the desired version number
3) decompression
tar -zxvf keepalived-2.2.7.tar.gz -C /usr/src
4) Compilation and installation
cd /usr/src/keepalived-2.2.7/
./configure && make -j 4 && make install
Here are three hosts to make a virtual IP Get an example (2021 year )
Modify the configuration file contents /etc/keepalived/keepalived.conf
Start service usage instruction :service keepalived restart
# master Node configuration content :
! Configuration File for keepalived
vrrp_instance VI_1 {
state MASTER # It's certain that master node , Multiple master I don't know if my brain will crack , Didn't try
interface ens33
virtual_router_id 51
priority 100
advert_int 1
unicast_src_ip 192.168.163.134
unicast_peer {
192.168.163.132
192.168.163.133
}
authentication {
auth_type PASS
auth_pass 1111 # The code is random , Each host requires the same
}
virtual_ipaddress {
192.168.163.135
}
}
# node1 Node configuration content :
! Configuration File for keepalived
vrrp_instance VI_1 {
state BACKUP # It's certain that backup node
interface ens33
virtual_router_id 51
priority 50
advert_int 1
unicast_src_ip 192.168.163.132
unicast_peer {
192.168.163.133
192.168.163.134
}
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.163.135
}
}
# node2 Node configuration
! Configuration File for keepalived
vrrp_instance VI_1 {
state BACKUP # It's certain that backup node
interface ens33
virtual_router_id 51
priority 50
advert_int 1
unicast_src_ip 192.168.163.133
unicast_peer {
192.168.163.132
192.168.163.134
}
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.163.135
}
}
Here is an example of two machines (2022 year )
# master Node configuration content :
! Configuration File for keepalived
global_defs {
notification_email {
[email protected]
[email protected]
[email protected]
}
notification_email_from [email protected]
smtp_server 127.0.0.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 web {
script "/etc/keepalived/check_web_port.sh"
interval 1
weight -20
vrrp_instance VI_1 {
state MASTER
interface ens33
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.163.11
}
track_script {
web
}
}
virtual_server 192.168.163.11 8080 {
delay_loop 6
lb_algo rr
lb_kind NAT
persistence_timeout 50
persistence_timeout 1
protocol TCP
real_server 192.168.163.136 8080 {
weight 1
TCP_CHECK {
connect_timeout 1
nb_get_retry 3
delay_before_retry 3
connect_port 8080
}
}
real_server 192.168.163.137 8080 {
weight 1
TCP_CHECK {
connect_timeout 1
nb_get_retry 3
delay_before_retry 3
connect_port 8080
}
}
}
# node Node configuration content :
! Configuration File for keepalived
global_defs {
notification_email {
[email protected]rewall.loc
[email protected]
[email protected]
}
notification_email_from [email protected]
smtp_server 127.0.0.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 web {
script "/etc/keepalived/check_web_port.sh"
interval 1
weight -20
vrrp_instance VI_1 {
state BACKUP
interface ens33
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.163.11
}
track_script {
web
}
}
virtual_server 192.168.163.11 8080 {
delay_loop 6
lb_algo rr
lb_kind NAT
persistence_timeout 50
persistence_timeout 1
protocol TCP
real_server 192.168.163.136 8080 {
weight 1
TCP_CHECK {
connect_timeout 1
nb_get_retry 3
delay_before_retry 3
connect_port 8080
}
}
real_server 192.168.163.137 8080 {
weight 1
TCP_CHECK {
connect_timeout 1
nb_get_retry 3
delay_before_retry 3
connect_port 8080
}
}
}
# Scripts involved /etc/keepalived/check_web_port.sh"
#!/bin/bash
count=`nmap 127.0.0.1|grep 8080/tcp|wc -l`
if [ $count != 0 ]
then
exit 0
else
exit 1
fi
边栏推荐
猜你喜欢

Golang - - paquet d'exécution simultané

Simple reservation system for C language course design classroom

微信小程序:(异常)Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ 解决方案和分析流程(这里一定有你要的答案)

openGL_01-创建窗口

rigidbody2d 围绕某固定点point进行旋转rotate

1264_FreeRTOS任务的初始化以及堆栈初始化处理分析

全国大学生信息安全竞赛(CISCN)-reverse-复现(部分)

数据库连接问题,换版本后无法获取连接

keepalived配置虚拟IP

(3) Data binding instructions
随机推荐
Golang--- redis operation
[从零开始学习FPGA编程-14]:快速入门篇 - 操作步骤3(功能仿真)-3-modelsim快速使用入门(8bits循环计数器)
(2) v-cloak指令
Merkle Patricia trie principle
全国大学生信息安全竞赛(CISCN)-reverse-复现(部分)
(4)数据响应式
rigidbody2d 围绕某固定点point进行旋转rotate
YOLO、COCO和VOC数据集之间格式互换
openGL_04使用索引数组进行绘制
【6.824分布式系统】LEC 6&7: Fault Tolerance: Raft
[learn FPGA programming from scratch -14]: quick start chapter - operation step 3 (functional simulation) -3-modelsim quick start (8bits cycle counter)
MMdet修改检测框字体大小、位置、颜色、填充框
Rich color changes
17billion parameters, 28 open test sets SOTA, the industry's largest unified visual multi task model
golang---各个类型变量的比较运算
Lua operator
Attention OCR Chinese version mas ter code running logic
openGL_ 05 simple application of shader
Implementation of horizontal and vertical center of unknown width and height elements
(4) Data responsive