How To Set Up A Load-Balanced MySQL Cluster - Page 5
6 Configure The Load BalancersOur MySQL cluster is finished now, and you could start using it now. However, we don't have a single IP address that we can use to access the cluster, which means you must configure your applications in a way that a part of it uses the MySQL cluster node 1 (sql1.example.com), and the rest uses the other node (sql2.example.com). Of course, all your applications could just use one node, but what's the point then in having a cluster if you do not split up the load between the cluster nodes? Another problem is, what happens if one of the cluster nodes fails? Then the applications that use this cluster node cannot work anymore. The solution is to have a load balancer in front of the MySQL cluster which (as its name suggests) balances the load between the MySQL cluster nodes. The load blanacer configures a virtual IP address that is shared between the cluster nodes, and all your applications use this virtual IP address to access the cluster. If one of the nodes fails, then your applications will still work, because the load balancer redirects the requests to the working node. Now in this scenario the load balancer becomes the bottleneck. What happens if the load balancer fails? Therefore we will configure two load balancers (loadb1.example.com and loadb2.example.com) in an active/passive setup, which means we have one active load balancer, and the other one is a hot-standby and becomes active if the active one fails. Both load balancers use heartbeat to check if the other load balancer is still alive, and both load balancers also use ldirectord, the actual load balancer the splits up the load onto the cluster nodes. heartbeat and ldirectord are provided by the Ultra Monkey package that we will install. It is important that loadb1.example.com and loadb2.example.com have support for IPVS (IP Virtual Server) in their kernels. IPVS implements transport-layer load balancing inside the Linux kernel.
6.1 Install Ultra MonkeyOk, let's start: first we enable IPVS on loadb1.example.com and loadb2.example.com: loadb1.example.com / loadb2.example.com: modprobe ip_vs_dh In order to load the IPVS kernel modules at boot time, we list the modules in /etc/modules: loadb1.example.com / loadb2.example.com: vi /etc/modules
Now we edit /etc/apt/sources.list and add the Ultra Monkey repositories (don't remove the other repositories), and then we install Ultra Monkey: loadb1.example.com / loadb2.example.com: vi /etc/apt/sources.list
apt-get update Now Ultra Monkey is being installed. If you see this warning:
you can ignore it. Answer the following questions: Do you want to automatically load IPVS rules on boot? Select a daemon method. The libdbd-mysql-perl package we've just installed does not work with MySQL 5 (we use MySQL 5 on our MySQL cluster...), so we install the newest DBD::mysql Perl package: loadb1.example.com / loadb2.example.com: cd /tmp We must enable packet forwarding: loadb1.example.com / loadb2.example.com: vi /etc/sysctl.conf
sysctl -p
|
www.seamlessenterprise.com
One number. One voicemail. Seize the lead. Sprint Mobile Integration.
www.seamlessenterprise.com
One Number. One Voicemail.
Make it easier for clients to reach you. Turn your desk phone and mobile phone into one with Sprint Mobile Integration.
www.seamlessenterprise.com
One number. One voicemail. Sprint Mobile Integration.
www.seamlessenterprise.com
AT&T Synaptic Compute as a Service. Boost your power on demand.
Trial: IBM Cognos Express Reporting, Analysis & Planning
Learn benefits of Simpana software.
View the Gartner Video




print: 

Recent comments
14 hours 45 min ago
17 hours 29 min ago
22 hours 55 min ago
1 day 1 hour ago
1 day 2 hours ago
1 day 3 hours ago
1 day 4 hours ago
1 day 10 hours ago
1 day 11 hours ago
1 day 14 hours ago