mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
Remove ssh_hostname support
Currently repmgr assumes the SSH hostname will be the same as the database hostname, and it's easy enough now to extract this from the node's conninfo string. We can consider re-adding this in the next release if required.
This commit is contained in:
@@ -1607,8 +1607,7 @@ which contains connection details for the local database.
|
||||
replication cluster. This command polls each registered server and
|
||||
asks it to connect to each other node.
|
||||
|
||||
This command requires a valid `repmgr.conf` file on each node,
|
||||
with the optional `ssh_hostname` parameter set.
|
||||
This command requires a valid `repmgr.conf` file on each node.
|
||||
|
||||
Example 1 (all nodes up):
|
||||
|
||||
|
||||
18
config.c
18
config.c
@@ -217,7 +217,6 @@ parse_config(t_configuration_options *options)
|
||||
memset(options->conninfo, 0, sizeof(options->conninfo));
|
||||
memset(options->barman_server, 0, sizeof(options->barman_server));
|
||||
memset(options->barman_config, 0, sizeof(options->barman_config));
|
||||
memset(options->ssh_hostname, 0, sizeof(options->ssh_hostname));
|
||||
options->failover = MANUAL_FAILOVER;
|
||||
options->priority = DEFAULT_PRIORITY;
|
||||
memset(options->node_name, 0, sizeof(options->node_name));
|
||||
@@ -317,8 +316,6 @@ parse_config(t_configuration_options *options)
|
||||
strncpy(options->barman_server, value, MAXLEN);
|
||||
else if (strcmp(name, "barman_config") == 0)
|
||||
strncpy(options->barman_config, value, MAXLEN);
|
||||
else if (strcmp(name, "ssh_hostname") == 0)
|
||||
strncpy(options->ssh_hostname, value, MAXLEN);
|
||||
else if (strcmp(name, "rsync_options") == 0)
|
||||
strncpy(options->rsync_options, value, QUERY_STR_LEN);
|
||||
else if (strcmp(name, "ssh_options") == 0)
|
||||
@@ -455,10 +452,6 @@ parse_config(t_configuration_options *options)
|
||||
PQconninfoFree(conninfo_options);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: Sanity check ssh_hostname
|
||||
*/
|
||||
|
||||
if (config_errors.head != NULL)
|
||||
{
|
||||
exit_with_errors(&config_errors);
|
||||
@@ -627,10 +620,6 @@ reload_config(t_configuration_options *orig_options)
|
||||
PQfinish(conn);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: Sanity check the new ssh_hostname
|
||||
*/
|
||||
|
||||
/*
|
||||
* No configuration problems detected - copy any changed values
|
||||
*
|
||||
@@ -659,13 +648,6 @@ reload_config(t_configuration_options *orig_options)
|
||||
config_changed = true;
|
||||
}
|
||||
|
||||
/* ssh_hostname */
|
||||
if (strcmp(orig_options->ssh_hostname, new_options.ssh_hostname) != 0)
|
||||
{
|
||||
strcpy(orig_options->ssh_hostname, new_options.ssh_hostname);
|
||||
config_changed = true;
|
||||
}
|
||||
|
||||
/* node */
|
||||
if (orig_options->node != new_options.node)
|
||||
{
|
||||
|
||||
3
config.h
3
config.h
@@ -60,7 +60,6 @@ typedef struct
|
||||
char conninfo[MAXLEN];
|
||||
char barman_server[MAXLEN];
|
||||
char barman_config[MAXLEN];
|
||||
char ssh_hostname[MAXLEN];
|
||||
int failover;
|
||||
int priority;
|
||||
char node_name[MAXLEN];
|
||||
@@ -94,7 +93,7 @@ typedef struct
|
||||
* The following will initialize the structure with a minimal set of options;
|
||||
* actual defaults are set in parse_config() before parsing the configuration file
|
||||
*/
|
||||
#define T_CONFIGURATION_OPTIONS_INITIALIZER { "", -1, NO_UPSTREAM_NODE, "", "", "", "", MANUAL_FAILOVER, -1, "", "", "", "", "", "", "", "", "", "", -1, -1, -1, "", "", "", "", "", 0, 0, 0, 0, "", { NULL, NULL }, { NULL, NULL } }
|
||||
#define T_CONFIGURATION_OPTIONS_INITIALIZER { "", -1, NO_UPSTREAM_NODE, "", "", "", MANUAL_FAILOVER, -1, "", "", "", "", "", "", "", "", "", "", -1, -1, -1, "", "", "", "", "", 0, 0, 0, 0, "", { NULL, NULL }, { NULL, NULL } }
|
||||
|
||||
typedef struct ItemListCell
|
||||
{
|
||||
|
||||
19
dbutils.c
19
dbutils.c
@@ -1227,7 +1227,7 @@ witness_copy_node_records(PGconn *masterconn, PGconn *witnessconn, char *cluster
|
||||
|
||||
/* Get current records from primary */
|
||||
sqlquery_snprintf(sqlquery,
|
||||
"SELECT id, type, upstream_node_id, name, conninfo, ssh_command, priority, slot_name, active FROM %s.repl_nodes",
|
||||
"SELECT id, type, upstream_node_id, name, conninfo, priority, slot_name, active FROM %s.repl_nodes",
|
||||
get_repmgr_schema_quoted(masterconn));
|
||||
|
||||
log_verbose(LOG_DEBUG, "witness_copy_node_records():\n%s\n", sqlquery);
|
||||
@@ -1263,7 +1263,6 @@ witness_copy_node_records(PGconn *masterconn, PGconn *witnessconn, char *cluster
|
||||
cluster_name,
|
||||
PQgetvalue(res, i, 3),
|
||||
PQgetvalue(res, i, 4),
|
||||
PQgetvalue(res, i, 5),
|
||||
atoi(PQgetvalue(res, i, 6)),
|
||||
strlen(PQgetvalue(res, i, 7))
|
||||
? PQgetvalue(res, i, 7)
|
||||
@@ -1301,7 +1300,7 @@ witness_copy_node_records(PGconn *masterconn, PGconn *witnessconn, char *cluster
|
||||
* XXX we should pass the record parameters as a struct.
|
||||
*/
|
||||
bool
|
||||
create_node_record(PGconn *conn, char *action, int node, char *type, int upstream_node, char *cluster_name, char *node_name, char *conninfo, char *ssh_hostname, int priority, char *slot_name, bool active)
|
||||
create_node_record(PGconn *conn, char *action, int node, char *type, int upstream_node, char *cluster_name, char *node_name, char *conninfo, int priority, char *slot_name, bool active)
|
||||
{
|
||||
char sqlquery[QUERY_STR_LEN];
|
||||
char upstream_node_id[MAXLEN];
|
||||
@@ -1342,9 +1341,9 @@ create_node_record(PGconn *conn, char *action, int node, char *type, int upstrea
|
||||
sqlquery_snprintf(sqlquery,
|
||||
"INSERT INTO %s.repl_nodes "
|
||||
" (id, type, upstream_node_id, cluster, "
|
||||
" name, conninfo, ssh_hostname, slot_name, "
|
||||
" name, conninfo, slot_name, "
|
||||
" priority, active) "
|
||||
"VALUES (%i, '%s', %s, '%s', '%s', '%s', '%s', %s, %i, %s) ",
|
||||
"VALUES (%i, '%s', %s, '%s', '%s', '%s', %s, %i, %s) ",
|
||||
get_repmgr_schema_quoted(conn),
|
||||
node,
|
||||
type,
|
||||
@@ -1352,7 +1351,6 @@ create_node_record(PGconn *conn, char *action, int node, char *type, int upstrea
|
||||
cluster_name,
|
||||
node_name,
|
||||
conninfo,
|
||||
ssh_hostname,
|
||||
slot_name_buf,
|
||||
priority,
|
||||
active == true ? "TRUE" : "FALSE");
|
||||
@@ -1719,7 +1717,7 @@ get_node_record(PGconn *conn, char *cluster, int node_id, t_node_info *node_info
|
||||
|
||||
sqlquery_snprintf(
|
||||
sqlquery,
|
||||
"SELECT id, type, upstream_node_id, name, conninfo, ssh_hostname, "
|
||||
"SELECT id, type, upstream_node_id, name, conninfo, "
|
||||
" slot_name, priority, active"
|
||||
" FROM %s.repl_nodes "
|
||||
" WHERE cluster = '%s' "
|
||||
@@ -1793,10 +1791,9 @@ _get_node_record(PGconn *conn, char *cluster, char *sqlquery, t_node_info *node_
|
||||
node_info->upstream_node_id = atoi(PQgetvalue(res, 0, 2));
|
||||
strncpy(node_info->name, PQgetvalue(res, 0, 3), MAXLEN);
|
||||
strncpy(node_info->conninfo_str, PQgetvalue(res, 0, 4), MAXLEN);
|
||||
strncpy(node_info->ssh_hostname_str, PQgetvalue(res, 0, 5), MAXLEN);
|
||||
strncpy(node_info->slot_name, PQgetvalue(res, 0, 6), MAXLEN);
|
||||
node_info->priority = atoi(PQgetvalue(res, 0, 7));
|
||||
node_info->active = (strcmp(PQgetvalue(res, 0, 8), "t") == 0)
|
||||
strncpy(node_info->slot_name, PQgetvalue(res, 0, 5), MAXLEN);
|
||||
node_info->priority = atoi(PQgetvalue(res, 0, 6));
|
||||
node_info->active = (strcmp(PQgetvalue(res, 0, 7), "t") == 0)
|
||||
? true
|
||||
: false;
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ typedef struct s_node_info
|
||||
t_server_type type;
|
||||
char name[MAXLEN];
|
||||
char conninfo_str[MAXLEN];
|
||||
char ssh_hostname_str[MAXLEN];
|
||||
char slot_name[MAXLEN];
|
||||
int priority;
|
||||
bool active;
|
||||
@@ -62,7 +61,6 @@ typedef struct s_node_info
|
||||
"", \
|
||||
"", \
|
||||
"", \
|
||||
"", \
|
||||
DEFAULT_PRIORITY, \
|
||||
true, \
|
||||
false, \
|
||||
@@ -128,7 +126,7 @@ bool start_backup(PGconn *conn, char *first_wal_segment, bool fast_checkpoint);
|
||||
bool stop_backup(PGconn *conn, char *last_wal_segment);
|
||||
bool set_config_bool(PGconn *conn, const char *config_param, bool state);
|
||||
bool witness_copy_node_records(PGconn *masterconn, PGconn *witnessconn, char *cluster_name);
|
||||
bool create_node_record(PGconn *conn, char *action, int node, char *type, int upstream_node, char *cluster_name, char *node_name, char *conninfo, char *ssh_hostname, int priority, char *slot_name, bool active);
|
||||
bool create_node_record(PGconn *conn, char *action, int node, char *type, int upstream_node, char *cluster_name, char *node_name, char *conninfo, int priority, char *slot_name, bool active);
|
||||
bool delete_node_record(PGconn *conn, int node, char *action);
|
||||
int get_node_record(PGconn *conn, char *cluster, int node_id, t_node_info *node_info);
|
||||
int get_node_record_by_name(PGconn *conn, char *cluster, const char *node_name, t_node_info *node_info);
|
||||
|
||||
19
repmgr.c
19
repmgr.c
@@ -1105,7 +1105,7 @@ do_cluster_matrix(void)
|
||||
conn = establish_db_connection(options.conninfo, true);
|
||||
|
||||
sqlquery_snprintf(sqlquery,
|
||||
"SELECT conninfo, ssh_hostname, type, name, upstream_node_name, id"
|
||||
"SELECT conninfo, type, name, upstream_node_name, id"
|
||||
" FROM %s.repl_show_nodes",
|
||||
get_repmgr_schema_quoted(conn));
|
||||
|
||||
@@ -1144,7 +1144,7 @@ do_cluster_matrix(void)
|
||||
{
|
||||
int name_length_cur;
|
||||
|
||||
name_length_cur = strlen(PQgetvalue(res, i, 3));
|
||||
name_length_cur = strlen(PQgetvalue(res, i, 2));
|
||||
if (name_length_cur > name_length)
|
||||
name_length = name_length_cur;
|
||||
}
|
||||
@@ -1152,6 +1152,11 @@ do_cluster_matrix(void)
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
int connection_status;
|
||||
t_conninfo_param_list remote_conninfo;
|
||||
char *host;
|
||||
|
||||
initialize_conninfo_params(&remote_conninfo, false);
|
||||
host = param_get(&remote_conninfo, "host");
|
||||
|
||||
conn = establish_db_connection(PQgetvalue(res, i, 0), false);
|
||||
|
||||
@@ -1173,7 +1178,7 @@ do_cluster_matrix(void)
|
||||
initPQExpBuffer(&command_output);
|
||||
|
||||
(void)remote_command(
|
||||
PQgetvalue(res, i, 1),
|
||||
host,
|
||||
"postgres",
|
||||
command,
|
||||
&command_output);
|
||||
@@ -1226,7 +1231,7 @@ do_cluster_matrix(void)
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
printf("%*s | %2d ", name_length,
|
||||
PQgetvalue(res, i, 3), i + 1);
|
||||
PQgetvalue(res, i, 2), i + 1);
|
||||
for (j = 0; j < n; j++)
|
||||
{
|
||||
switch (matrix[i * n + j])
|
||||
@@ -1475,7 +1480,6 @@ do_master_register(void)
|
||||
options.cluster_name,
|
||||
options.node_name,
|
||||
options.conninfo,
|
||||
options.ssh_hostname,
|
||||
options.priority,
|
||||
repmgr_slot_name_ptr,
|
||||
true);
|
||||
@@ -1601,7 +1605,6 @@ do_standby_register(void)
|
||||
options.cluster_name,
|
||||
options.node_name,
|
||||
options.conninfo,
|
||||
options.ssh_hostname,
|
||||
options.priority,
|
||||
repmgr_slot_name_ptr,
|
||||
true);
|
||||
@@ -5533,7 +5536,6 @@ do_witness_register(PGconn *masterconn)
|
||||
options.cluster_name,
|
||||
options.node_name,
|
||||
options.conninfo,
|
||||
options.ssh_hostname,
|
||||
options.priority,
|
||||
NULL,
|
||||
true);
|
||||
@@ -6531,7 +6533,6 @@ create_schema(PGconn *conn)
|
||||
" cluster TEXT NOT NULL, "
|
||||
" name TEXT NOT NULL, "
|
||||
" conninfo TEXT NOT NULL, "
|
||||
" ssh_hostname TEXT NULL, "
|
||||
" slot_name TEXT NULL, "
|
||||
" priority INTEGER NOT NULL, "
|
||||
" active BOOLEAN NOT NULL DEFAULT TRUE )",
|
||||
@@ -6667,7 +6668,7 @@ create_schema(PGconn *conn)
|
||||
/* CREATE VIEW repl_show_nodes */
|
||||
sqlquery_snprintf(sqlquery,
|
||||
"CREATE VIEW %s.repl_show_nodes AS "
|
||||
"SELECT rn.id, rn.conninfo, rn.ssh_hostname, "
|
||||
"SELECT rn.id, rn.conninfo, "
|
||||
" rn.type, rn.name, rn.cluster,"
|
||||
" rn.priority, rn.active, sq.name AS upstream_node_name"
|
||||
" FROM %s.repl_nodes as rn"
|
||||
|
||||
@@ -42,12 +42,6 @@
|
||||
# Optional configuration items
|
||||
# ============================
|
||||
|
||||
# SSH connection information
|
||||
# We recommend using the "postgres" user, so it is enough to indicate the hostname.
|
||||
# If extra parameters such as port, etc. are needed, they can be
|
||||
# specified in the .ssh/config file.
|
||||
#ssh_hostname='192.168.204.104'
|
||||
|
||||
# Replication settings
|
||||
# ---------------------
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ CREATE TABLE repl_nodes (
|
||||
cluster text not null, -- Name to identify the cluster
|
||||
name text not null,
|
||||
conninfo text not null,
|
||||
ssh_command text,
|
||||
priority integer not null,
|
||||
witness boolean not null default false
|
||||
);
|
||||
@@ -65,7 +64,7 @@ CREATE INDEX idx_repl_status_sort ON repl_monitor(last_monitor_time, standby_nod
|
||||
* This view shows the list of nodes with the information of which one is the upstream
|
||||
* in each case (when appliable)
|
||||
*/
|
||||
CREATE VIEW repl_show_nodes AS
|
||||
SELECT rn.id, rn.conninfo, rn.ssh_command, rn.type, rn.name, rn.cluster,
|
||||
CREATE VIEW repl_show_nodes AS
|
||||
SELECT rn.id, rn.conninfo, rn.type, rn.name, rn.cluster,
|
||||
rn.priority, rn.active, sq.name AS upstream_node_name
|
||||
FROM repl_nodes as rn LEFT JOIN repl_nodes AS sq ON sq.id=rn.upstream_node_id;
|
||||
|
||||
Reference in New Issue
Block a user