mirror of
https://github.com/schoebel/mars
synced 2025-03-25 04:26:49 +00:00
marsadm: lowlevel IP address commands
This is absolutely necessary for coping with changes in network setups.
This commit is contained in:
parent
e7f41563f2
commit
f89e0a7d96
@ -27148,13 +27148,14 @@ Postcondition: the local
|
||||
\end_layout
|
||||
|
||||
\begin_layout Subsection
|
||||
Low-Level Helpers
|
||||
Low-Level Expert Commands
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
These commands are for experts and advanced sysadmins only.
|
||||
The interface is not stable, i.e.
|
||||
the meaning may change at any time.
|
||||
Use at your own risk!
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
@ -27443,6 +27444,386 @@ RTFS.
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
The following commands are for manual setup / repair of cluster membership.
|
||||
Only to be used by experts who know what they are doing! In general, cluster-wi
|
||||
de operations on IP addresses may need to be repeated at all hosts in the
|
||||
cluster iff the communication is not (yet) possible and/or not (yet) actually
|
||||
working (e.g.
|
||||
firewalling problems etc).
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
|
||||
\size scriptsize
|
||||
\begin_inset Tabular
|
||||
<lyxtabular version="3" rows="4" columns="3">
|
||||
<features rotate="0" islongtable="true" longtabularalignment="left">
|
||||
<column alignment="left" valignment="top" width="0pt">
|
||||
<column alignment="center" valignment="top">
|
||||
<column alignment="left" valignment="top" width="0pt">
|
||||
<row endhead="true" endfirsthead="true" endfoot="true" endlastfoot="true">
|
||||
<cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
|
||||
\begin_inset Text
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\size scriptsize
|
||||
Command / Params
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
</cell>
|
||||
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
|
||||
\begin_inset Text
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\size scriptsize
|
||||
Cmp
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
</cell>
|
||||
<cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
|
||||
\begin_inset Text
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\size scriptsize
|
||||
Description
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
</cell>
|
||||
</row>
|
||||
<row>
|
||||
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
|
||||
\begin_inset Text
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\family typewriter
|
||||
\size scriptsize
|
||||
\begin_inset Box Frameless
|
||||
position "t"
|
||||
hor_pos "c"
|
||||
has_inner_box 1
|
||||
inner_pos "t"
|
||||
use_parbox 0
|
||||
use_makebox 0
|
||||
width "30col%"
|
||||
special "none"
|
||||
height "1in"
|
||||
height_special "totalheight"
|
||||
status open
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\family typewriter
|
||||
\size scriptsize
|
||||
lowlevel-ls-host-ips
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
</cell>
|
||||
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
|
||||
\begin_inset Text
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\size scriptsize
|
||||
no
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
</cell>
|
||||
<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
|
||||
\begin_inset Text
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\size scriptsize
|
||||
\begin_inset Box Frameless
|
||||
position "t"
|
||||
hor_pos "c"
|
||||
has_inner_box 1
|
||||
inner_pos "t"
|
||||
use_parbox 0
|
||||
use_makebox 0
|
||||
width "50col%"
|
||||
special "none"
|
||||
height "1in"
|
||||
height_special "totalheight"
|
||||
status open
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\size scriptsize
|
||||
List all configured cluster members together with their currently configured
|
||||
IP addresses, as known
|
||||
\emph on
|
||||
locally
|
||||
\emph default
|
||||
.
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
</cell>
|
||||
</row>
|
||||
<row>
|
||||
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
|
||||
\begin_inset Text
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\family typewriter
|
||||
\size scriptsize
|
||||
\begin_inset Box Frameless
|
||||
position "t"
|
||||
hor_pos "c"
|
||||
has_inner_box 1
|
||||
inner_pos "t"
|
||||
use_parbox 0
|
||||
use_makebox 0
|
||||
width "30col%"
|
||||
special "none"
|
||||
height "1in"
|
||||
height_special "totalheight"
|
||||
status open
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\family typewriter
|
||||
\size scriptsize
|
||||
lowlevel-set-host-ip
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset ERT
|
||||
status open
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
|
||||
\backslash
|
||||
strut
|
||||
\backslash
|
||||
hfill
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
$hostname
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset ERT
|
||||
status open
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
|
||||
\backslash
|
||||
strut
|
||||
\backslash
|
||||
hfill
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
$ip
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
</cell>
|
||||
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
|
||||
\begin_inset Text
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\size scriptsize
|
||||
no
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
</cell>
|
||||
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
|
||||
\begin_inset Text
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\size scriptsize
|
||||
\begin_inset Box Frameless
|
||||
position "t"
|
||||
hor_pos "c"
|
||||
has_inner_box 1
|
||||
inner_pos "t"
|
||||
use_parbox 0
|
||||
use_makebox 0
|
||||
width "50col%"
|
||||
special "none"
|
||||
height "1in"
|
||||
height_special "totalheight"
|
||||
status open
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\size scriptsize
|
||||
Change the assignment of IP addresses
|
||||
\emph on
|
||||
locally
|
||||
\emph default
|
||||
.
|
||||
May be used when hosts are moved to different network locations, or when
|
||||
different network interfaces are to be used for replication (e.g.
|
||||
dedicated replication IPs).
|
||||
Notice that the names of hosts must not change at all, only their IP addresses
|
||||
may be changed.
|
||||
Check active connections with
|
||||
\family typewriter
|
||||
netstat
|
||||
\family default
|
||||
& friends.
|
||||
Updates may need some time to proceed (socket timeouts etc).
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
</cell>
|
||||
</row>
|
||||
<row>
|
||||
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
|
||||
\begin_inset Text
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\family typewriter
|
||||
\size scriptsize
|
||||
\begin_inset Box Frameless
|
||||
position "t"
|
||||
hor_pos "c"
|
||||
has_inner_box 1
|
||||
inner_pos "t"
|
||||
use_parbox 0
|
||||
use_makebox 0
|
||||
width "30col%"
|
||||
special "none"
|
||||
height "1in"
|
||||
height_special "totalheight"
|
||||
status open
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\family typewriter
|
||||
\size scriptsize
|
||||
lowlevel-delete-host
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset ERT
|
||||
status open
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
|
||||
\backslash
|
||||
strut
|
||||
\backslash
|
||||
hfill
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
$hostname
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
</cell>
|
||||
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
|
||||
\begin_inset Text
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\size scriptsize
|
||||
no
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
</cell>
|
||||
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
|
||||
\begin_inset Text
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\size scriptsize
|
||||
\begin_inset Box Frameless
|
||||
position "t"
|
||||
hor_pos "c"
|
||||
has_inner_box 1
|
||||
inner_pos "t"
|
||||
use_parbox 0
|
||||
use_makebox 0
|
||||
width "50col%"
|
||||
special "none"
|
||||
height "1in"
|
||||
height_special "totalheight"
|
||||
status open
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\size scriptsize
|
||||
Remove a host from the cluster membership
|
||||
\emph on
|
||||
locally
|
||||
\emph default
|
||||
, together with its IP address assignment.
|
||||
This does not remove any further information.
|
||||
In particular, resource memberships are untouched.
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
</cell>
|
||||
</row>
|
||||
</lyxtabular>
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Subsection
|
||||
|
@ -2015,7 +2015,7 @@ static
|
||||
int peer_thread(void *data)
|
||||
{
|
||||
struct mars_peerinfo *peer = data;
|
||||
char *real_peer;
|
||||
const char *real_peer;
|
||||
struct sockaddr_storage sockaddr = {};
|
||||
struct key_value_pair peer_pairs[] = {
|
||||
{ peer->peer },
|
||||
@ -2093,6 +2093,17 @@ int peer_thread(void *data)
|
||||
MARS_DBG("successfully opened socket to '%s'\n", real_peer);
|
||||
brick_msleep(100);
|
||||
continue;
|
||||
} else {
|
||||
const char *new_peer;
|
||||
|
||||
/* check whether IP assignment has changed */
|
||||
new_peer = mars_translate_hostname(peer->peer);
|
||||
MARS_INF("AHA %d '%s' '%s'\n",
|
||||
mars_socket_is_alive(&peer->socket),
|
||||
new_peer, real_peer);
|
||||
if (new_peer && real_peer && strcmp(new_peer, real_peer))
|
||||
mars_shutdown_socket(&peer->socket);
|
||||
brick_string_free(new_peer);
|
||||
}
|
||||
|
||||
if (peer->from_remote_trigger) {
|
||||
|
@ -1424,6 +1424,38 @@ sub _set_replaylink {
|
||||
|
||||
##################################################################
|
||||
|
||||
# lowlevel tools
|
||||
|
||||
sub lowlevel_ls_host_ips {
|
||||
my ($cmd) = @_;
|
||||
for my $path (glob("$mars/ips/ip-*")) {
|
||||
$path =~ m:/ip-(.*):;
|
||||
my $peer = $1;
|
||||
my $ip = get_link($path, 1);
|
||||
lprint "$peer $ip\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub lowlevel_set_host_ip {
|
||||
my ($cmd, $peer, $ip) = @_;
|
||||
check_id($peer);
|
||||
my $path = "$mars/ips/ip-$peer";
|
||||
my $old = get_link($path, 2) || "";
|
||||
lprint "Set host '$peer' IP from '$old' to '$ip'\n";
|
||||
set_link($ip, $path);
|
||||
}
|
||||
|
||||
sub lowlevel_delete_host {
|
||||
my ($cmd, $peer) = @_;
|
||||
check_id($peer, 1);
|
||||
my $path = "$mars/ips/ip-$peer";
|
||||
my $old = get_link($path);
|
||||
lprint "Removing host '$peer' old IP '$old'\n";
|
||||
_create_delete($path);
|
||||
}
|
||||
|
||||
##################################################################
|
||||
|
||||
# commands
|
||||
|
||||
sub ignore_cmd {
|
||||
@ -4918,6 +4950,23 @@ my %cmd_table =
|
||||
],
|
||||
"new-current-uuid" => \&senseless_cmd,
|
||||
"hidden-commands" => \&ignore_cmd,
|
||||
|
||||
# lowlevel tools
|
||||
"lowlevel-ls-host-ips"
|
||||
=> [
|
||||
"List cluster member names and IP addresses.",
|
||||
\&lowlevel_ls_host_ips,
|
||||
],
|
||||
"lowlevel-set-host-ip"
|
||||
=> [
|
||||
"Set IP for host.",
|
||||
\&lowlevel_set_host_ip,
|
||||
],
|
||||
"lowlevel-delete-host"
|
||||
=> [
|
||||
"Delete cluster member.",
|
||||
\&lowlevel_delete_host,
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
@ -5129,6 +5178,24 @@ if ($perms != 0700) {
|
||||
lwarn "Fixed to mode 0700 for security reasons.\n";
|
||||
}
|
||||
|
||||
# lowlevel tools
|
||||
if ($cmd =~ m/^lowlevel-/) {
|
||||
my $func = $cmd_table{$cmd};
|
||||
if ($func && ref($func) eq "ARRAY") {
|
||||
lwarn "EXPERTS ONLY -- risky lowlevel command '$cmd'\n";
|
||||
my @list = @$func;
|
||||
while (@list) {
|
||||
my $memb_func = shift @list;
|
||||
next unless ref($memb_func) eq "CODE";
|
||||
&{$memb_func}($cmd, @args);
|
||||
}
|
||||
finish_links();
|
||||
exit(0);
|
||||
} else {
|
||||
ldie "Internal error: command table is wrong for '$cmd'";
|
||||
}
|
||||
}
|
||||
|
||||
if ($cmd !~ m/(create|join)-cluster|create-uuid|cat|view|pretty/) {
|
||||
my $uuid = get_link("$mars/uuid", 1);
|
||||
ldie "No valid cluster UUID $mars/uuid found. You need {create,join}-cluster first (or create-uuid).\n" unless $uuid;
|
||||
|
Loading…
Reference in New Issue
Block a user