From 0875b2aafa5ce47baed9f2ce2d0e90b3937e1ee9 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Mon, 23 Mar 2015 15:24:01 +0900 Subject: [PATCH] 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 --- FAQ.md | 7 ++++--- config.c | 2 -- config.h | 3 +-- repmgr.c | 17 ++++++++++++++--- repmgr.conf.sample | 8 -------- repmgr.h | 4 ++-- 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/FAQ.md b/FAQ.md index ee744363..6b936b4e 100644 --- a/FAQ.md +++ b/FAQ.md @@ -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? diff --git a/config.c b/config.c index c25c0c34..19cf7a35 100644 --- a/config.c +++ b/config.c @@ -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) diff --git a/config.h b/config.h index 85d2934f..2d3b756f 100644 --- a/config.h +++ b/config.h @@ -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); diff --git a/repmgr.c b/repmgr.c index ece3beb2..43d3f8cd 100644 --- a/repmgr.c +++ b/repmgr.c @@ -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; diff --git a/repmgr.conf.sample b/repmgr.conf.sample index 12a163ed..a0dacdfe 100644 --- a/repmgr.conf.sample +++ b/repmgr.conf.sample @@ -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) # --------------------------- diff --git a/repmgr.h b/repmgr.h index 1514c277..ce3ea1f5 100644 --- a/repmgr.h +++ b/repmgr.h @@ -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];