-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import the pgsqlms script, its required libs, docs and others files from its old location in the pgsql-resource-agent repository. For history, see: https://github.com/dalibo/pgsql-resource-agent
- Loading branch information
Showing
21 changed files
with
3,630 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use File::Spec; | ||
use Storable; | ||
use Module::Build; | ||
|
||
my $lib_ocf_root = '/usr/lib/ocf'; | ||
my $ocft_confs = '/usr/share/resource-agents/ocft/configs'; | ||
my $lib_ocf_dirs; | ||
my $ocf_dirs; | ||
my %ocf_dirs; | ||
|
||
my $build = Module::Build->new( | ||
module_name => 'PAF', | ||
license => 'bsd', | ||
requires => { | ||
'perl' => '5.8.0' | ||
}, | ||
create_packlist => 1, | ||
#create_readme => 1, | ||
create_makefile_pl => 'traditional', | ||
dist_version => '1.0.0', | ||
dist_abstract => 'PostgreSQL multistate OCF resource agent for Pacemaker', | ||
dist_author => [ | ||
'Mael Rimbault <[email protected]>', | ||
'Jehan-Guillaume <[email protected]>' | ||
], | ||
script_files => [ 'script/pgsqlms' ], | ||
PL_files => { | ||
'lib/OCF_Directories.pm.PL' => 'lib/OCF_Directories.pm' | ||
}, | ||
tests_files => { | ||
't/pgsqlms' => 'tests/pgsqlms' | ||
}, | ||
get_options => { | ||
with_ocf_root => { | ||
type => '=s', | ||
store => \$lib_ocf_root | ||
}, | ||
with_ocft_confs => { | ||
type => '=s', | ||
store => \$ocft_confs | ||
} | ||
}, | ||
add_to_cleanup => [ | ||
'lib/OCF_Directories.pm', | ||
], | ||
meta_merge => { | ||
resources => { | ||
'homepage' => 'http://dalibo.github.io/PAF/', | ||
'repository' => 'https://github.com/dalibo/PAF', | ||
'bugtracker' => 'https://github.com/dalibo/PAF/issues' | ||
} | ||
}, | ||
); | ||
|
||
# Check given ocf_root or default values | ||
for my $dir ( | ||
$lib_ocf_root, '/usr/lib/ocf', '/usr/lib32/ocf', '/usr/lib64/ocf' | ||
) { | ||
if ( -d $dir and -s "$dir/lib/heartbeat/ocf-directories" ) { | ||
print STDERR "Found OCF_ROOT: $dir\n"; | ||
$lib_ocf_root = $dir; | ||
last; | ||
} | ||
} | ||
|
||
$lib_ocf_dirs = "$lib_ocf_root/lib/heartbeat/ocf-directories"; | ||
|
||
die "Couldn't find OCF shell functions in «OCF_ROOT/lib/heartbeat»!\n" | ||
."Try to build using the --with_ocf_root argument.\n" if ! -f $lib_ocf_dirs; | ||
|
||
$ocf_dirs = qx{ | ||
. "$lib_ocf_dirs" 2> /dev/null | ||
echo "\$INITDIR" | ||
echo "\$HA_DIR" | ||
echo "\$HA_RCDIR" | ||
echo "\$HA_CONFDIR" | ||
echo "\$HA_CF" | ||
echo "\$HA_VARLIB" | ||
echo "\$HA_RSCTMP" | ||
echo "\$HA_RSCTMP_OLD" | ||
echo "\$HA_FIFO" | ||
echo "\$HA_BIN" | ||
echo "\$HA_SBIN_DIR" | ||
echo "\$HA_DATEFMT" | ||
echo "\$HA_DEBUGLOG" | ||
echo "\$HA_RESOURCEDIR" | ||
echo "\$HA_DOCDIR" | ||
echo "\$HA_VARRUN" | ||
echo "\$HA_VARLOCK" | ||
echo "\$prefix" | ||
echo "\$exec_prefix" | ||
}; | ||
|
||
@ocf_dirs{ | ||
'INITDIR', 'HA_DIR', 'HA_RCDIR', 'HA_CONFDIR', 'HA_CF', | ||
'HA_VARLIB', 'HA_RSCTMP', 'HA_RSCTMP_OLD', 'HA_FIFO', 'HA_BIN', | ||
'HA_SBIN_DIR', 'HA_DATEFMT', 'HA_DEBUGLOG', 'HA_RESOURCEDIR', 'HA_DOCDIR', | ||
'HA_VARRUN', 'HA_VARLOCK', 'prefix', 'exec_prefix' | ||
} = split /\n/ => $ocf_dirs; | ||
|
||
$build->install_path( 'lib' => "$lib_ocf_root/lib/heartbeat" ); | ||
$build->install_path( 'script' => "$lib_ocf_root/resource.d/heartbeat" ); | ||
|
||
for my $dir ( | ||
$ocft_confs, "$ocf_dirs{'prefix'}/share/resource-agents/ocft/configs" | ||
) { | ||
if ( -d $dir ) { | ||
print STDERR "Found OCFT_CONFS: $dir\n"; | ||
$ocft_confs = $dir; | ||
|
||
$build->add_build_element('tests'); | ||
$build->install_path( 'tests' => "$ocft_confs" ); | ||
last; | ||
} | ||
} | ||
|
||
$build->create_build_script; | ||
|
||
Storable::store( \%ocf_dirs, File::Spec->tmpdir."/ocf_dirs.bin" ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2016, Jehan-Guillaume de Rorthais, Mael Rimbault. | ||
|
||
Permission to use, copy, modify, and distribute this software and its | ||
documentation for any purpose, without fee, and without a written agreement | ||
is hereby granted, provided that the above copyright notice and this | ||
paragraph and the following two paragraphs appear in all copies. | ||
|
||
IN NO EVENT SHALL THE AUTHOR OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR | ||
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING | ||
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS | ||
DOCUMENTATION, EVEN IF THE AUTHOR OR DISTRIBUTORS HAVE BEEN ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. | ||
|
||
THE AUTHOR AND DISTRIBUTORS SPECIFICALLY DISCLAIMS ANY WARRANTIES, | ||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS | ||
ON AN "AS IS" BASIS, AND THE AUTHOR AND DISTRIBUTORS HAS NO OBLIGATIONS TO | ||
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Build.PL | ||
LICENSE | ||
MANIFEST This list of files | ||
README.md | ||
docs/FENCING.md | ||
docs/INSTALL.md | ||
docs/Quick_Start-CentOS-6.md | ||
docs/Quick_Start-CentOS-7.md | ||
lib/OCF_Directories.pm.PL | ||
lib/OCF_Functions.pm | ||
lib/OCF_ReturnCodes.pm | ||
script/pgsqlms | ||
t/pgsqlms | ||
t/README |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
|
||
#!start included /usr/share/perl/5.20/ExtUtils/MANIFEST.SKIP | ||
# Avoid version control files. | ||
\bRCS\b | ||
\bCVS\b | ||
\bSCCS\b | ||
,v$ | ||
\B\.svn\b | ||
\B\.git\b | ||
\B\.gitignore\b | ||
\b_darcs\b | ||
\B\.cvsignore$ | ||
|
||
# Avoid VMS specific MakeMaker generated files | ||
\bDescrip.MMS$ | ||
\bDESCRIP.MMS$ | ||
\bdescrip.mms$ | ||
|
||
# Avoid Makemaker generated and utility files. | ||
\bMANIFEST\.bak | ||
\bMakefile$ | ||
\bblib/ | ||
\bMakeMaker-\d | ||
\bpm_to_blib\.ts$ | ||
\bpm_to_blib$ | ||
\bblibdirs\.ts$ # 6.18 through 6.25 generated this | ||
|
||
# Avoid Module::Build generated and utility files. | ||
\bBuild$ | ||
\b_build/ | ||
\bBuild.bat$ | ||
\bBuild.COM$ | ||
\bBUILD.COM$ | ||
\bbuild.com$ | ||
|
||
# Avoid temp and backup files. | ||
~$ | ||
\.old$ | ||
\#$ | ||
\b\.# | ||
\.bak$ | ||
\.tmp$ | ||
\.# | ||
\.rej$ | ||
|
||
# Avoid OS-specific files/dirs | ||
# Mac OSX metadata | ||
\B\.DS_Store | ||
# Mac OSX SMB mount metadata files | ||
\B\._ | ||
|
||
# Avoid Devel::Cover and Devel::CoverX::Covered files. | ||
\bcover_db\b | ||
\bcovered\b | ||
|
||
# Avoid MYMETA files | ||
^MYMETA\. | ||
#!end included /usr/share/perl/5.20/ExtUtils/MANIFEST.SKIP | ||
|
||
# Avoid configuration metadata file | ||
^MYMETA\. | ||
|
||
# Avoid Module::Build generated and utility files. | ||
\bBuild$ | ||
\bBuild.bat$ | ||
\b_build | ||
\bBuild.COM$ | ||
\bBUILD.COM$ | ||
\bbuild.com$ | ||
^MANIFEST\.SKIP | ||
|
||
# Avoid archives of this distribution | ||
\bPAF-[\d\.\_]+ | ||
|
||
# Avoid developers doc | ||
^docs\/dev\/.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# PostgreSQL Automatic Failover | ||
|
||
High-Availibility for Postgres, based industry references on Pacemaker and | ||
Corosync. | ||
|
||
## Description | ||
|
||
Pacemaker is nowadays the industry reference for High Availability. In the same | ||
fashion than for Systemd, all Linux distributions moved (or are moving) to this | ||
unique Pacemaker+Corosync stack, removing all other existing high availability | ||
stacks (CMAN, RGManager, OpenAIS, ...). It is able to detect failure on various | ||
services and automatically decide to failover the failing resource to another | ||
node when possible. | ||
|
||
To be able to manage a specific service resource, Pacemaker interact with it | ||
through a so-called "Resource Agent". Resource agents must comply to the OCF | ||
specification which define what they must implement (start, stop, promote, | ||
etc), how they should behave and inform Pacemaker of their results. | ||
|
||
PostgreSQL Automatic Failover is a new OCF resource Agent dedicated to | ||
PostgreSQL. Its original wish is to keep a clear limit between the Pacemaker | ||
administration and the PostgreSQL one, to keep things simple, documented and | ||
yet powerful. | ||
|
||
Once your PostgreSQL cluster built using internal streaming replication, PAF is | ||
able to expose to Pacemaker what is the current status of the PostgreSQL | ||
instance on each node: master, slave, stopped, catching up, etc. Should a | ||
failure occurs on the master, Pacemaker will try to recover it by default. | ||
Should the failure be non-recoverable, PAF allows the slaves to be able to | ||
elect the best of them (the closest one to the old master) and promote it as | ||
the new master. All of this thanks to the robust, feature-full and most | ||
importantly experienced project: Pacemaker. | ||
|
||
For information about how to install this agent, see``docs/INSTALL.md``. | ||
|
||
## Setup and requirements | ||
|
||
PAF supports PostgreSQL 9.3 and higher. It has been extensively tested under | ||
CentOS 6 and 7 in various scenario. | ||
|
||
PAF has been written to give to the administrator the maximum control | ||
over their PostgreSQL configuration and architecture. Thus, you are 100% | ||
responsible for the master/slave creations and their setup. The agent | ||
will NOT edit your setup. It only requires you to follow these pre-requisites: | ||
|
||
* slave __must__ be in hot_standby (accept read-only connections) | ||
* you __must__ provide a template file on each node which will be copied as | ||
the local ``recovery.conf`` when needed by the agent | ||
* the recovery template file __must__ contain ``standby_mode = on`` | ||
* the recovery template file __must__ contain ``recovery_target_timeline = 'latest'`` | ||
* the ``primary_conninfo`` parameter in the recovery template file __must__ | ||
set the ``application_name`` to the node name as seen in Pacemaker | ||
(usually, the hostname) | ||
|
||
When setting up the resource in Pacemaker, here are the available parameters you | ||
can set: | ||
|
||
* ``bindir``: location of the PostgreSQL binaries (default: ``/usr/bin``) | ||
* ``pgdata``: location of the PGDATA of your instance (default: | ||
``/var/lib/pgsql/data``) | ||
* ``pghost``: the socket directory or IP address to use to connect to the | ||
local instance (default: ``/tmp``) | ||
* ``pgport``: the port to connect to the local instance (default: ``5432``) | ||
* ``recovery_tpl``: the local template that will be copied as the | ||
``PGDATA/recovery.conf`` file. This template file must exists on all node | ||
(default: ``$PGDATA/recovery.conf.pcmk``) | ||
* ``system_user``: the system owner of your instance's process (default: | ||
``postgres``) | ||
|
||
For a demonstration about how to setup a cluster, see | ||
``docs/Quick_Start-CentOS-6.md`` or ``docs/Quick_Start-CentOS-7.md``. | ||
|
Oops, something went wrong.