4

Following servers:

....:100::10 mysql1 master
....:100::20 mysql2 master
....:100::30 loadbalancer (keepalived) with virtual ip ...:100::40

Config:

vrrp_instance V1 {
    state MASTER
    interface eth0
    lvs_sync_daemon_inteface eth0
    virtual_router_id 51
    priority 150
    advert_int 1
    smtp_alert

    virtual_ipaddress {
       ...:100::40
    }
}

virtual_server ...:100::40 3306 {
    delay_loop 6
    lb_algo wrr
    lb_kind DR
    protocol TCP

    real_server ...:100::10 3306 {
            weight 50
            TCP_CHECK {
                    connect_timeout 3
                    connect_port 3306
            }
    }

    real_server ...:100::20 3306 {
            weight 10
            TCP_CHECK {
               connect_timeout 3
               connect_port 3306
            }
    }

}

The connection directly to both servers are working: (bind-address = :: and no ip6tables firewall active)

$ mysql -uroot -p -h...:100::10
Welcome to the MySQL monitor.  Commands end with ; or \g.

$ mysql -uroot -p -h...:100::20
Welcome to the MySQL monitor.  Commands end with ; or \g.

...:100:30 of course not:

$ mysql -uroot -p -h...:100::30
ERROR 2003 (HY000): Can't connect to MySQL server on '...:100::30' (111)

Unfortunately I get a timeout for ...:100::40

$ mysql -uroot -p -h...:100::40
ERROR 2003 (HY000): Can't connect to MySQL server on '...:100::40' (110)

ipvsadm looks ok to me:

# ipvsadm
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port      Forward Weight ActiveConn InActConn
TCP  [...:100::40]:mysql     wrr
  -> [...:100::10]:mysql     Route   50     0          0

# ifconfig
eth0      Link encap:Ethernet  HWaddr ..........
          inet6 addr: ............/64 Scope:Link
          inet6 addr: ...:100::30/64 Scope:Global
          inet6 addr: ...:100::40/128 Scope:Global

My problem is now, that keepalived is not listening on port 3306:

# netstat -nlta
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN
tcp6       0      0 ::1:25                  :::*                    LISTEN

# keepalived --help
Keepalived v1.2.2 (12/18,2011)

Where is the fault?

da_didi
  • 255
  • 4
  • 11

1 Answers1

2

Each realserver needs an configuration change or it will discard the network packets, because it doesn't response on the virtual IP address (e.g. ...:100:40)

# nano /etc/sysctl.conf
net.ipv4.conf.eth0.arp_ignore = 1
net.ipv4.conf.eth0.arp_announce = 2

or directly

echo 1 > /proc/sys/net/ipv4/conf/eth0/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/eth0/arp_announce

You need to add the virtual IP address to the local loopback:

ip addr add 2a00:14e0:600:1200:100::40 dev lo

And edit the /etc/network/interfaces so the change is persistent after a reboot:

iface eth0 inet6 static
    address ...:100::20
    netmask 64
    gateway ...::1
    post-up ip addr add ...:100::40 dev lo

Right now the first connect times out, but the second connect is working fine. I will test this.

da_didi
  • 255
  • 4
  • 11