Merge remote-tracking branch 'origin/master' into heroku

The Great Whitespace Reconciliation

Conflicts:
	check_dir.c
	config.c
	dbutils.c
	repmgr.c
	repmgr.h
	repmgrd.c

Signed-off-by: Dan Farina <drfarina@acm.org>
This commit is contained in:
Dan Farina
2011-02-04 18:27:28 -08:00
13 changed files with 340 additions and 201 deletions

4
.gitignore vendored
View File

@@ -0,0 +1,4 @@
*~
*.o
repmgr
repmgrd

7
CREDITS Normal file
View File

@@ -0,0 +1,7 @@
Code and documentation contributors to repmgr include:
Jaime Casanova <jaime@2ndQuadrant.com>
Simon Riggs <simon@2ndQuadrant.com>
Greg Smith <greg@2ndQuadrant.com>
Robert J. Noles <rj@2ndQuadrant.com>
Gabriele Bartolini <gabriele@2ndQuadrant.com>

3
HISTORY Normal file
View File

@@ -0,0 +1,3 @@
1.0.0 2010-12-05 First public release
1.0.1 2010-12-XX Fix missing "--force" option in help

View File

@@ -212,6 +212,8 @@ If you give a password to the user, you need to create a ``.pgpass`` file for
them as well to allow automatic login. In this case you might use the them as well to allow automatic login. In this case you might use the
``md5`` authentication method instead of ``trust`` for the repmgr user. ``md5`` authentication method instead of ``trust`` for the repmgr user.
Don't forget to restart the database server after making all these changes.
Configuration File Configuration File
================== ==================
@@ -627,3 +629,16 @@ and on “prime."
The servers are now again acting as primary on “prime" and standby on “standby". The servers are now again acting as primary on “prime" and standby on “standby".
License and Contributions
=========================
repmgr is licensed under the GPL v3. All of its code and documentation is
Copyright 2010, 2ndQuadrant Limited. See the files COPYRIGHT and LICENSE for
details.
Contributions to repmgr are welcome, and listed in the file CREDITS.
2ndQuadrant Limited requires that any contributions provide a copyright
assignment and a disclaimer of any work-for-hire ownership claims from the
employer of the developer. This lets us make sure that all of the repmgr
distribution remains free code. Please contact info@2ndQuadrant.com for a
copy of the relevant Copyright Assignment Form.

View File

@@ -1,10 +1,21 @@
/* /*
* check_dir.c * check_dir.c - Directories management functions
* *
* Copyright (c) 2ndQuadrant, 2010 * Copyright (C) 2ndQuadrant, 2010
* Copyright (c) Heroku, 2010 *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* Directories management functions
*/ */
#include <sys/stat.h> #include <sys/stat.h>

View File

@@ -2,6 +2,19 @@
* check_dir.h * check_dir.h
* Copyright (c) 2ndQuadrant, 2010 * Copyright (c) 2ndQuadrant, 2010
* *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/ */
int check_dir(char *dir); int check_dir(char *dir);

View File

@@ -1,10 +1,20 @@
/* /*
* config.c * config.c - Functions to parse the config file
* Copyright (C) 2ndQuadrant, 2010
* *
* Copyright (c) 2ndQuadrant, 2010 * This program is free software: you can redistribute it and/or modify
* Copyright (c) Heroku, 2010 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* Functions to parse the config file
*/ */
#include "repmgr.h" #include "repmgr.h"

View File

@@ -2,6 +2,19 @@
* config.h * config.h
* Copyright (c) 2ndQuadrant, 2010 * Copyright (c) 2ndQuadrant, 2010
* *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/ */
void parse_config(const char *config_file, char *cluster_name, int *node, void parse_config(const char *config_file, char *cluster_name, int *node,

View File

@@ -1,10 +1,19 @@
/* /*
* dbutils.c * dbutils.c - Database connection/management functions
* Copyright (C) 2ndQuadrant, 2010
* *
* Copyright (c) 2ndQuadrant, 2010 * This program is free software: you can redistribute it and/or modify
* Copyright (c) Heroku, 2010 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* *
* Database connection/management functions * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */

View File

@@ -2,6 +2,19 @@
* dbutils.h * dbutils.h
* Copyright (c) 2ndQuadrant, 2010 * Copyright (c) 2ndQuadrant, 2010
* *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/ */
PGconn *establishDBConnection(const char *conninfo, const bool exit_on_error); PGconn *establishDBConnection(const char *conninfo, const bool exit_on_error);

View File

@@ -1,16 +1,27 @@
/* /*
* repmgr.c * repmgr.c - Command interpreter for the repmgr
* *
* Copyright (c) 2ndQuadrant, 2010
* Copyright (c) Heroku, 2010
* *
* Command interpreter for the repmgr
* This module is a command-line utility to easily setup a cluster of * This module is a command-line utility to easily setup a cluster of
* hot standby servers for an HA environment * hot standby servers for an HA environment
* *
* Commands implemented are. * Commands implemented are.
* MASTER REGISTER, STANDBY REGISTER, STANDBY CLONE, STANDBY FOLLOW, * MASTER REGISTER, STANDBY REGISTER, STANDBY CLONE, STANDBY FOLLOW,
* STANDBY PROMOTE * STANDBY PROMOTE
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/ */
#include "repmgr.h" #include "repmgr.h"
@@ -71,7 +82,8 @@ char *server_cmd = NULL;
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
static struct option long_options[] = { static struct option long_options[] =
{
{"dbname", required_argument, NULL, 'd'}, {"dbname", required_argument, NULL, 'd'},
{"host", required_argument, NULL, 'h'}, {"host", required_argument, NULL, 'h'},
{"port", required_argument, NULL, 'p'}, {"port", required_argument, NULL, 'p'},
@@ -1472,7 +1484,8 @@ check_parameters_for_action(const int action)
progname); progname);
ok = false; ok = false;
} }
if (dest_dir != NULL) { if (dest_dir != NULL)
{
fprintf(stderr, "\nYou don't need a destination directory for MASTER REGISTER command"); fprintf(stderr, "\nYou don't need a destination directory for MASTER REGISTER command");
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
progname); progname);
@@ -1493,7 +1506,8 @@ check_parameters_for_action(const int action)
progname); progname);
ok = false; ok = false;
} }
if (dest_dir != NULL) { if (dest_dir != NULL)
{
fprintf(stderr, "\nYou don't need a destination directory for STANDBY REGISTER command"); fprintf(stderr, "\nYou don't need a destination directory for STANDBY REGISTER command");
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
progname); progname);
@@ -1515,7 +1529,8 @@ check_parameters_for_action(const int action)
progname); progname);
ok = false; ok = false;
} }
if (dest_dir != NULL) { if (dest_dir != NULL)
{
fprintf(stderr, "\nYou don't need a destination directory for STANDBY PROMOTE command"); fprintf(stderr, "\nYou don't need a destination directory for STANDBY PROMOTE command");
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
progname); progname);
@@ -1537,7 +1552,8 @@ check_parameters_for_action(const int action)
progname); progname);
ok = false; ok = false;
} }
if (dest_dir != NULL) { if (dest_dir != NULL)
{
fprintf(stderr, "\nYou don't need a destination directory for STANDBY FOLLOW command"); fprintf(stderr, "\nYou don't need a destination directory for STANDBY FOLLOW command");
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
progname); progname);
@@ -1550,7 +1566,8 @@ check_parameters_for_action(const int action)
* repmgr.conf is useless because we don't have a server running * repmgr.conf is useless because we don't have a server running
* in the standby * in the standby
*/ */
if (config_file != NULL) { if (config_file != NULL)
{
fprintf(stderr, "\nYou need to use connection parameters to the master when issuing a STANDBY CLONE command."); fprintf(stderr, "\nYou need to use connection parameters to the master when issuing a STANDBY CLONE command.");
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
progname); progname);

View File

@@ -2,7 +2,19 @@
* repmgr.h * repmgr.h
* *
* Copyright (c) 2ndQuadrant, 2010 * Copyright (c) 2ndQuadrant, 2010
* Copyright (c) Heroku, 2010 *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */

View File

@@ -1,12 +1,24 @@
/* /*
* repmgrd.c * repmgrd.c - Replication manager daemon
* *
* Copyright (c) 2ndQuadrant, 2010 * Copyright (C) 2ndQuadrant, 2010
* Copyright (c) Heroku, 2010
* *
* Replication manager daemon
* This module connects to the nodes of a replication cluster and monitors * This module connects to the nodes of a replication cluster and monitors
* how far are they from master * how far are they from master
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <signal.h> #include <signal.h>
@@ -74,7 +86,8 @@ static void setup_cancel_handler(void);
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
static struct option long_options[] = { static struct option long_options[] =
{
{"config", required_argument, NULL, 'f'}, {"config", required_argument, NULL, 'f'},
{"verbose", no_argument, NULL, 'v'}, {"verbose", no_argument, NULL, 'v'},
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
@@ -235,7 +248,6 @@ MonitorExecute(void)
{ {
fprintf(stderr, "\n%s: We couldn't reconnect to master, checking if ", fprintf(stderr, "\n%s: We couldn't reconnect to master, checking if ",
progname); progname);
fprintf(stderr, "%s: another node has been promoted.\n", progname);
for (connection_retries = 0; connection_retries < 6; for (connection_retries = 0; connection_retries < 6;
connection_retries++) connection_retries++)
{ {