keepalived 实现热备

基本环境
MASTER机,10.0.0.9
BACKUP机,10.0.0.10

1,安装

wget http://www.keepalived.org/software/keepalived-1.2.7.tar.gz
tar xvzf keepalived-1.2.7.tar.gz
cd keepalived-1.2.7
./configure
make
make install



2,配置(低版本貌似才需要这个配置)

cp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/
mkdir /etc/keepalived
cp /usr/local/sbin/keepalived /usr/sbin/
vi /etc/keepalived/keepalived.conf




3,MASTER配置keepalived.conf,避免立即将vip还回去配置双BACKUP


vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 11
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.100
10.0.0.101
}
}

vrrp_instance VI_2 {
state BACKUP
interface eth1
virtual_router_id 21
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.0.100
192.168.0.101
}
}





4,BACKUP配置keepalived.conf


vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 11
priority 10
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.100
10.0.0.101
}
}

vrrp_instance VI_2 {
state BACKUP
interface eth1
virtual_router_id 21
priority 10
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.0.100
192.168.0.101
}
}




5,启动
[code="java"]
# keepalived

[/code]

由于/etc/rc.d/init.d/keepalived start报错,故采用如此启动

6,MASTER机验证网络信息
[code="java"]
# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> 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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:50:56:20:3d:2a brd ff:ff:ff:ff:ff:ff
inet 10.0.0.9/24 brd 10.0.0.255 scope global eth0
inet 10.0.0.100/32 scope global eth0
inet 10.0.0.101/32 scope global eth0
inet6 fe80::250:56ff:fe20:3d2a/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:50:56:34:80:48 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.9/16 brd 192.168.0.255 scope global eth1
inet 192.168.0.100/32 scope global eth1
inet 192.168.0.101/32 scope global eth1
inet6 fe80::250:56ff:fe34:8048/64 scope link
valid_lft forever preferred_lft forever

[/code]

7,停MASTER机keepalived服务,验证BACKUP机网络
[code="java"]
# /etc/rc.d/init.d/keepalived stop
Stopping keepalived: [ OK ]

[/code]

[code="java"]
# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> 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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:50:56:2e:2b:6d brd ff:ff:ff:ff:ff:ff
inet 10.0.0.10/24 brd 10.0.0.255 scope global eth0
inet 10.0.0.100/32 scope global eth0
inet 10.0.0.101/32 scope global eth0
inet6 fe80::250:56ff:fe2e:2b6d/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:50:56:3b:e8:e2 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.10/16 brd 192.168.0.255 scope global eth1
inet 192.168.0.100/32 scope global eth1
inet 192.168.0.101/32 scope global eth1
inet6 fe80::250:56ff:fe3b:e8e2/64 scope link
valid_lft forever preferred_lft forever

[/code]

8,更新后的配置
[code="java"]
# cat /etc/keepalived/keepalived.conf

global_defs {
notification_email {
jie.zhang@ttpod.com
}
notification_email_from keepalived@ttpod.com
smtp_server 127.0.0.1
stmp_connect_timeout 30
router_id keepalived_for_backup
}

vrrp_script check_top {
script "/root/bin/check_top"
interval 10
weight 10
}

vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 11
priority 10
advert_int 1
nopreempt
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.100/24 dev eth0 label eth0:0
10.0.0.101/24 dev eth0 label eth0:1
}
track_script {
check_top weight 20
}
}

vrrp_instance VI_2 {
state BACKUP
interface eth1
virtual_router_id 21
priority 10
advert_int 1
nopreempt
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.0.100/16 dev eth1 label eth1:0
192.168.0.101/16 dev eth1 label eth1:1
}
track_script {
check_top
}
}


[/code]

9,查看网络信息
ip a
[code="java"]
# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> 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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:50:56:20:3d:2a brd ff:ff:ff:ff:ff:ff
inet 10.0.0.9/24 brd 10.0.0.255 scope global eth0
inet 10.0.0.100/24 scope global eth0:0
inet 10.0.0.101/24 scope global eth0:1
inet6 fe80::250:56ff:fe20:3d2a/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:50:56:34:80:48 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.9/16 brd 192.168.0.255 scope global eth1
inet 192.168.0.100/16 scope global eth1:0
inet 192.168.0.101/16 scope global eth1:1
inet6 fe80::250:56ff:fe34:8048/64 scope link
valid_lft forever preferred_lft forever

[/code]

ifconfig
[code="java"]
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:56:20:3D:2A
inet addr:10.0.0.9 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fe20:3d2a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1206 errors:0 dropped:0 overruns:0 frame:0
TX packets:1282 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:125352 (122.4 KiB) TX bytes:148912 (145.4 KiB)

eth0:0 Link encap:Ethernet HWaddr 00:50:56:20:3D:2A
inet addr:10.0.0.100 Bcast:0.0.0.0 Mask:255.255.255.255
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

eth0:1 Link encap:Ethernet HWaddr 00:50:56:20:3D:2A
inet addr:10.0.0.101 Bcast:0.0.0.0 Mask:255.255.255.255
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

eth1 Link encap:Ethernet HWaddr 00:50:56:34:80:48
inet addr:192.168.0.9 Bcast:192.168.0.255 Mask:255.255.0.0
inet6 addr: fe80::250:56ff:fe34:8048/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:349754 errors:0 dropped:0 overruns:0 frame:0
TX packets:476 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:21502934 (20.5 MiB) TX bytes:32269 (31.5 KiB)

eth1:0 Link encap:Ethernet HWaddr 00:50:56:34:80:48
inet addr:192.168.0.100 Bcast:0.0.0.0 Mask:255.255.255.255
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

eth1:1 Link encap:Ethernet HWaddr 00:50:56:34:80:48
inet addr:192.168.0.101 Bcast:0.0.0.0 Mask:255.255.255.255
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

[/code]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
毕业设计,基于SpringBoot+Vue+MySQL开发的公寓报修管理系统,源码+数据库+毕业论文+视频演示 现代经济快节奏发展以及不断完善升级的信息化技术,让传统数据信息的管理升级为软件存储,归纳,集中处理数据信息的管理方式。本公寓报修管理系统就是在这样的大环境下诞生,其可以帮助管理者在短时间内处理完毕庞大的数据信息,使用这种软件工具可以帮助管理人员提高事务处理效率,达到事半功倍的效果。此公寓报修管理系统利用当下成熟完善的Spring Boot框架,使用跨平台的可开发大型商业网站的Java语言,以及最受欢迎的RDBMS应用软件之一的MySQL数据库进行程序开发。公寓报修管理系统有管理员,住户,维修人员。管理员可以管理住户信息和维修人员信息,可以审核维修人员的请假信息,住户可以申请维修,可以对维修结果评价,维修人员负责住户提交的维修信息,也可以请假。公寓报修管理系统的开发根据操作人员需要设计的界面简洁美观,在功能模块布局上跟同类型网站保持一致,程序在实现基本要求功能时,也为数据信息面临的安全问题提供了一些实用的解决方案。可以说该程序在帮助管理者高效率地处理工作事务的同时,也实现了数据信息的整体化,规范化与自动化。 关键词:公寓报修管理系统;Spring Boot框架;MySQL;自动化;VUE
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值