10.0.0.150 ka1
10.0.0.160 ka2
10.0.0.170 web1
10.0.0.180 web2
10.0.0.190 client
[root@ka1 ~]
[root@ka1 ~]
! Configuration File for keepalived
global_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id ka1
vrrp_mcast_group4 224.0.100.10
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
10.0.0.188/24 dev eth0 label eth0:1
}
}
virtual_server 10.0.0.188 80 {
delay_loop 6
lb_algo rr
lb_kind DR
protocol TCP
sorry_server 127.0.0.1 80
real_server 10.0.0.170 80 {
weight 1
HTTP_GET {
url {
path /
status_code 200
}
connect_timeout 1
retry 3
delay_before_retry 1
}
}
real_server 10.0.0.180 80 {
weight 1
HTTP_GET {
url {
path /
status_code 200
}
connect_timeout 1
retry 3
delay_before_retry 1
}
}
}
[root@ka1 ~]
[root@ka1 ~]
[root@ka2 ~]
[root@ka2 ~]
! Configuration File for keepalived
global_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id ka2
vrrp_mcast_group4 224.0.100.10
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 80
advert_int 1
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
10.0.0.188/24 dev eth0 label eth0:1
}
}
virtual_server 10.0.0.188 80 {
delay_loop 6
lb_algo rr
lb_kind DR
protocol TCP
sorry_server 127.0.0.1 80
real_server 10.0.0.170 80 {
weight 1
HTTP_GET {
url {
path /
status_code 200
}
connect_timeout 1
retry 3
delay_before_retry 1
}
}
real_server 10.0.0.180 80 {
weight 1
HTTP_GET {
url {
path /
status_code 200
}
connect_timeout 1
retry 3
delay_before_retry 1
}
}
}
[root@ka2 ~]
[root@ka2 ~]
[root@web1 ~]
vip=10.0.0.188
mask='255.255.255.255'
dev=lo:1
rpm -q httpd &> /dev/null || yum -y install httpd &>/dev/null
service httpd start &> /dev/null && echo "The httpd Server is Ready!"
echo "<h1>`hostname`</h1>" > /var/www/html/index.html
case $1 in
start)
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce
ifconfig $dev $vip netmask $mask
echo "The RS Server is Ready!"
;;
stop)
ifconfig $dev down
echo 0 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 0 > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo 0 > /proc/sys/net/ipv4/conf/all/arp_announce
echo 0 > /proc/sys/net/ipv4/conf/lo/arp_announce
echo "The RS Server is Canceled!"
;;
*)
echo "Usage: $(basename $0) start|stop"
exit 1
;;
esac
[root@web1 ~]
The httpd Server is Ready!
The RS Server is Ready!
[root@web1 ~]
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet 10.0.0.188/32 scope global lo:1
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:90:bc:7e brd ff:ff:ff:ff:ff:ff
inet 10.0.0.170/24 brd 10.0.0.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:46:bf:71 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:46:bf:71 brd ff:ff:ff:ff:ff:ff
[root@web1 ~]
<h1>web1.tan.com</h1>
[root@web2 ~]
vip=10.0.0.188
mask='255.255.255.255'
dev=lo:1
rpm -q httpd &> /dev/null || yum -y install httpd &>/dev/null
service httpd start &> /dev/null && echo "The httpd Server is Ready!"
echo "<h1>`hostname`</h1>" > /var/www/html/index.html
case $1 in
start)
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce
ifconfig $dev $vip netmask $mask
echo "The RS Server is Ready!"
;;
stop)
ifconfig $dev down
echo 0 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 0 > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo 0 > /proc/sys/net/ipv4/conf/all/arp_announce
echo 0 > /proc/sys/net/ipv4/conf/lo/arp_announce
echo "The RS Server is Canceled!"
;;
*)
echo "Usage: $(basename $0) start|stop"
exit 1
;;
esac
[root@web2 ~]
The httpd Server is Ready!
The RS Server is Ready!
[root@web2 ~]
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet 10.0.0.188/32 scope global lo:1
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:98:bc:23 brd ff:ff:ff:ff:ff:ff
inet 10.0.0.180/24 brd 10.0.0.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe98:bc23/64 scope link
valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:46:bf:71 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:46:bf:71 brd ff:ff:ff:ff:ff:ff
[root@web2 ~]
<h1>web2.tan.com</h1>
[root@redis-node5 ~]
<h1>web1.tan.com</h1>
<h1>web2.tan.com</h1>
<h1>web1.tan.com</h1>
<h1>web2.tan.com</h1>
<h1>web1.tan.com</h1>
<h1>web2.tan.com</h1>
<h1>web1.tan.com</h1>
<h1>web2.tan.com</h1>
<h1>web1.tan.com</h1>
<h1>web2.tan.com</h1>
<h1>web1.tan.com</h1>
<h1>web2.tan.com</h1>
<h1>web1.tan.com</h1>
<h1>web2.tan.com</h1>
<h1>web1.tan.com</h1>
[root@ka1 ~]
[root@client ~]
<h1>web2.tan.com</h1>
<h1>web1.tan.com</h1>
<h1>web2.tan.com</h1>
<h1>web1.tan.com</h1>
<h1>web2.tan.com</h1>
<h1>web1.tan.com</h1>
<h1>web2.tan.com</h1>
[root@web1 ~]
[root@client ~]
<h1>web1.tan.com</h1>
<h1>web2.tan.com</h1>
<h1>web1.tan.com</h1>
<h1>web2.tan.com</h1>
curl: (7) Failed to connect to 10.0.0.188 port 80: Connection refused
<h1>web2.tan.com</h1>
curl: (7) Failed to connect to 10.0.0.188 port 80: Connection refused
<h1>web2.tan.com</h1>
curl: (7) Failed to connect to 10.0.0.188 port 80: Connection refused
<h1>web2.tan.com</h1>
curl: (7) Failed to connect to 10.0.0.188 port 80: Connection refused
<h1>web2.tan.com</h1>
<h1>web2.tan.com</h1>
<h1>web2.tan.com</h1>
<h1>web2.tan.com</h1>
[root@web1 ~]
[root@client ~]
<h1>web2.tan.com</h1>
<h1>web2.tan.com</h1>
<h1>web2.tan.com</h1>
<h1>web1.tan.com</h1>
<h1>web2.tan.com</h1>
<h1>web1.tan.com</h1>
[root@web1 ~]
[root@web2 ~]
[root@client ~]
<h1>web2.tan.com</h1>
<h1>web1.tan.com</h1>
<h1>web2.tan.com</h1>
curl: (7) Failed to connect to 10.0.0.188 port 80: Connection refused
<h1>web2.tan.com</h1>
curl: (7) Failed to connect to 10.0.0.188 port 80: Connection refused
<h1>web2.tan.com</h1>
curl: (7) Failed to connect to 10.0.0.188 port 80: Connection refused
curl: (7) Failed to connect to 10.0.0.188 port 80: Connection refused
curl: (7) Failed to connect to 10.0.0.188 port 80: Connection refused
curl: (7) Failed to connect to 10.0.0.188 port 80: Connection refused
curl: (7) Failed to connect to 10.0.0.188 port 80: Connection refused
sorry server
sorry server
sorry server
sorry server
sorry server
sorry server
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· 写一个简单的SQL生成工具