Merge lp:~seuis398/mysql-mmm/reliable_virtual_ip into lp:mysql-mmm

Proposed by SeWoong Jeon
Status: Needs review
Proposed branch: lp:~seuis398/mysql-mmm/reliable_virtual_ip
Merge into: lp:mysql-mmm
Diff against target: 61 lines (+19/-4)
2 files modified
lib/Agent/Helpers/Network.pm (+2/-2)
lib/Monitor/Agents.pm (+17/-2)
To merge this branch: bzr merge lp:~seuis398/mysql-mmm/reliable_virtual_ip
Reviewer Review Type Date Requested Status
mysql-mmm-core Pending
Review via email: mp+91789@code.launchpad.net

Description of the change

Because there is a limit to the number of arp packet a switch can handle simultaneously, MMM arp packets can be ignored sometimes.
In that case, client host cannot access mysql db through virtual ip, because of wrong arp cache.
So, arp packet send interval need to be increased.

And... to make sure virtual ip is assigned exactly,
mmm_control executes "vip ping test" and displays the result. ("Net::Ping" is required.)

(Ex.) $ mmm_control show
  db01(192.168.56.10) master/ONLINE. Roles: writer(192.168.56.20)/Ping_OK
  db02(192.168.56.11) master/ONLINE. Roles: reader(192.168.56.21)/Ping_Error

To post a comment you must log in.

Unmerged revisions

149. By SeWoong Jeon

To make sure vip is assigned exactly,
mmm_control executes "vip ping test" and displays the result.
"Net::Ping" is required.

(Ex.) $ mmm_control show
  db01(192.168.56.10) master/ONLINE. Roles: writer(192.168.56.20)/Ping_OK
  db02(192.168.56.11) master/ONLINE. Roles: reader(192.168.56.21)/Ping_Error

148. By SeWoong Jeon

Because there is a limit to the number of arp packet switch can handle simultaneously,
MMM arp packets can be ignored sometimes.
In that case, client host cannot access mysql db through virtual ip, because of wrong arp cache.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/Agent/Helpers/Network.pm'
2--- lib/Agent/Helpers/Network.pm 2010-02-05 17:27:32 +0000
3+++ lib/Agent/Helpers/Network.pm 2012-02-07 10:31:03 +0000
4@@ -141,11 +141,11 @@
5 }
6 return "ERROR: Couldn't get mac adress of interface $if" unless ($mac);
7
8- for (my $i = 0; $i < 5; $i++) {
9+ for (my $i = 0; $i < 10; $i++) {
10 Net::ARP::send_packet($if, $ip, $ip, $mac, 'ff:ff:ff:ff:ff:ff', 'request');
11 usleep(50);
12 Net::ARP::send_packet($if, $ip, $ip, $mac, 'ff:ff:ff:ff:ff:ff', 'reply');
13- usleep(50) if ($i < 4);
14+ sleep(1) if ($i < 9);
15 }
16 }
17 elsif ($OSNAME eq 'solaris') {
18
19=== modified file 'lib/Monitor/Agents.pm'
20--- lib/Monitor/Agents.pm 2009-06-11 07:10:36 +0000
21+++ lib/Monitor/Agents.pm 2012-02-07 10:31:03 +0000
22@@ -9,7 +9,7 @@
23 use File::Basename;
24 use MMM::Monitor::Agent;
25 use MMM::Monitor::Role;
26-
27+use Net::Ping;
28
29
30
31@@ -131,14 +131,29 @@
32 my $detailed= shift || 0;
33 my $res = '';
34 my $agent_res = '';
35+ my $p = Net::Ping->new("tcp");
36
37 keys (%$self); # reset iterator
38 foreach my $host (sort(keys(%$self))) {
39 my $agent = $self->{$host};
40 next unless $agent;
41 $agent_res .= "# Warning: agent on host $host is not reachable\n" if ($agent->agent_down());
42- $res .= sprintf(" %s(%s) %s/%s. Roles: %s\n", $host, $agent->ip, $agent->mode, $agent->state, join(', ', sort(@{$agent->roles})));
43+
44+ my @arr_role;
45+ foreach my $check_roles (@{$agent->roles}) {
46+ $check_roles =~ /(writer|reader)\((.*)\)/;
47+ my $vip = $2;
48+ my $ping_check = "Error";
49+ $ping_check = "OK" if $p->ping($vip, 1);
50+
51+ unshift @arr_role, sprintf("%s/Ping_%s", $check_roles, $ping_check);
52+ }
53+
54+ $res .= sprintf(" %s(%s) %s/%s. Roles: %s\n", $host, join(':', $agent->ip, $agent->mysql_port), $agent->mode, $agent->state, join(', ', sort(@arr_role)));
55 }
56+
57+ $p->close();
58+
59 $res = $agent_res . $res if ($detailed);
60 return $res;
61 }

Subscribers

People subscribed via source and target branches