* Updated DRBD->gather_data() to record TCP/IP data between connections of two hosts.

* Updated anvil-manage-dr to use the TCP ports already configured for a resource when re-configuring a DR resource that has been previously configured.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 3 years ago
parent 13a4824db3
commit a034583213
  1. 11
      Anvil/Tools/DRBD.pm
  2. 2
      Anvil/Tools/Database.pm
  3. 41
      tools/anvil-manage-dr

@ -761,6 +761,17 @@ sub gather_data
host2_ip_address => $host2_ip_address, host2_ip_address => $host2_ip_address,
host2_tcp_port => $host2_tcp_port, host2_tcp_port => $host2_tcp_port,
}}); }});
$anvil->data->{new}{resource}{$resource}{host1_to_host2}{$host1_name}{$host2_name}{host1_ip_address} = $host1_ip_address;
$anvil->data->{new}{resource}{$resource}{host1_to_host2}{$host1_name}{$host2_name}{host1_tcp_port} = $host1_tcp_port;
$anvil->data->{new}{resource}{$resource}{host1_to_host2}{$host1_name}{$host2_name}{host2_ip_address} = $host2_ip_address;
$anvil->data->{new}{resource}{$resource}{host1_to_host2}{$host1_name}{$host2_name}{host2_tcp_port} = $host2_tcp_port;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"s1:new::resource::${resource}::host1_to_host2::${host1_name}::${host2_name}::host1_ip_address" => $anvil->data->{new}{resource}{$resource}{host1_to_host2}{$host1_name}{$host2_name}{host1_ip_address},
"s2:new::resource::${resource}::host1_to_host2::${host1_name}::${host2_name}::host1_tcp_port" => $anvil->data->{new}{resource}{$resource}{host1_to_host2}{$host1_name}{$host2_name}{host1_tcp_port},
"s3:new::resource::${resource}::host1_to_host2::${host1_name}::${host2_name}::host2_ip_address" => $anvil->data->{new}{resource}{$resource}{host1_to_host2}{$host1_name}{$host2_name}{host2_ip_address},
"s4:new::resource::${resource}::host1_to_host2::${host1_name}::${host2_name}::host2_tcp_port" => $anvil->data->{new}{resource}{$resource}{host1_to_host2}{$host1_name}{$host2_name}{host2_tcp_port},
}});
} }
# $peer = $this_host_name; # $peer = $this_host_name;

@ -1657,7 +1657,7 @@ sub connect
} }
# Before we try to connect, see if this is a local database and, if so, make sure it's setup. # Before we try to connect, see if this is a local database and, if so, make sure it's setup.
my $is_local = $anvil->Network->is_local({debug => 2, host => $host}); my $is_local = $anvil->Network->is_local({debug => $debug, host => $host});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { is_local => $is_local }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { is_local => $is_local }});
if ($is_local) if ($is_local)
{ {

@ -723,12 +723,49 @@ sub process_protect
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
# Get net next pair of TCP ports. # Have we already configured the DR? If so, what ports are already allocated.
my $node1_to_dr_port = "";
my $node2_to_dr_port = "";
foreach my $host1_name (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}{$server_name}{host1_to_host2}})
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { host1_name => $host1_name }});
foreach my $host2_name (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}{$server_name}{host1_to_host2}{$host1_name}})
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { host2_name => $host2_name }});
next if (($host1_name ne $dr1_short_host_name) && ($host2_name ne $dr1_short_host_name));
if (($host1_name eq $node1_short_host_name) or ($host2_name eq $node1_short_host_name))
{
$node1_to_dr_port = $anvil->data->{new}{resource}{$server_name}{host1_to_host2}{$host1_name}{$host2_name}{host1_tcp_port};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { node1_to_dr_port => $node1_to_dr_port }});
}
else
{
$node2_to_dr_port = $anvil->data->{new}{resource}{$server_name}{host1_to_host2}{$host1_name}{$host2_name}{host1_tcp_port};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { node2_to_dr_port => $node2_to_dr_port }});
}
}
}
# Get net next pair of TCP ports, if needed.
my (undef, $tcp_ports) = $anvil->DRBD->get_next_resource({ my (undef, $tcp_ports) = $anvil->DRBD->get_next_resource({
debug => 2, debug => 2,
dr_tcp_ports => 1, dr_tcp_ports => 1,
}); });
my ($node1_to_dr_port, $node2_to_dr_port) = split/,/, $tcp_ports; my ($first_port, $second_port) = split/,/, $tcp_ports;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"s01:first_port" => $first_port,
"s02:second_port" => $second_port,
}});
if ($node1_to_dr_port eq "")
{
$node1_to_dr_port = $first_port;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { node1_to_dr_port => $node1_to_dr_port }});
}
if ($node2_to_dr_port eq "")
{
$node2_to_dr_port = $second_port;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { node2_to_dr_port => $node2_to_dr_port }});
}
# Show what we're doing # Show what we're doing
my $variables = { my $variables = {

Loading…
Cancel
Save