Change 'ignore_external_config_files' to a command line option

It's only used when cloning a standby and has more in common with
--fast-checkpoint
This commit is contained in:
Ian Barwick
2015-03-23 15:24:01 +09:00
parent 3e2c9ed410
commit 0875b2aafa
6 changed files with 21 additions and 20 deletions

7
FAQ.md
View File

@@ -66,10 +66,11 @@ General
just timestamp and size, to ensure that all changed files are
copied and prevent corruption.
- How can I prevent `repmgr` from copying `postgresql.conf` and
`pg_hba.conf` from the PostgreSQL configuration directory in `/etc`?
- When cloning a standby, how can I prevent `repmgr` from copying
`postgresql.conf` and `pg_hba.conf` from the PostgreSQL configuration
directory in `/etc`?
Include the option `ignore_external_config_files=1` in `repmgr.conf`
Use the command line option `--ignore-external-config-files`
- How can I prevent `repmgr` from copying local configuration files
in the data directory?

View File

@@ -221,8 +221,6 @@ parse_config(const char *config_file, t_configuration_options *options)
options->retry_promote_interval_secs = atoi(value);
else if (strcmp(name, "use_replication_slots") == 0)
options->use_replication_slots = atoi(value);
else if (strcmp(name, "ignore_external_config_files") == 0)
options->ignore_external_config_files = atoi(value);
else if (strcmp(name, "event_notification_command") == 0)
strncpy(options->event_notification_command, value, MAXLEN);
else if (strcmp(name, "event_notifications") == 0)

View File

@@ -75,13 +75,12 @@ typedef struct
int monitor_interval_secs;
int retry_promote_interval_secs;
int use_replication_slots;
int ignore_external_config_files;
char event_notification_command[MAXLEN];
EventNotificationList event_notifications;
TablespaceList tablespace_mapping;
} t_configuration_options;
#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, "", { NULL, NULL }, {NULL, NULL} }
bool parse_config(const char *config_file, t_configuration_options *options);

View File

@@ -143,6 +143,7 @@ main(int argc, char **argv)
{"check-upstream-config", no_argument, NULL, 2},
{"rsync-only", no_argument, NULL, 3},
{"fast-checkpoint", no_argument, NULL, 4},
{"ignore-external-config-files", no_argument, NULL, 5},
{NULL, 0, NULL, 0}
};
@@ -268,6 +269,9 @@ main(int argc, char **argv)
case 4:
runtime_options.fast_checkpoint = true;
break;
case 5:
runtime_options.ignore_external_config_files = true;
break;
default:
{
PQExpBufferData unknown_option;
@@ -1337,7 +1341,7 @@ do_standby_clone(void)
if(strlen(master_config_file))
{
if(options.ignore_external_config_files && config_file_outside_pgdata)
if(runtime_options.ignore_external_config_files && config_file_outside_pgdata)
{
log_notice(_("standby clone: not copying master config file '%s'\n"), master_config_file);
}
@@ -1358,7 +1362,7 @@ do_standby_clone(void)
if(strlen(master_hba_file))
{
if(options.ignore_external_config_files && hba_file_outside_pgdata)
if(runtime_options.ignore_external_config_files && hba_file_outside_pgdata)
{
log_notice(_("standby clone: not copying master config file '%s'\n"), master_hba_file);
}
@@ -1379,7 +1383,7 @@ do_standby_clone(void)
if(strlen(master_ident_file))
{
if(options.ignore_external_config_files && ident_file_outside_pgdata)
if(runtime_options.ignore_external_config_files && ident_file_outside_pgdata)
{
log_notice(_("standby clone: not copying master config file '%s'\n"), master_ident_file);
}
@@ -2231,6 +2235,8 @@ help(const char *progname)
printf(_(" -r, --min-recovery-apply-delay=VALUE enable recovery time delay, value has to be a valid time atom (e.g. 5min)\n"));
printf(_(" --rsync-only use only rsync to clone a standby\n"));
printf(_(" --fast-checkpoint force fast checkpoint when cloning a standby\n"));
printf(_(" --ignore-external-config-files don't copy configuration files located outside \n" \
" the data directory when cloning a standby\n"));
printf(_(" --initdb-no-pwprompt don't require superuser password when running initdb\n"));
printf(_(" --check-upstream-config verify upstream server configuration\n"));
printf(_("\n%s performs the following node management tasks:\n\n"), progname);
@@ -2657,6 +2663,11 @@ check_parameters_for_action(const int action)
{
error_list_append(_("--fast-checkpoint can only be used when executing STANDBY CLONE"));
}
if(runtime_options.ignore_external_config_files)
{
error_list_append(_("--ignore-external-config-files can only be used when executing STANDBY CLONE"));
}
}
return;

View File

@@ -101,14 +101,6 @@ logfacility=STDERR
#
# tablespace_mapping=/path/to/original/tablespace=/path/to/new/tablespace
# Don't copy configuration files located outside the data directory.
#
# By default repmgr will attempt to copy postgresql.conf, pg_hba.conf and pg_ident.conf
# from the master, however this may not be desirable if the files are e.g. maintained
# by configuration management software.
#
# ignore_external_config_files=0
# Failover settings (repmgrd)
# ---------------------------

View File

@@ -81,7 +81,7 @@ typedef struct
bool initdb_no_pwprompt;
bool rsync_only;
bool fast_checkpoint;
bool ignore_external_config_files;
char masterport[MAXLEN];
char localport[MAXLEN];
@@ -93,7 +93,7 @@ typedef struct
char min_recovery_apply_delay[MAXLEN];
} t_runtime_options;
#define T_RUNTIME_OPTIONS_INITIALIZER { "", "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, false, false, false, false, "", "", 0, "", "" }
#define T_RUNTIME_OPTIONS_INITIALIZER { "", "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, false, false, false, false, false, "", "", 0, "", "" }
extern char repmgr_schema[MAXLEN];