Commit Graph

129 Commits

Author SHA1 Message Date
Ian Barwick
9788b2bd29 repmgr: don't display timestamp in log output
Differentiate between repmgr and repmgrd output
2016-12-05 10:44:30 +09:00
Ian Barwick
b54f98ed8a repmgr: always log to STDERR even if log facility defined 2016-11-23 08:55:55 +09:00
Ian Barwick
26f73686e5 repmgrd: fixes to configuration reload mechanism 2016-11-02 23:23:26 +09:00
Ian Barwick
d502bbe614 repmgrd: enable logging configuration to be changed 2016-11-01 20:34:50 +09:00
Ian Barwick
2594411820 reload_config(): document items which can change 2016-11-01 20:08:57 +09:00
Ian Barwick
fce1f0cd4a Refactor reload_config()
Remove any non-repmgrd specific items.

parse_config() already sanity-checks the values so no need to
recheck. Refactor parse_config() so when called by reload_config()
it won't exit if errors are encountered.
2016-11-01 19:05:21 +09:00
Ian Barwick
ed22fe326e Document and expand pg_ctl override configuration options
These are now prefixed with "service_" to emphasize that they're
OS-level commands, not repmgr ones; also added reload and promote
commands:

    service_start_command
    service_stop_command
    service_restart_command
    service_reload_command
    service_promote_command

GitHub #169
2016-09-30 11:58:45 +09:00
Ian Barwick
41ec45a4cc 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.
2016-09-29 00:24:04 +09:00
Gianni Ciolli
9b5b9acb82 Add "cluster matrix" mode and "ssh_hostname" parameter
- The "cluster matrix" command supports CSV mode via the --csv
  switch.
- Add the optional ssh_hostname configuration parameter, which is
  required by "cluster matrix".
- A corresponding ssh_hostname column has been added to the repl_nodes
  table and to the repl_show_nodes view.
2016-09-28 23:40:35 +09:00
Ian Barwick
5baec14a1e Add repmgr.conf setting 'barman_config'
Enables provision of a non-default Barman configuration file.
2016-08-18 15:06:06 +09:00
Gianni Ciolli
2f529e20c1 Barman support, draft #1
TODO: we need to check what happens with configuration files placed in
non-standard locations.
2016-08-04 14:40:23 +02:00
Ian Barwick
02668ee045 Parse the contents of the "pg_basebackup_options" parameter in repmgr.conf
This is to ensure that when repmgr executes pg_basebackup it doesn't
add any options which would conflict with user-supplied options.

This is related to GitHub #206, where the -S/--slot option has been
added for 9.6 - it's important to check this doesn't conflict with
-X/--xlog-method.

While we're at it, rename the ErrorList handling code to ItemList
etc. so we can use it for generic non-error-related lists.
2016-07-26 16:12:43 +09:00
Jarkko Oranen
d44885b330 Allow overriding start, stop and restart commands issued by repmgr
This commit introduces three new options:
  - start_command
  - stop_command
  - restart_command

If these are set, repmgr will issue the specified command instead
of the default pg_ctl commands
2016-07-06 15:52:58 -03:00
Ian Barwick
f1ee6e19b6 Ensure configuration options correctly initialised in repmgrd.c
Per GitHub #150.

Also remove unused variable.
2016-06-27 11:26:05 +09:00
Ian Barwick
3d6c349d88 Rename "pg_restore_command" to "restore_command"
The 'pg_' prefix could cause confusion with actual binaries
(pg_ctl, pg_basebackup etc.) and there's no obvious reason
why we need it.
2016-06-17 14:43:02 +09:00
Ian Barwick
afc904f876 Fix typos and whitespace 2016-05-30 16:01:38 +09:00
Peter Eisentraut
45178c19d8 Fix compiler warning
For a char * variable, '\0' is just a strange way to write NULL, and
clang warns about it.
2016-05-21 21:04:19 -04:00
Martin
cf46834041 Add new option pg_restore_command.
This can be used so that repmgr standby clone adds the string
specified in repmgr.conf as a restore_command in recovery.conf.

We can use this option for integration with barman by setting the
parameter to an appropriate get-wal call.
2016-05-17 15:21:40 -03:00
Ian Barwick
c48c248c15 Regularly sync witness server repl_nodes table.
Although the witness server will resync the repl_nodes table following
a failover, other operations (e.g. removing or cloning a standby)
were previously not reflected in the witness server's copy of this
table.

As a short-term workaround, automatically resync the table at regular
intervals (defined by the configuration file parameter
"witness_repl_nodes_sync_interval_secs", default 30 seconds).
2016-03-29 16:49:28 +09:00
Ian Barwick
a96f478a43 Allow negative values in configuration parameters, where appropriate.
Make the code match the documentation.

As pointed out by GitHub user phyber (#142).

Also various other minor improvements to error reporting during
config file parsing.
2016-01-27 09:10:19 +09:00
Ian Barwick
7e6bac1be6 Display a couple of repetitive log messages in verbose mode only 2016-01-08 11:10:34 +09:00
Ian Barwick
b72058dba8 Update copyright notice to 2016 2016-01-05 15:57:46 +09:00
Ian Barwick
120688013e Add "standby switchover" mode
Perform a switchover by:
 - stopping current primary node
 - promoting this standby node to primary
 - forcing previous primary node to follow this node

Caveats:
 - repmgrd must not be running, otherwise it may
   attempt a failover
   (TODO: find some way of notifying repmgrd of planned
    activity like this)
 - currently only set up for two-node operation; any other
   standbys will probably become downstream cascaded standbys
   of the old primary once it's restarted
 - as we're executing repmgr remotely (on the old primary),
   we'll need the location of its configuration file; this
   can be provided explicitly with -C/--remote-config-file,
   otherwise repmgr will look in default locations on the
   remote server
 - this does not yet support "rewinding" stopped nodes
   which will be unable to catch up with the primary

TODO:
 - update help, docs
 - make connection test timeouts/intervals configurable
2015-11-30 12:20:24 +09:00
Ian Barwick
d1b4280182 Add /etc/repmgr.conf as a default configuration file location
Also refactor configuration file handling while we're at it.

Previously a configuration file would be ignored if it couldn't
be opened, however that is now treated as an error.
2015-11-19 15:16:18 +09:00
Ian Barwick
abb02cab76 Improve configuration file parsing
Related to Github #127.

- use the previously introduced repmgr_atoi() function to parse
  integers better
- collate all detected errors and output as a list, rather than
  failing on the first error.
2015-11-09 14:56:35 +09:00
Ian Barwick
8e66e4811c Rename variable 'reconnect_intvl' to 'reconnect_interval'
For consistency with the configuration file parameter name
2015-11-09 11:04:42 +09:00
Ian Barwick
ce5a541960 Use strtol() to parse config file arguments too 2015-11-09 11:02:04 +09:00
Ian Barwick
e12be52fa8 Use strtol() in place of atoi() to better verify integer parameters
Per GitHub #127
2015-11-09 11:00:53 +09:00
Ian Barwick
c8d0fb401f Add note about default log level 2015-10-27 14:39:30 +09:00
Ian Barwick
a86fa4ad4a Explicitly set default value for 'use_replication_slots' 2015-10-27 13:01:20 +09:00
Ian Barwick
7e3007f6e8 Add 'primary_response_timeout' as synonym for 'master_response_timeout'
We'll switch terminology in a future release and maintain
'master_response_timeout' for backwards compatibility
2015-10-27 10:23:54 +09:00
Ian Barwick
6da03a6157 Free connection options array after use. 2015-10-01 09:16:36 +09:00
Ian Barwick
9bb6befa25 Sanity check 'conninfo' parameter
Catch errors early, it makes everyone's life easier.
2015-10-01 09:06:27 +09:00
Ian Barwick
c3bd02b83d Standardize if-statement formatting
"if(" -> "if ("
2015-09-24 17:45:08 +09:00
Ian Barwick
30fd111cba Rework config file handling
If no configuration file provided, also check default Postgres
sysconfig dir.

It would also be useful to check the configuration directory
provided by the RPM/DEB packages, not sure if that's programmatically
feasible.
2015-09-21 15:55:29 +09:00
Simon Oxwell
faf72a2514 Ignore comments after values 2015-07-15 14:53:35 +10:00
Ian Barwick
7010b636e0 Reword error message for consistency
Github issue #87
2015-07-10 10:11:23 +09:00
Gregory Duchatelet
00deff9069 [Fix] if 'node' config parameter is set as a string, nothing complain and all nodes are set to id '0'. 2015-07-06 11:20:31 +02:00
Ian Barwick
5def293ed6 Configuration file: ignore whitespace following the '=' sign 2015-06-04 11:58:34 +09:00
Ian Barwick
ff7b4d3f02 Improve whitespace handling
Ignore blank lines which consist of whitespace. Per issue #71 in
GitHub.

This fix also improves comment handling and will treat lines with
whitespace before the '#' character as whitespace.
2015-06-04 11:44:38 +09:00
Ian Barwick
3e621f43d1 Use 100 as the default priority; 0 or less means node will never be promoted 2015-03-26 10:38:20 +09:00
Ian Barwick
0875b2aafa 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
2015-03-23 15:24:01 +09:00
Ian Barwick
0fbb83262f Rename t_configuration_options member 'pgctl_options' to 'pg_ctl_options'
Change is to make it match the actual configuration item.
2015-03-20 11:02:32 +09:00
Ian Barwick
e21448831d Standardize configuration error messages for 'failover' parameter.
Better to fail with an error than assume a default value if an
unrecognized value is detected.
2015-03-17 08:19:29 +09:00
Ian Barwick
155f5075cb Improve configuration error and warning messages 2015-03-17 08:14:27 +09:00
Ian Barwick
9cfd6680b3 Remove superfluous comment 2015-03-17 08:01:09 +09:00
Ian Barwick
61ce18ebbe Add configuration parameter 'event_notifications' 2015-03-16 17:31:26 +09:00
Ian Barwick
922dfd88e5 Add configuration option 'event_notification_command'
Command to be executed each time an event is logged.

Following formatting sequences will be interpolated:

      %e - event type
      %d - description
      %s - success (1 or 0)
      %t - timestamp
2015-03-16 13:41:13 +09:00
Ian Barwick
2929ed9be0 Make parameters 'conninfo' and 'node_name' mandatory
There's no reason why they need to be absent; if absent they're
likely to cause confusion.
2015-03-13 11:57:34 +09:00
Ian Barwick
33037dd7fb Explicitly specify problematic parameter names in error messages. 2015-03-13 11:47:28 +09:00