LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Please help to load balancing httpd and mysqld with keepalived (https://www.linuxquestions.org/questions/linux-software-2/please-help-to-load-balancing-httpd-and-mysqld-with-keepalived-830929/)

chobong 09-08-2010 04:06 AM

Please help to load balancing httpd and mysqld with keepalived
 
Dear All,

I have 4 servers:
- One is loadbalancer, installed keepalived and ipvsadm - LV1
- One is failover for loadbalancer, installed keepalived and ipvsadm too - LV2
- The other servers was installed httpd and mysqld. (RealServer)
LV1 load balancing for both httpd and mysql. And it's working fine.
VIP for http: 192.168.1.110
VIP for mysql: 192.168.1.111

Now I want to setup a website on RealServers , with URL is http://192.168.1.110, and this website connect to mysql via VIP 192.168.1.111, this means real servers will connect to their mysql via load balancer (LV!).
I tried to connect mysql via VIP from real server but it cannot.

Please help me if I can make this?
Thanks so much!!

kbp 09-08-2010 07:27 AM

Maybe start with tcpdump on LV1 and watch port 3306 (I think), it may not be routing between VIP's

cheers

chobong 09-08-2010 11:08 PM

Thanks a lot, kbp.

Actually, when I stand at RealServer1 and connect to VIP:mysql, it's ok at the first, but not ok at the second, and ok at the third... RealServer2 is the same.
I think when a RealServer connect to its mysql, it's NOT ok.
But when a RealServer connect to mysql of the other, it's ok.

I don't know why...
Could you please let me know how to route between VIP?

kbp 09-08-2010 11:20 PM

Are you doing active/passive load balancing for mysql or active/active ?

chobong 09-08-2010 11:23 PM

I did keepalived with roundrobin for load balancing mysql. That is your mean?
Uhm, mysql is being active at both two realservers..

chobong 09-09-2010 04:52 AM

And Im having a trouble with keepalived.:(
Status is MASTER on both LV1 and LV2, not MASTER and BACKUP.
Ipvsadm is still working fine !!

In the log message on two servers
Code:

[root@localhost ~]# tail /var/log/messages
Sep  9 22:46:13 localhost Keepalived_vrrp: cant bind to device eth0. errno=9. (try to run it as root)
Sep  9 22:46:13 localhost Keepalived_vrrp: VRRP_Instance(VI) Transition to MASTER STATE
Sep  9 22:46:14 localhost Keepalived_vrrp: VRRP_Instance(VI) Entering MASTER STATE
Sep  9 22:46:14 localhost Keepalived_vrrp: VRRP_Instance(VI) setting protocol VIPs.
Sep  9 22:46:14 localhost Keepalived_vrrp: VRRP_Instance(VI) Sending gratuitous ARPs on eth0 for 192.168.1.110
Sep  9 22:46:14 localhost Keepalived_vrrp: VRRP_Instance(VI) Sending gratuitous ARPs on eth0 for 192.168.1.111
Sep  9 22:46:14 localhost Keepalived_vrrp: Remote SMTP server [127.0.0.1:25] connected.
Sep  9 22:46:15 localhost Keepalived_vrrp: SMTP alert successfully sent.
Sep  9 22:46:19 localhost Keepalived_vrrp: VRRP_Instance(VI) Sending gratuitous ARPs on eth0 for 192.168.1.110
Sep  9 22:46:19 localhost Keepalived_vrrp: VRRP_Instance(VI) Sending gratuitous ARPs on eth0 for 192.168.1.111

And here is my configuration
Code:

vrrp_instance VI {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 120
    nopreempt
    smtp_alert
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.1.110
        192.168.1.111
    }
}

At this time, LV1 load balancing, but at other time, LV2 load balancing...
Please help me.
Thank you so much!

chobong 09-09-2010 05:11 AM

Please forget about latest reply!

That is because I didn't allow multicast IP 224.0.0.8 and protocol 112 in iptables.
Just add lines which listed below in iptables and restart it.
Code:

-A RH-Firewall-1-INPUT -i eth0 -d 224.0.0.0/8 -j ACCEPT
-A RH-Firewall-1-INPUT -i eth0 -p 112 -j ACCEPT

Refer this link: http://www.cyberciti.biz/faq/linux-u...orking-or-not/

chobong 09-10-2010 05:04 AM

Quote:

Originally Posted by chobong (Post 4092057)
Thanks a lot, kbp.

Actually, when I stand at RealServer1 and connect to VIP:mysql, it's ok at the first, but not ok at the second, and ok at the third... RealServer2 is the same.
I think when a RealServer connect to its mysql, it's NOT ok.
But when a RealServer connect to mysql of the other, it's ok.

I don't know why...
Could you please let me know how to route between VIP?

Anyone knows? Please help me ...


All times are GMT -5. The time now is 01:04 AM.