- 论坛徽章:
- 0
|
lvs master:192.168.2.6
lvs backup:192.168.2.101
realserver1:192.168.2.103
realserver2:192.168.2.13
keepalived的配置如下:
! Configuration File for keepalived
global_defs {
router_id lvs_1
}
vrrp_sync_group mysql {
group {
mysql_userdb
}
vrrp_instance mysql_userdb {
state MASTER
interface eth1
lvs_sync_daemon_interface eth1
virtual_router_id 51
priority 180
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.2.242
}
}
virtual_server 192.168.2.242 3306 {
delay_loop 6
lb_algo rr
lb_kind DR
persistence_timeout 600
protocol TCP
real_server 192.168.2.103 3306 {
weight 1
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 3306
}
}
real_server 192.168.2.13 3306 {
weight 1
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 3306
}
}
}
}
在MASTER上启动keepalived后,ip addr list无法看到vip
[root@localhost ~]# ipvsadm
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress ort Scheduler Flags
-> RemoteAddress ort Forward Weight ActiveConn InActConn
TCP 192.168.2.242:mysql rr persistent 600
-> 192.168.2.13:mysql Route 1 0 0
-> 192.168.2.103:mysql Route 1 0 0
root@localhost ~]# ip addr list
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet 192.168.1.112/32 brd 192.168.1.112 scope global lo:0
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 78:2b:cb:48:58:10 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.6/24 brd 192.168.1.255 scope global eth0
inet6 fe80::7a2b:cbff:fe48:5810/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 78:2b:cb:48:58:12 brd ff:ff:ff:ff:ff:ff
inet 192.168.2.6/16 brd 192.168.2.255 scope global eth1
inet6 fe80::7a2b:cbff:fe48:5812/64 scope link
valid_lft forever preferred_lft forever
4: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000
link/ether 78:2b:cb:48:58:14 brd ff:ff:ff:ff:ff:ff
keeplived的启动日志如下:
Apr 24 16:06:45 localhost Keepalived: Stopping Keepalived v1.1.17 (04/24,2013)
Apr 24 16:06:45 localhost Keepalived_vrrp: Terminating VRRP child process on signal
Apr 24 16:06:45 localhost Keepalived_healthcheckers: Terminating Healthchecker child process on signal
Apr 24 16:06:45 localhost Keepalived: Starting Keepalived v1.1.17 (04/24,2013)
Apr 24 16:06:45 localhost Keepalived_healthcheckers: Using MII-BMSR NIC polling thread...
Apr 24 16:06:45 localhost Keepalived: Starting Healthcheck child process, pid=19778
Apr 24 16:06:45 localhost Keepalived: Starting VRRP child process, pid=19779
Apr 24 16:06:45 localhost Keepalived_vrrp: Using MII-BMSR NIC polling thread...
Apr 24 16:06:45 localhost Keepalived_healthcheckers: Netlink reflector reports IP 192.168.1.6 added
Apr 24 16:06:45 localhost Keepalived_healthcheckers: Netlink reflector reports IP 192.168.2.6 added
Apr 24 16:06:45 localhost Keepalived_vrrp: Netlink reflector reports IP 192.168.1.6 added
Apr 24 16:06:45 localhost Keepalived_healthcheckers: Registering Kernel netlink reflector
Apr 24 16:06:45 localhost Keepalived_healthcheckers: Registering Kernel netlink command channel
Apr 24 16:06:45 localhost Keepalived_vrrp: Netlink reflector reports IP 192.168.2.6 added
Apr 24 16:06:45 localhost Keepalived_vrrp: Registering Kernel netlink reflector
Apr 24 16:06:45 localhost Keepalived_vrrp: Registering Kernel netlink command channel
Apr 24 16:06:45 localhost Keepalived_vrrp: Registering gratutious ARP shared channel
Apr 24 16:06:45 localhost Keepalived_healthcheckers: Opening file '/etc/keepalived/keepalived.conf'.
Apr 24 16:06:45 localhost Keepalived_healthcheckers: Configuration is using : 12385 Bytes
Apr 24 16:06:45 localhost Keepalived_vrrp: Opening file '/etc/keepalived/keepalived.conf'.
Apr 24 16:06:45 localhost Keepalived_vrrp: Configuration is using : 60734 Bytes
Apr 24 16:06:45 localhost Keepalived_healthcheckers: Activating healtchecker for service [192.168.2.103:3306]
Apr 24 16:06:45 localhost Keepalived_healthcheckers: Activating healtchecker for service [192.168.2.13:3306]
请问keepalived如何绑定vip呢? |
|