232121 发表于 2016-5-12 09:35:15

keepalived+lvs高可用一个集群服务

准备阶段:
    keepalived
    ipvsadm





   

IP设计:   
    LVS-DR-MASTER:172.18.1.105
    LVS-DR-BACKUP:172.18.1.106
    VIP:172.18.1.66

    GateWay:192.168.10.254

    RS1:192.168.10.11

    RS2:192.168.10.12



编辑主路由/etc/keepalived/keepalived.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
global_defs {
   notification_email {
      root@localhost#发送邮件地址为本机的root
   }
   notification_email_from test@ka.com
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id node1
   vrrp_mcast_group4 224.0.49.18
}

vrrp_instance VI_1 {
    state MASTER#为主路由
    interface eno16777736
    virtual_router_id 49
    priority 100 #优先级,数字越大优先级越高
    advert_int 1
    authentication {
      auth_type PASS
      auth_pass khR8lPmc
    }
    virtual_ipaddress {
      172.18.100.88 dev eno16777736 label eno16777736:0
    }
}

将此文件复制到备路由一份,并保存到/etc/keepalived/keepalived.conf
只需要更改
state BACKUP


priority 98





接下来测试

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# systemctl start keepalived.service #先启动主路由
# ifconfig #查看地址,172.18.100.88已经添加上了
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>mtu 1500
      inet 172.18.1.109netmask 255.255.0.0broadcast 172.18.255.255
      inet6 fe80::20c:29ff:fef8:338prefixlen 64scopeid 0x20<link>
      ether 00:0c:29:f8:03:38txqueuelen 1000(Ethernet)
      RX packets 8698bytes 5562385 (5.3 MiB)
      RX errors 0dropped 0overruns 0frame 0
      TX packets 8582bytes 897646 (876.6 KiB)
      TX errors 0dropped 0 overruns 0carrier 0collisions 0

eno16777736:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>mtu 1500
      inet 172.18.100.88netmask 255.255.255.255broadcast 0.0.0.0
      ether 00:0c:29:f8:03:38txqueuelen 1000(Ethernet)

lo: flags=73<UP,LOOPBACK,RUNNING>mtu 65536
      inet 127.0.0.1netmask 255.0.0.0
      inet6 ::1prefixlen 128scopeid 0x10<host>
      looptxqueuelen 0(Local Loopback)
      RX packets 0bytes 0 (0.0 B)
      RX errors 0dropped 0overruns 0frame 0
      TX packets 0bytes 0 (0.0 B)
      TX errors 0dropped 0 overruns 0carrier 0collisions 0






页: [1]
查看完整版本: keepalived+lvs高可用一个集群服务