Commit Graph

368 Commits

Author SHA1 Message Date
Ian Barwick
53ed8e948c Clean up help output
master/primary register only has one option
2015-11-30 16:13:22 +09:00
Ian Barwick
43626892d0 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-30 16:13:16 +09:00
Ian Barwick
6054da2c25 Use strtol() in place of atoi() to better verify integer parameters
Per GitHub #127
2015-11-30 16:12:30 +09:00
Ian Barwick
049ea4e24f cluster cleanup: standardize error message and return code 2015-11-30 16:12:19 +09:00
Ian Barwick
5f8185ef3a Fix log wording 2015-11-30 16:12:13 +09:00
Ian Barwick
66a6c15773 Add informtative logging output for 'repmgr cluster cleanup'
Per Github issue #126.
2015-11-30 16:12:06 +09:00
Ian Barwick
3f98e1b91b Replace "slave" with "standby" for consistency
"standby" is used everywhere except in these two error messages.
2015-11-30 16:11:21 +09:00
Ian Barwick
d512bac31d Clean up --help output
There are a confusing number of command line options, some
of which are only valid for particular operations, e.g. "standby clone".
2015-11-30 16:02:59 +09:00
Ian Barwick
ca9c2e1143 Fix -D/--data-dir's long option
This was erroneously rendered as --dest-dir. This bugfeature seems
to have been around for a long time; however as the only way anyone
could know of the existence of --dest-dir is by reading the source
code, we can safely remove it.

Pointed out by Github user Jehan-Guillaume (ioguix) de Rorthais.
2015-10-02 07:50:19 +09:00
Ian Barwick
870b0a53b6 Allow 'primary' as synonym for 'master'.
"Primary" is the term preferred in the PostgreSQL documentation, so
we should at least support it.

Practically this means it's possible to write "rempgr primary register"
in place of "repmgr master register".

The next feature-release should replace "master" with "primary" in
the documentation and log messages.

Per gripe in Github #112.
2015-10-01 16:01:12 +09:00
Ian Barwick
1c9121c2d8 Witness server - extract explicit port setting from conninfo setting
This makes the '-l/--local-port' option redundant, which is now
marked as deprecated.
2015-10-01 09:42:44 +09:00
Ian Barwick
a8e5c68d03 Better document '-l/--local-port' option.
Per Github #59.
2015-10-01 08:40:27 +09:00
Ian Barwick
b83e18c503 Fix '-l, --local-port' help output.
Is for witness server only.

Use constants for default port definitions while we're at it.

Github #123.
2015-10-01 08:24:14 +09:00
Ian Barwick
d4b845d213 'repmgr witness create --force': overwrite any existing node record
Consistent with 'repmgr standby register --force'.

Fixes Github #122.
2015-10-01 08:02:06 +09:00
Ian Barwick
75aad9a85e repmgr witness create --force: overwrite existing data directory
Per Github #82 (dimitri).
2015-09-30 17:05:54 +09:00
Ian Barwick
f8119d20ea Handle tablespace mapping in 9.5 and later in --rsync-only mode
9.5 introduces the tablespace_map file, which is created on the upstream
node while a backup is running. We need to overwrite this with the
provided values.

Note that we only write explicitly-provided values to the tablespace_map
file, however the existing symlinks for non-specified tablespaces
will have been copied anyway.

Fixes Github #119.
2015-09-30 11:48:09 +09:00
Ian Barwick
0caddf2d2c Fix check when tablespace mapping option used with 9.3
As pointed out by EvilElk (Github issue #91).
2015-09-29 14:30:37 +09:00
Ian Barwick
a4abbc6f0c Minor formatting fixes 2015-09-29 14:18:48 +09:00
Ian Barwick
d7e489ea0a Update repmgr --help output
(per Github report #113 from renard)
2015-09-25 11:26:12 +09:00
Ian Barwick
c3bd02b83d Standardize if-statement formatting
"if(" -> "if ("
2015-09-24 17:45:08 +09:00
Ian Barwick
8e7d110a22 Check for existing master record before deleting it
Otherwise repmgr implies it's deleting a record which isn't actually
there.
2015-09-24 17:39:39 +09:00
Ian Barwick
43874d5576 Close database connection as soon as it is no longer required 2015-09-24 16:55:59 +09:00
Ian Barwick
87ff9d09ba Ensure --force option works with "master register"
This was failing previously if repmgr was able to connect to the
master database
2015-09-24 16:55:59 +09:00
Ian Barwick
c429b0b186 Don't fail with error when registering master if schema already defined
Registering a master creates the schema, but it may be desirable
to forcibly reregister a master without deleting the schema, so
uncouple the dependency.

Also ensure schema creation is atomic by wrapping it in a transaction.

Per GitHub issue #49.
2015-09-24 16:55:43 +09:00
Martín Marqués
03b88178c1 Minor change in an error log message 2015-09-23 10:44:07 -03:00
Martín Marqués
5f33f4286f Merge pull request #115 from xocolatl/unregister
Add a STANDBY UNREGISTER command.
2015-09-23 10:17:22 -03:00
Vik Fearing
932f84910b Add a STANDBY UNREGISTER command.
In some cases it is desirable to remove repmgr's handling of a standby, perhaps
because that standby is to be removed altogether.  With no UNREGISTER command,
one had to manually delete the corresponding row from repl_nodes.
2015-09-23 12:37:42 +02:00
Ian Barwick
640abed18f Don't close connection to master until upstream node updated 2015-09-23 13:11:51 +09:00
Tomas Vondra
ef6b24551a call update_node_record_set_upstream() for STANDBY FOLLOW
repmgrd correctly updates ID of the upstream node after automatic
failover, but repmgr was not doing that for manual failvers.

This moves the existing function to dbutils and modifies it so that
it does not rely on global variables with configuration (available
just in repmgrd).

This should fix issue #67 (hopefully, haven't done much testing).
2015-09-23 12:32:47 +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
Ian Barwick
65e63b062e Generally tidy up help output 2015-09-21 11:49:06 +09:00
Ian Barwick
053f672caa Treat -?/--help and -V/--version as normal options
Currently repmgr/repmgrd will only accept these as valid when
provided as the first command line option, however it's possible
a user will want to get the output of those options by adding
them to the end of a previously inputted command.

Note that after the first of these options is encountered, the
program will terminate and not process any other options. This
is consistent with psql's behaviour

Per GitHub issue #107 from Sébastien Gross.
2015-09-21 09:53:51 +09:00
Ian Barwick
eb0af7ca23 Always pass -D/--pgdata option to pg_basebackup
repmgr does not require explicit provision of the target data
directory when cloning a standby (it defaults to the same directory
as on the master). However this is a required option for pg_basebackup
which was only being provided if repmgr's -D/--data-dir option was
set, so ensure we always provide whatever repmgr is using.

Per report from Martín.
2015-08-25 14:36:51 +09:00
Gianni Ciolli
f1584469bf Bug #97 fix (standby clone --force does not empty pg_xlog). 2015-08-11 14:59:23 +02:00
Martín Marqués
45e29c5b28 Typo in a comment 2015-06-04 18:12:35 +09:00
Ian Barwick
9735bb63a1 Add short option '-c' for '--fast-checkpoint'
This is similar to pg_basebackup's '-c/--checkpoint=fast|spread'
option.
2015-04-16 08:15:44 +09:00
Ian Barwick
a01fefa7d0 After standby promotion, ensure metadata is updated by repmgr
Previously this was handled by repmgrd but if a standby is promoted
directly this will leave the metadata in an incorrect state.
2015-04-14 13:39:48 +09:00
Ian Barwick
34eaf94b2b Fix variable name spelling 2015-04-14 13:15:44 +09:00
Ian Barwick
68e3a9d7ab Improve promotion failure handling
Exit with error; don't attempt to write event log as master
connection will not be valid at this point.
2015-04-14 13:09:02 +09:00
Ian Barwick
9e5e843a4f Prevent a test SSH connection being made when not needed
When using the default pg_basebackup method to clone a standby
together with the `--ignore-external-config-files` option, there's
no need to test for a working SSH connection - which may not
be desirable in many use-cases anyway.

Per issue #64 in GitHub.
2015-04-10 15:05:19 +09:00
Martín Marqués
734ae1825e Don't run ssh connection test when --ignore-external-config-files was used 2015-04-10 11:02:19 +09:00
Ian Barwick
4dfeffe087 Add constant NODE_NOT_FOUND
Which is what the magic number means in those contexts.
2015-03-31 14:35:16 +09:00
Ian Barwick
fec65bde3d Fix typo in -?/--help output 2015-03-27 18:09:41 +09:00
Ian Barwick
98df2a5891 Fix recovery_min_apply_delay handling
- rename --min-recovery-apply-delay to --recovery-min-apply-delay
- ensure server version is 9.4 or later before writing
  recovery_min_apply_delay to recovery.conf.

This fixes changes introduced in 653e11c2a7
(the parameter was subsequently renamed).

Also reallocate the '-r' parameter to --rsync-only, which is probably
more useful.
2015-03-23 17:50:51 +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
3e2c9ed410 Support --fast-checkpoint 2015-03-23 12:18:17 +09:00
Ian Barwick
5b4f832f3b Only allow --rsync-only option in combination with STANDBY CLONE 2015-03-20 15:16:55 +09:00
Ian Barwick
66844d057a Rename 'need_a_node' to 'config_file_required' 2015-03-20 14:56:02 +09:00
Ian Barwick
f096cca84f Fix parameter checking for STANDBY CLONE
Previous check for the master host was ineffective. We'd be better off explicitly
requiring at least hostname, database and usernames for the master rather
than relying on whatever defaults were in place when STANDBY CLONE is
run, especially as dbname and username are used in recovery.conf.
2015-03-20 14:47:04 +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