mirror of
https://abf.rosa.ru/djam/postgrespro-1c.git
synced 2025-02-23 21:42:47 +00:00
Automatic import for version 15.2-1.res7
This commit is contained in:
commit
a42e261a2c
16 changed files with 3192 additions and 0 deletions
2
.abf.yml
Normal file
2
.abf.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
sources:
|
||||
"postgresql-15.2.tar.bz2": 3725afaa8587583628bc36b813cb9eb2013aad28
|
68
1c.tune
Executable file
68
1c.tune
Executable file
|
@ -0,0 +1,68 @@
|
|||
#!/bin/sh
|
||||
# This script generates set of configuration options
|
||||
# tuned for 1C database
|
||||
|
||||
limit() {
|
||||
## This function checks if first arg is within limits set by second
|
||||
## and third arg. If so, it prints out first arg, otherwise - limit
|
||||
## minimal limit should always be specified. maximal can be omitted
|
||||
## and would be considered infinity
|
||||
computed="$1"
|
||||
min="$2"
|
||||
max="$3"
|
||||
if [ "$computed" -lt "$min" ]; then
|
||||
echo "$min"
|
||||
elif [ -n "$max" ] && [ "$computed" -gt "$max" ]; then
|
||||
echo "$max"
|
||||
else
|
||||
echo "$computed"
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$1" != "--nocheck" ]; then
|
||||
PREFIX=$(dirname $(dirname $0))
|
||||
EDVER=$(basename $PREFIX)
|
||||
for module in plantuner online_analyze; do
|
||||
if [ ! -e ${PREFIX}/lib/${module}.so ]; then
|
||||
echo "Module $module is not found. Please install postgrespro-${EDVER}-contrib package" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
# Number of CPUS
|
||||
NCPU=$(nproc)
|
||||
# Size of RAM in megabytes
|
||||
RAMMB=$(LC_MESSAGES=C free -m|awk '/Mem:/ {print $2;}')
|
||||
# This is set of options to be added to config
|
||||
|
||||
cat << END_OF_CONF
|
||||
listen_addresses = '*'
|
||||
shared_buffers = $((RAMMB/4))MB # 25% of RAM
|
||||
temp_buffers = 128MB
|
||||
max_files_per_process = 10000
|
||||
max_parallel_workers_per_gather = 0
|
||||
max_parallel_maintenance_workers = $(limit $((NCPU/4)) 2 6) # Количество CPU/4, минимум 2, максимум 6
|
||||
commit_delay = 1000
|
||||
max_wal_size = 4GB
|
||||
min_wal_size = 2GB
|
||||
checkpoint_timeout = 15min
|
||||
effective_cache_size = $((RAMMB*3/4))MB # 75% of RAM
|
||||
from_collapse_limit = 8
|
||||
join_collapse_limit = 8
|
||||
autovacuum_max_workers = $(limit $((NCPU/2)) 2) # Количество CPU/2, минимум 2
|
||||
vacuum_cost_limit = $(limit $((NCPU*50)) 200) # 100* autovacuum_max_workers
|
||||
autovacuum_naptime = 20s
|
||||
autovacuum_vacuum_scale_factor = 0.01
|
||||
autovacuum_analyze_scale_factor = 0.005
|
||||
max_locks_per_transaction = 256
|
||||
escape_string_warning = off
|
||||
standard_conforming_strings = off
|
||||
shared_preload_libraries = 'online_analyze, plantuner'
|
||||
online_analyze.threshold = 50
|
||||
online_analyze.scale_factor = 0.1
|
||||
online_analyze.enable = on
|
||||
online_analyze.verbose = off
|
||||
online_analyze.min_interval = 10000
|
||||
online_analyze.table_type = 'temporary'
|
||||
plantuner.fix_empty_table = on
|
||||
END_OF_CONF
|
67
Makefile.regress
Executable file
67
Makefile.regress
Executable file
|
@ -0,0 +1,67 @@
|
|||
#
|
||||
# Simplified makefile for running the PostgreSQL regression tests
|
||||
# in an RPM installation
|
||||
#
|
||||
|
||||
# maximum simultaneous connections for parallel tests
|
||||
MAXCONNOPT =
|
||||
ifdef MAX_CONNECTIONS
|
||||
MAXCONNOPT += --max-connections=$(MAX_CONNECTIONS)
|
||||
endif
|
||||
|
||||
# locale
|
||||
NOLOCALE =
|
||||
ifdef NO_LOCALE
|
||||
NOLOCALE += --no-locale
|
||||
endif
|
||||
|
||||
srcdir := .
|
||||
|
||||
REGRESS_OPTS += --dlpath=.
|
||||
|
||||
pg_regress_locale_flags = $(if $(ENCODING),--encoding=$(ENCODING)) $(NOLOCALE)
|
||||
|
||||
pg_regress_installcheck = ./pg_regress --inputdir=$(srcdir) --psqldir='/usr/bin' $(pg_regress_locale_flags)
|
||||
|
||||
# Test input and expected files. These are created by pg_regress itself, so we
|
||||
# don't have a rule to create them. We do need rules to clean them however.
|
||||
ifile_list := $(subst .source,, $(notdir $(wildcard $(srcdir)/input/*.source)))
|
||||
input_files := $(foreach file, $(ifile_list), sql/$(file).sql)
|
||||
ofile_list := $(subst .source,, $(notdir $(wildcard $(srcdir)/output/*.source)))
|
||||
output_files := $(foreach file, $(ofile_list), expected/$(file).out)
|
||||
|
||||
abs_srcdir := $(shell pwd)
|
||||
abs_builddir := $(shell pwd)
|
||||
|
||||
check: installcheck-parallel
|
||||
|
||||
installcheck: cleandirs
|
||||
$(pg_regress_installcheck) $(REGRESS_OPTS) --schedule=$(srcdir)/serial_schedule $(EXTRA_TESTS)
|
||||
|
||||
installcheck-parallel: cleandirs
|
||||
$(pg_regress_installcheck) $(REGRESS_OPTS) --schedule=$(srcdir)/parallel_schedule $(MAXCONNOPT) $(EXTRA_TESTS)
|
||||
|
||||
# The tests command the server to write into testtablespace and results.
|
||||
# On a SELinux-enabled system this will fail unless we mark those directories
|
||||
# as writable by the server.
|
||||
cleandirs:
|
||||
-rm -rf testtablespace results
|
||||
mkdir testtablespace results
|
||||
[ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_db_t testtablespace results
|
||||
|
||||
# old interfaces follow...
|
||||
|
||||
runcheck: check
|
||||
runtest: installcheck
|
||||
runtest-parallel: installcheck-parallel
|
||||
|
||||
|
||||
##
|
||||
## Clean up
|
||||
##
|
||||
|
||||
clean distclean maintainer-clean:
|
||||
rm -f $(output_files) $(input_files)
|
||||
rm -rf testtablespace
|
||||
rm -rf results tmp_check log
|
||||
rm -f regression.diffs regression.out regress.out run_check.out
|
18
big.conf.sample
Normal file
18
big.conf.sample
Normal file
|
@ -0,0 +1,18 @@
|
|||
# DB Version: 9.6
|
||||
# OS Type: linux
|
||||
# DB Type: oltp
|
||||
# Total Memory (RAM): 128 GB
|
||||
# Number of Connections: 1000
|
||||
|
||||
max_connections = 1000
|
||||
shared_buffers = 32GB
|
||||
effective_cache_size = 96GB
|
||||
work_mem = 33554kB
|
||||
maintenance_work_mem = 2GB
|
||||
min_wal_size = 2GB
|
||||
max_wal_size = 4GB
|
||||
checkpoint_completion_target = 0.9
|
||||
wal_buffers = 16MB
|
||||
default_statistics_target = 100
|
||||
|
||||
|
1
buildinfo.txt
Normal file
1
buildinfo.txt
Normal file
|
@ -0,0 +1 @@
|
|||
SPEC file version: 87cbabd5d8742b84f2d3c75bae5c2a9884ac61d3 Tue Feb 14 11:30:28 2023 +0300
|
29
ecpg_config.h
Executable file
29
ecpg_config.h
Executable file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Kluge to support multilib installation of both 32- and 64-bit RPMS:
|
||||
* we need to arrange that header files that appear in both RPMs are
|
||||
* identical. Hence, this file is architecture-independent and calls
|
||||
* in an arch-dependent file that will appear in just one RPM.
|
||||
*
|
||||
* To avoid breaking arches not explicitly supported by Red Hat, we
|
||||
* use this indirection file *only* on known multilib arches.
|
||||
*
|
||||
* Note: this may well fail if user tries to use gcc's -I- option.
|
||||
* But that option is deprecated anyway.
|
||||
*/
|
||||
#if defined(__x86_64__)
|
||||
#include "ecpg_config_x86_64.h"
|
||||
#elif defined(__i386__)
|
||||
#include "ecpg_config_i386.h"
|
||||
#elif defined(__ppc64__) || defined(__powerpc64__)
|
||||
#include "ecpg_config_ppc64.h"
|
||||
#elif defined(__ppc__) || defined(__powerpc__)
|
||||
#include "ecpg_config_ppc.h"
|
||||
#elif defined(__s390x__)
|
||||
#include "ecpg_config_s390x.h"
|
||||
#elif defined(__s390__)
|
||||
#include "ecpg_config_s390.h"
|
||||
#elif defined(__sparc__) && defined(__arch64__)
|
||||
#include "ecpg_config_sparc64.h"
|
||||
#elif defined(__sparc__)
|
||||
#include "ecpg_config_sparc.h"
|
||||
#endif
|
18
medium.conf.sample
Normal file
18
medium.conf.sample
Normal file
|
@ -0,0 +1,18 @@
|
|||
# DB Version: 9.6
|
||||
# OS Type: linux
|
||||
# DB Type: oltp
|
||||
# Total Memory (RAM): 32 GB
|
||||
# Number of Connections: 200
|
||||
|
||||
max_connections = 200
|
||||
shared_buffers = 8GB
|
||||
effective_cache_size = 24GB
|
||||
work_mem = 41943kB
|
||||
maintenance_work_mem = 2GB
|
||||
min_wal_size = 2GB
|
||||
max_wal_size = 4GB
|
||||
checkpoint_completion_target = 0.9
|
||||
wal_buffers = 16MB
|
||||
default_statistics_target = 100
|
||||
|
||||
|
218
pg-wrapper.in
Normal file
218
pg-wrapper.in
Normal file
|
@ -0,0 +1,218 @@
|
|||
#!/bin/sh
|
||||
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||||
NAME=`basename $0`
|
||||
BINDIR=@BINDIR@
|
||||
MANDIR=@MANDIR@
|
||||
MANSUF=.gz
|
||||
# List of possible names of man.config in the various distributions
|
||||
MAN_CONFIGS="/etc/manpath.config /etc/man_db.conf /etc/man.config"
|
||||
|
||||
USAGE_STRING="Usage: $0 links (update|remove)"
|
||||
|
||||
make_ua_path() {
|
||||
if [ -x /usr/sbin/update-alternatives ]; then
|
||||
echo /usr/sbin/update-alternatives
|
||||
else
|
||||
if [ -x /usr/bin/update-alternatives ]; then
|
||||
echo /usr/bin/update-alternatives
|
||||
else
|
||||
echo /sbin/update-alternatives
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
update_man_config() {
|
||||
for config in $MAN_CONFIGS; do
|
||||
[ -f "$config" ] || continue
|
||||
if ! grep $MANDIR "$config" >/dev/null; then
|
||||
echo "Updating $config"
|
||||
if [ "$config" = "/etc/man.config" ]; then
|
||||
echo "MANPATH $MANDIR" >> "$config"
|
||||
else
|
||||
echo "MANDATORY_MANPATH $MANDIR" >> "$config"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
cleanup_man_config() {
|
||||
for config in $MAN_CONFIGS; do
|
||||
[ -f "$config" ] || continue
|
||||
if grep $MANDIR "$config" >/dev/null; then
|
||||
echo "Updating $config"
|
||||
MANDIR_PATTERN=`echo $MANDIR | sed -e 's,\/,\\\/,g'`
|
||||
if [ "$config" = "/etc/man.config" ]; then
|
||||
sed -i.bak "/MANPATH $MANDIR_PATTERN/d" "$config" && rm -f "${config}.bak"
|
||||
else
|
||||
sed -i.bak "/MANDATORY_MANPATH $MANDIR_PATTERN/d" "$config" && rm -f "${config}.bak"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
update_links() {
|
||||
BINLIST=`ls $BINDIR`
|
||||
MAN1LIST=`ls $MANDIR/man1`
|
||||
MAN1RULIST=`ls $MANDIR/ru/man1`
|
||||
UA=`make_ua_path`
|
||||
if [ -x $UA ] && [ ! "`realpath $UA 2>/dev/null`" = "/bin/true" ]; then
|
||||
man_installed=0
|
||||
for name in $BINLIST; do
|
||||
$UA --install /usr/bin/$name pgsql-${name} $BINDIR/pg-wrapper @VERSION@00
|
||||
done
|
||||
for name in $MAN1LIST; do
|
||||
name=`echo $name | sed -e 's/\.1.*//g'`
|
||||
$UA --install /usr/share/man/man1/${name}.1${MANSUF} pgsql-${name}man $MANDIR/man1/${name}.1${MANSUF} @VERSION@00 && man_installed=1
|
||||
done
|
||||
|
||||
if [ ! -d /usr/share/man/ru/man1 ]; then
|
||||
mkdir -p /usr/share/man/ru/man1
|
||||
fi
|
||||
for name in $MAN1RULIST; do
|
||||
name=`echo $name | sed -e 's/\.1.*//g'`
|
||||
$UA --install /usr/share/man/ru/man1/${name}.1${MANSUF} pgsql-${name}manru $MANDIR/ru/man1/${name}.1${MANSUF} @VERSION@00
|
||||
done
|
||||
|
||||
if [ $man_installed -eq 1 ]; then
|
||||
update_man_config
|
||||
fi
|
||||
else
|
||||
bin_ready=1
|
||||
man_ready=1
|
||||
man_ru_ready=1
|
||||
for name in $BINLIST; do
|
||||
if [ -f /usr/bin/$name ] && [ ! -L /usr/bin/$name ]; then
|
||||
echo "Warning: skipping binary link setup. Binary file already exists: /usr/bin/$name"
|
||||
bin_ready=0
|
||||
fi
|
||||
done
|
||||
for name in $MAN1LIST; do
|
||||
name=`echo $name | sed -e 's/\.1.*//g'`
|
||||
if [ -f /usr/share/man/man1/${name}.1${MANSUF} ] && [ ! -L /usr/share/man/man1/${name}.1${MANSUF} ]; then
|
||||
echo "Warning: skipping man page setup. Man page with the same name already exists: /usr/share/man/man1/${name}.1${MANSUF}"
|
||||
man_ready=0
|
||||
fi
|
||||
done
|
||||
for name in $MAN1RULIST; do
|
||||
name=`echo $name | sed -e 's/\.1.*//g'`
|
||||
if [ -f /usr/share/man/ru/man1/${name}.1${MANSUF} ] && [ ! -L /usr/share/man/ru/man1/${name}.1${MANSUF} ]; then
|
||||
echo "Warning: skipping man page setup. Man page with the same name already exists: /usr/share/man/ru/man1/${name}.1${MANSUF}"
|
||||
man_ru_ready=0
|
||||
fi
|
||||
done
|
||||
if [ $bin_ready -eq 1 ] && [ $man_ready -eq 1 ] && [ $man_ru_ready -eq 1 ]; then
|
||||
for name in $BINLIST; do
|
||||
echo "Creating link for /usr/bin/$name"
|
||||
ln -snf $BINDIR/pg-wrapper /usr/bin/$name
|
||||
done
|
||||
for name in $MAN1LIST; do
|
||||
name=`echo $name | sed -e 's/\.1.*//g'`
|
||||
echo "Creating link for /usr/share/man/man1/${name}.1${MANSUF}"
|
||||
ln -snf $MANDIR/man1/${name}.1${MANSUF} /usr/share/man/man1/${name}.1${MANSUF}
|
||||
done
|
||||
if [ ! -d /usr/share/man/ru/man1 ]; then
|
||||
mkdir -p /usr/share/man/ru/man1
|
||||
fi
|
||||
for name in $MAN1RULIST; do
|
||||
name=`echo $name | sed -e 's/\.1.*//g'`
|
||||
echo "Creating link for /usr/share/man/ru/man1/${name}.1${MANSUF}"
|
||||
ln -snf $MANDIR/ru/man1/${name}.1${MANSUF} /usr/share/man/ru/man1/${name}.1${MANSUF}
|
||||
done
|
||||
|
||||
update_man_config
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
remove_links() {
|
||||
BINLIST=`ls $BINDIR`
|
||||
MAN1LIST=`ls $MANDIR/man1`
|
||||
MAN1RULIST=`ls $MANDIR/ru/man1`
|
||||
UA=`make_ua_path`
|
||||
if [ -x $UA ] && [ ! "`realpath $UA`" = "/bin/true" ] 2>/dev/null; then
|
||||
for name in $BINLIST; do
|
||||
$UA --remove pgsql-$name $BINDIR/pg-wrapper
|
||||
done
|
||||
for name in $MAN1LIST; do
|
||||
name=`echo $name | sed -e 's/\.1.*//g'`
|
||||
$UA --remove pgsql-${name}man $MANDIR/man1/${name}.1${MANSUF}
|
||||
done
|
||||
for name in $MAN1RULIST; do
|
||||
name=`echo $name | sed -e 's/\.1.*//g'`
|
||||
$UA --remove pgsql-${name}manru $MANDIR/ru/man1/${name}.1${MANSUF}
|
||||
done
|
||||
else
|
||||
PGHOME=`/usr/bin/dirname $BINDIR`
|
||||
for name in $BINLIST; do
|
||||
if [ -L /usr/bin/$name ] ; then
|
||||
path=`readlink /usr/bin/$name`
|
||||
if echo $path | grep $PGHOME >/dev/null; then
|
||||
echo "Removing link for /usr/bin/$name"
|
||||
rm -f /usr/bin/$name
|
||||
fi
|
||||
fi
|
||||
done
|
||||
for name in $MAN1LIST; do
|
||||
name=`echo $name | sed -e 's/\.1.*//g'`
|
||||
if [ -L /usr/share/man/man1/${name}.1${MANSUF} ] ; then
|
||||
path=`readlink /usr/share/man/man1/${name}.1${MANSUF}`
|
||||
if echo $path | grep $PGHOME >/dev/null; then
|
||||
echo "Removing link for /usr/share/man/man1/${name}.1${MANSUF}"
|
||||
rm -f /usr/share/man/man1/${name}.1${MANSUF}
|
||||
fi
|
||||
fi
|
||||
done
|
||||
for name in $MAN1RULIST; do
|
||||
name=`echo $name | sed -e 's/\.1.*//g'`
|
||||
if [ -L /usr/share/man/ru/man1/${name}.1 ] ; then
|
||||
path=`readlink /usr/share/man/ru/man1/${name}.1${MANSUF}`
|
||||
if echo $path | grep $PGHOME >/dev/null; then
|
||||
echo "Removing link for /usr/share/man/ru/man1/${name}.1${MANSUF}"
|
||||
rm -f /usr/share/man/ru/man1/${name}.1${MANSUF}
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
cleanup_man_config
|
||||
|
||||
}
|
||||
|
||||
links() {
|
||||
case "$1" in
|
||||
update)
|
||||
shift
|
||||
update_links $@
|
||||
;;
|
||||
remove)
|
||||
shift
|
||||
remove_links $@
|
||||
;;
|
||||
*)
|
||||
echo >&2 "$USAGE_STRING"
|
||||
exit 2
|
||||
esac
|
||||
}
|
||||
|
||||
if [ -z "$NAME" ]; then
|
||||
echo "Error: failed to extract basename of $0"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$NAME" = "pg-wrapper" ]; then
|
||||
case "$1" in
|
||||
links)
|
||||
shift
|
||||
if [ $(id -u) -ne 0 ]; then
|
||||
echo "Links management requires root privileges" >&2
|
||||
exit 1;
|
||||
fi
|
||||
links $@
|
||||
;;
|
||||
*)
|
||||
echo >&2 "$USAGE_STRING"
|
||||
exit 2
|
||||
esac
|
||||
else
|
||||
exec $BINDIR/$NAME ${1:+"$@"}
|
||||
fi
|
29
pg_config.h
Executable file
29
pg_config.h
Executable file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Kluge to support multilib installation of both 32- and 64-bit RPMS:
|
||||
* we need to arrange that header files that appear in both RPMs are
|
||||
* identical. Hence, this file is architecture-independent and calls
|
||||
* in an arch-dependent file that will appear in just one RPM.
|
||||
*
|
||||
* To avoid breaking arches not explicitly supported by Red Hat, we
|
||||
* use this indirection file *only* on known multilib arches.
|
||||
*
|
||||
* Note: this may well fail if user tries to use gcc's -I- option.
|
||||
* But that option is deprecated anyway.
|
||||
*/
|
||||
#if defined(__x86_64__)
|
||||
#include "pg_config_x86_64.h"
|
||||
#elif defined(__i386__)
|
||||
#include "pg_config_i386.h"
|
||||
#elif defined(__ppc64__) || defined(__powerpc64__)
|
||||
#include "pg_config_ppc64.h"
|
||||
#elif defined(__ppc__) || defined(__powerpc__)
|
||||
#include "pg_config_ppc.h"
|
||||
#elif defined(__s390x__)
|
||||
#include "pg_config_s390x.h"
|
||||
#elif defined(__s390__)
|
||||
#include "pg_config_s390.h"
|
||||
#elif defined(__sparc__) && defined(__arch64__)
|
||||
#include "pg_config_sparc64.h"
|
||||
#elif defined(__sparc__)
|
||||
#include "pg_config_sparc.h"
|
||||
#endif
|
47
postgrespro-check-db-dir.in
Executable file
47
postgrespro-check-db-dir.in
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/bin/sh
|
||||
|
||||
# This script verifies that the postgrespro data directory has been correctly
|
||||
# initialized. We do not want to automatically initdb it, because that has
|
||||
# a risk of catastrophic failure (ie, overwriting a valuable database) in
|
||||
# corner cases, such as a remotely mounted database on a volume that's a
|
||||
# bit slow to mount. But we can at least emit a message advising newbies
|
||||
# what to do.
|
||||
PATH=/bin:/usr/bin
|
||||
export PATH
|
||||
PGDATA="$1"
|
||||
|
||||
if [ -z "$PGDATA" ]
|
||||
then
|
||||
echo "Usage: $0 database-path"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PGENGINE=@BINDIR@
|
||||
PGMAJORVERSION=@VERSION@
|
||||
PREVMAJORVERSION=10
|
||||
|
||||
# Check for the PGDATA structure
|
||||
if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base" ]
|
||||
then
|
||||
# Check version of existing PGDATA
|
||||
if [ "$(cat "$PGDATA/PG_VERSION")" = "$PGMAJORVERSION" ]
|
||||
then
|
||||
exit 0
|
||||
elif [ "$(cat "$PGDATA/PG_VERSION")" = "$PREVMAJORVERSION" ]
|
||||
then
|
||||
echo "An old version of the database format was found."
|
||||
echo "Use \"${PGENGINE}/pg_upgrade\" to upgrade to version $PGMAJORVERSION."
|
||||
exit 1
|
||||
else
|
||||
echo "An old version of the database format was found."
|
||||
echo "You need to dump and reload before using Postgres Pro @EDITION@-$PGMAJORVERSION."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# No existing PGDATA! Warn the user to initdb it.
|
||||
echo "\"$PGDATA\" is missing or empty."
|
||||
echo "Use \"${PGENGINE}/pg-setup initdb\" to initialize the database cluster."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
482
postgrespro-setup.in
Normal file
482
postgrespro-setup.in
Normal file
|
@ -0,0 +1,482 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# postgrespro-setup Initialization and control operations for Postgres Pro
|
||||
#
|
||||
|
||||
PG_SETUP_VERSION=13.2.1
|
||||
BINDIR=@BINDIR@
|
||||
SERVICE=@PROGNAME@-@EDITION@-@VERSION@
|
||||
PGENGINE=$BINDIR
|
||||
|
||||
OU_STRING=""
|
||||
if [ "ent" = "@EDITION@" ] && [ "@VERSION@" -ge 13 ]; then
|
||||
OU_STRING=" [--enable-online-upgrade]"
|
||||
fi
|
||||
|
||||
USAGE_STRING="Usage: $0 initdb [<initdb-options>]
|
||||
or: $0 find-free-port
|
||||
or: $0 set-server-port <port>
|
||||
or: $0 service (enable|disable)
|
||||
or: $0 service (start|stop|condrestart|status)
|
||||
or: $0 set GUC-variable value
|
||||
or: $0 psql [<psql options>]
|
||||
|
||||
Script is aimed to help sysadmin with basic database cluster administration.
|
||||
|
||||
Available operation mode:
|
||||
initdb [--tune=conf]${OU_STRING} [<initdb-options>] Create a new Postgres Pro database cluster.
|
||||
find-free-port Search of free server TCP-port number, start with 5432.
|
||||
set-server-port <port> Set server port number.
|
||||
service enable Enable service.
|
||||
service disable Disable service.
|
||||
service status Service status.
|
||||
service start Start service.
|
||||
service stop Stop service.
|
||||
service condrestart Conditional restart of service.
|
||||
|
||||
pg-setup psql allows to start SQL shell correctly switching from root
|
||||
to postgres user and use port set by pg-setup set-server-port.
|
||||
"
|
||||
|
||||
# note that these options are useful at least for help2man processing
|
||||
case "$1" in
|
||||
--version)
|
||||
echo "pg-setup $PG_SETUP_VERSION"
|
||||
exit 0
|
||||
;;
|
||||
--help|--usage)
|
||||
echo "$USAGE_STRING"
|
||||
exit 0
|
||||
;;
|
||||
"")
|
||||
echo "$USAGE_STRING"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "$0 must be started as root" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PGDATA=/var/lib/pgpro/@EDITION@-@VERSION@/data
|
||||
DEFCONFIG=/etc/default/postgrespro-@EDITION@-@VERSION@
|
||||
# shellcheck disable=SC1090
|
||||
[ -f $DEFCONFIG ] && . $DEFCONFIG
|
||||
export PGDATA
|
||||
# make safe PATH
|
||||
PATH=/sbin:/bin:/usr/sbin:/usr/bin:@BINDIR@
|
||||
export PATH
|
||||
|
||||
# For SELinux we need to use 'runuser' not 'su'
|
||||
if [ -x /sbin/runuser ]
|
||||
then
|
||||
SU=/sbin/runuser
|
||||
else
|
||||
SU=su
|
||||
fi
|
||||
|
||||
#
|
||||
# This function sets confguration value in the postgresql.conf to given
|
||||
# string. If value should contain quotes, they should be passed as part
|
||||
# of string
|
||||
# i.e. set_conf_value log_destination "'stderr'"
|
||||
# Keeps end of line comments if it can.
|
||||
# Removes corresponding paramters from postgresql.auto.conf if any
|
||||
# FIXME - this function is unable to handle arbitrary includes,
|
||||
# but possibly would do a right thing, because if directive is in the
|
||||
# include, it would not find it in the main configuration file
|
||||
# and append new value to the end of it after all includes.
|
||||
|
||||
set_conf_value() {
|
||||
param="$1"
|
||||
value="$2"
|
||||
config="$PGDATA/postgresql.conf"
|
||||
if [ ! -f "$config" ]; then
|
||||
echo "Cannot find configuration file for $PGDATA!" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check if there is (possibly commented out) parameter in the config
|
||||
if grep -q "^#\\?${param}[ ]*=" "$config"; then
|
||||
# Found one edit
|
||||
sed -i "s/^#\\?${param}[ ]*=[ ]*[^#]*\\(#.*\\)\\?/$param = $value \\1/" \
|
||||
"$config"
|
||||
else
|
||||
# Not found, just append
|
||||
echo "$param = $value" >> "$config"
|
||||
fi
|
||||
# Check postgresql.auto.conf
|
||||
if [ -f "$PGDATA/postgresql.auto.conf" ] && grep -q "^${param}[ ]*=" "$PGDATA/postgresql.auto.conf"; then
|
||||
#Really we could call sed without previous check, but
|
||||
#I want to keep file timestamp if there is nothing to change
|
||||
sed -i "/^${param}[ ]*=/d" "$PGDATA/postgresql.auto.conf";
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# This function checks whether environment variable needs shell
|
||||
# quoting. Pass there unquited variable and function will return
|
||||
# 0 if it got more than one argument and 1 if just one
|
||||
need_quotes() {
|
||||
[ "$#" -gt 1 ]
|
||||
}
|
||||
#
|
||||
# This function checks whether existing directory does contain any files
|
||||
# and subdirectories
|
||||
#
|
||||
dir_is_not_empty() {
|
||||
[ "$(ls -A "$1")" ]
|
||||
}
|
||||
|
||||
initdb(){
|
||||
INITDB_OPTIONS=""
|
||||
datadir=""
|
||||
TUNE=@EDITION@
|
||||
ENABLE_ONLINE_UPGRADE=0
|
||||
for opt in "$@"; do
|
||||
if [ -n "$consume_next" ]; then
|
||||
datadir="$opt"
|
||||
consume_next=""
|
||||
continue
|
||||
fi
|
||||
case "$opt" in
|
||||
-D|--pgdata)
|
||||
if [ -n "$datadir" ]; then
|
||||
echo "Duplicate option $opt" 1>&2
|
||||
return 1
|
||||
fi
|
||||
consume_next=1
|
||||
;;
|
||||
--pgdata=*)
|
||||
if [ -n "$datadir" ]; then
|
||||
echo "Duplicate option --pgdata" 1>&2
|
||||
return 1
|
||||
fi
|
||||
datadir=$(echo "$opt"|sed 's/^[^=]*=//')
|
||||
;;
|
||||
--auth-local=*)
|
||||
if [ -n "$local_auth" ]; then
|
||||
echo "Duplicate option --auth-local" 1>&2
|
||||
return 1
|
||||
fi
|
||||
local_auth=$opt
|
||||
;;
|
||||
--auth-host=*)
|
||||
if [ -n "$host_auth" ]; then
|
||||
echo "Duplicate option --auth-host" 1>&2
|
||||
return 1
|
||||
fi
|
||||
host_auth=$opt
|
||||
;;
|
||||
--tune|--auth-local|-auth-host)
|
||||
echo "Please use syntax $opt=value" >&2;
|
||||
return 1
|
||||
;;
|
||||
--tune=*)
|
||||
TUNE=${opt#*=}
|
||||
;;
|
||||
--enable-online-upgrade)
|
||||
ENABLE_ONLINE_UPGRADE=1
|
||||
;;
|
||||
*)
|
||||
INITDB_OPTIONS="$INITDB_OPTIONS \"$opt\""
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [ -n "$datadir" ]; then
|
||||
# shellcheck disable=SC2166
|
||||
if [ "$datadir" != "$PGDATA" -a -f ${DEFCONFIG} ]; then
|
||||
echo "${DEFCONFIG} already exists " >&2
|
||||
echo "And sets up database location $PGDATA." >&2
|
||||
echo "If you want to setup second postgres instance in" >&2
|
||||
echo "$datadir" >&2
|
||||
echo "use @BINDIR@/initdb directly and configure service" >&2
|
||||
echo "startup manually." >&2
|
||||
return 1
|
||||
fi
|
||||
PGDATA="$datadir"
|
||||
export PGDATA
|
||||
fi
|
||||
# Check for relative path
|
||||
if [ ! -d "$PGDATA" ]; then
|
||||
mkdir -p "$PGDATA" || return 1
|
||||
elif dir_is_not_empty "$PGDATA" ; then
|
||||
echo "Data directory $PGDATA is not empty!" 1>&2
|
||||
return 1
|
||||
fi
|
||||
# convert path to PGDATA to absolute
|
||||
PGDATA="$(sh -c "cd '$PGDATA' && pwd -P")"
|
||||
|
||||
chown postgres:postgres "$PGDATA"
|
||||
chmod go-rwx "$PGDATA"
|
||||
# We intend word splitting here. This line checks if
|
||||
# PGDATA would be splitted
|
||||
# shellcheck disable=SC2086
|
||||
if need_quotes $PGDATA ; then
|
||||
echo "PGDATA=\"$PGDATA\"" > "${DEFCONFIG}"
|
||||
else
|
||||
echo "PGDATA=$PGDATA" > "${DEFCONFIG}"
|
||||
fi
|
||||
if [ "$ENABLE_ONLINE_UPGRADE" = "1" ]; then
|
||||
echo "ENABLE_ONLINE_UPGRADE=1" >> "${DEFCONFIG}"
|
||||
fi
|
||||
PGLOG="$(dirname "${PGDATA}")/initdb.$(basename "${PGDATA}").log"
|
||||
# Clean up SELinux tagging for PGDATA
|
||||
RESTORECON=/sbin/restorecon
|
||||
[ -x $RESTORECON ] && $RESTORECON "$PGDATA"
|
||||
# Check if locale of this script is suitable for creating database
|
||||
# and try to find better one if not
|
||||
if [ "$(locale charmap)" = "ANSI_X3.4-1968" ]; then
|
||||
# If current locale is 7-bit, try to get locale of
|
||||
# invoking user or default locale of user postgres,
|
||||
# shellcheck disable=SC2046
|
||||
eval $($SU - "${SUDO_USER:-postgres}" -c locale)
|
||||
[ -z "$LANG" ] || export LANG
|
||||
[ -z "$LC_CTYPE" ] || export LC_CTYPE
|
||||
elif [ -z "$LANG" ]&&[ -n "$LC_CTYPE" ]; then
|
||||
# If LC_CTYPE set to something usable, but LANG is unset,
|
||||
# set it equal to LC_CTYPE, because we need LC_COLLATE as well
|
||||
# as LC_CTYPE
|
||||
LANG="$LC_CTYPE"
|
||||
export LANG
|
||||
fi
|
||||
# if locale still C or POSIX, use C.UTF-8
|
||||
if [ "$(locale charmap)" = "ANSI_X3.4-1968" ]; then
|
||||
LANG=C.UTF-8
|
||||
[ -z "$LC_CTYPE" ] || LC_CTYPE="$LANG"
|
||||
[ -z "$LC_COLLATE" ] || LC_COLLATE="$LANG"
|
||||
[ -z "$LC_ALL" ] || LC_ALL="$LANG"
|
||||
[ -z "$LC_ALL" ] || export LC_ALL
|
||||
fi
|
||||
# Create the initdb log file if needed
|
||||
# shellcheck disable=SC2166
|
||||
if [ -f "$PGLOG" -o ! -e "$PGLOG" ]; then
|
||||
if ! : > "$PGLOG" ; then
|
||||
echo "Cannot write installation log file $PGLOG" >&2
|
||||
rm -rf "${PGDATA}" "${DEFCONFIG}"
|
||||
return 1
|
||||
fi
|
||||
chown postgres:postgres "$PGLOG"
|
||||
chmod go-wx "$PGLOG"
|
||||
[ -x $RESTORECON ] && $RESTORECON "$PGLOG"
|
||||
else
|
||||
echo "Log file $PGLOG exist and is not regular file. Cannot continue." >&2
|
||||
rm -rf "${PGDATA}" "${DEFCONFIG}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Initialize the database
|
||||
initdbcmd="$PGENGINE/initdb --pgdata='$PGDATA' ${local_auth:---auth-local=peer} ${host_auth:---auth-host=md5} $INITDB_OPTIONS"
|
||||
echo "Initalizing database..."
|
||||
if $SU -l postgres -c "LANG=$LANG $initdbcmd" >> "$PGLOG" 2>&1 < /dev/null; then
|
||||
# Create directory for postmaster log files
|
||||
mkdir "$PGDATA/log"
|
||||
chown postgres:postgres "$PGDATA/log"
|
||||
chmod go-rwx "$PGDATA/log"
|
||||
[ -x $RESTORECON ] && $RESTORECON "$PGDATA/log"
|
||||
# Tune configuration
|
||||
if [ -x "@PREFIX@/share/$TUNE.tune" ]; then
|
||||
if ! "@PREFIX@/share/$TUNE.tune" >> "$PGDATA/postgresql.conf"; then
|
||||
rm -rf "${PGDATA}" "${DEFCONFIG}"
|
||||
return 1
|
||||
fi
|
||||
if grep -q "^listen_addresses[ ]*=[ ]*'\\*'" "$PGDATA/postgresql.conf"
|
||||
then
|
||||
echo "host all all 0.0.0.0/0 md5" >> "$PGDATA/pg_hba.conf"
|
||||
fi
|
||||
fi
|
||||
# Fix shared_memory_type for online-upgrade
|
||||
if [ "$ENABLE_ONLINE_UPGRADE" = "1" ]; then
|
||||
set_conf_value "shared_memory_type" "sysv"
|
||||
fi
|
||||
# Fix configuration file to enable loging_collector
|
||||
if set_conf_value "logging_collector" "on"; then
|
||||
echo OK
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
rm -rf "${PGDATA}" "${DEFCONFIG}"
|
||||
echo "failed, see $PGLOG" 1>&2
|
||||
return 1
|
||||
}
|
||||
|
||||
find_free_port() {
|
||||
free_port=5432
|
||||
while /usr/bin/timeout 5 /bin/bash -c "cat < /dev/null > /dev/tcp/127.0.0.1/$free_port" 2>/dev/null; do
|
||||
# shellcheck disable=SC2003
|
||||
free_port=$((free_port + 1))
|
||||
done
|
||||
echo $free_port
|
||||
}
|
||||
|
||||
set_server_port(){
|
||||
port=$1
|
||||
if [ -z "$port" ]; then
|
||||
echo "Error: port value is empty!" >&2
|
||||
return 1
|
||||
fi
|
||||
# shellcheck disable=SC2003
|
||||
if ! /usr/bin/expr "$port" + 0 >/dev/null >&2; then
|
||||
echo "Bad port value: $port" 1>&2
|
||||
return 1
|
||||
fi
|
||||
# shellcheck disable=SC2166
|
||||
if [ "$port" -lt 1024 -o "$port" -gt 65535 ]; then
|
||||
echo "Port value $port is out of range (1024-65535)" 1>&2;
|
||||
return 1
|
||||
fi
|
||||
set_conf_value "port" "$port"
|
||||
}
|
||||
|
||||
enable_service() {
|
||||
if [ -n "$SCTL" ]; then
|
||||
$SCTL enable $SERVICE
|
||||
return $?
|
||||
else
|
||||
URCD=/usr/sbin/update-rc.d
|
||||
if [ -x $URCD ]; then
|
||||
$URCD $SERVICE defaults
|
||||
else
|
||||
/sbin/chkconfig --add $SERVICE
|
||||
/sbin/chkconfig --level 35 $SERVICE on
|
||||
fi
|
||||
return $?
|
||||
fi
|
||||
}
|
||||
|
||||
disable_service() {
|
||||
if [ -n "$SCTL" ]; then
|
||||
$SCTL disable $SERVICE
|
||||
return $?
|
||||
else
|
||||
URCD=/usr/sbin/update-rc.d
|
||||
if [ -x $URCD ]; then
|
||||
$URCD -f $SERVICE remove
|
||||
else
|
||||
/sbin/chkconfig --del $SERVICE
|
||||
fi
|
||||
return $?
|
||||
fi
|
||||
}
|
||||
|
||||
start_service() {
|
||||
if [ -n "$SCTL" ]; then
|
||||
$SCTL is-active --quiet $SERVICE || $SCTL start $SERVICE
|
||||
return $?
|
||||
else
|
||||
SS=/usr/sbin/service
|
||||
if [ -x /sbin/service ]; then
|
||||
SS=/sbin/service
|
||||
fi
|
||||
$SS $SERVICE start
|
||||
return $?
|
||||
fi
|
||||
}
|
||||
|
||||
status_service() {
|
||||
if [ -n "$SCTL" ]; then
|
||||
$SCTL status $SERVICE
|
||||
return $?
|
||||
else
|
||||
SS=/usr/sbin/service
|
||||
if [ -x /sbin/service ]; then
|
||||
SS=/sbin/service
|
||||
fi
|
||||
$SS $SERVICE status
|
||||
return $?
|
||||
fi
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
if [ -n "$SCTL" ]; then
|
||||
$SCTL stop $SERVICE
|
||||
return $?
|
||||
else
|
||||
SS=/usr/sbin/service
|
||||
if [ -x /sbin/service ]; then
|
||||
SS=/sbin/service
|
||||
fi
|
||||
$SS $SERVICE stop
|
||||
return $?
|
||||
fi
|
||||
}
|
||||
|
||||
condrestart_service() {
|
||||
if [ -n "$SCTL" ]; then
|
||||
if $SCTL 1>/dev/null 2>/dev/null; then
|
||||
$SCTL condrestart $SERVICE
|
||||
return $?
|
||||
fi
|
||||
else
|
||||
SS=/usr/sbin/service
|
||||
if [ -x /sbin/service ]; then
|
||||
SS=/sbin/service
|
||||
fi
|
||||
$SS $SERVICE condrestart
|
||||
return $?
|
||||
fi
|
||||
}
|
||||
|
||||
service() {
|
||||
if [ ! -f ${DEFCONFIG} ]; then
|
||||
echo "Default database not found. Use $0 initdb to create it" 2>&1
|
||||
if [ "$1" = "enable" ]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
SCTL=""
|
||||
# shellcheck disable=2166
|
||||
if [ -d "/run/systemd/system" -a -x "/bin/systemctl" ]; then
|
||||
SCTL=/bin/systemctl
|
||||
fi
|
||||
export SCTL
|
||||
cmd=$1
|
||||
shift
|
||||
case "${cmd}" in
|
||||
start|stop|enable|disable|status|condrestart)
|
||||
"${cmd}_service" "$@"
|
||||
|
||||
;;
|
||||
*)
|
||||
echo >&2 "$USAGE_STRING"
|
||||
exit 2
|
||||
esac
|
||||
}
|
||||
|
||||
command="$1"
|
||||
shift
|
||||
|
||||
case "$command" in
|
||||
initdb)
|
||||
# We want wordsplitting here
|
||||
# shellcheck disable=SC2086
|
||||
initdb "$@" $PGSETUP_INITDB_OPTIONS || exit 1
|
||||
;;
|
||||
find-free-port)
|
||||
find_free_port "$@" || exit 1
|
||||
;;
|
||||
set-server-port)
|
||||
set_server_port "$@" || exit 1
|
||||
;;
|
||||
service)
|
||||
service "$@" || exit 1
|
||||
;;
|
||||
set)
|
||||
set_conf_value "$@" || exit 1
|
||||
;;
|
||||
psql)
|
||||
if [ ! -f "$PGDATA/postgresql.conf" ]; then
|
||||
echo "Database in $PGDATA not found. Do you need pg-setup initdb first?" 1>&2
|
||||
exit 1;
|
||||
fi
|
||||
PORT=$(sed -n 's/^port[ ]*=[ ]*\([0-9]\+\)/\1/p' "$PGDATA/postgresql.conf")
|
||||
$SU -l postgres -c "exec ${BINDIR}/psql ${PORT:+-p ${PORT}} $*"
|
||||
;;
|
||||
*)
|
||||
echo >&2 "$USAGE_STRING"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
143
postgrespro.init.in
Executable file
143
postgrespro.init.in
Executable file
|
@ -0,0 +1,143 @@
|
|||
#!/bin/sh
|
||||
# Start/stop the Postgres Pro @EDITION@ database server.
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: postgrespro-@EDITION@-@VERSION@
|
||||
# Required-Start: $local_fs $remote_fs $network $time
|
||||
# Required-Stop: $local_fs $remote_fs $network $time
|
||||
# Should-Start: $syslog
|
||||
# Should-Stop: $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Postgres Pro database server
|
||||
### END INIT INFO
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
NAME=postgrespro-@EDITION@-@VERSION@
|
||||
|
||||
# For SELinux we need to use 'runuser' not 'su'
|
||||
if [ -x /sbin/runuser ]
|
||||
then
|
||||
SU=runuser
|
||||
else
|
||||
SU=su
|
||||
fi
|
||||
|
||||
# Set defaults for configuration variables
|
||||
BINDIR=@BINDIR@
|
||||
PGDATA=/var/lib/pgpro/@EDITION@-@VERSION@/data
|
||||
lockfile=/var/run/${NAME}.lock
|
||||
pidfile="/var/run/${NAME}.pid"
|
||||
# Override defaults from /etc/default/${NAME} if file is present
|
||||
DEFCONFIG=/etc/default/${NAME}
|
||||
PG_OOM_ADJUST_VALUE=0
|
||||
PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
|
||||
export PG_OOM_ADJUST_FILE PG_OOM_ADJUST_VALUE
|
||||
# shellcheck disable=SC1090
|
||||
[ -f $DEFCONFIG ] && . $DEFCONFIG
|
||||
export PG_OOM_AJUST_VALUE
|
||||
PGLOG="$(dirname "$PGDATA")/pgstartup-$(basename "$PGDATA").log"
|
||||
export PGDATA
|
||||
|
||||
script_result=0
|
||||
|
||||
start(){
|
||||
$SU -l postgres -c "${BINDIR}/check-db-dir $PGDATA"
|
||||
|
||||
echo -n "Starting ${NAME} service" "postgrespro-@EDITION@-@VERSION@"
|
||||
echo -1000 > "$PG_OOM_ADJUST_FILE"
|
||||
$SU -l postgres -c "PG_OOM_ADJUST_FILE=$PG_OOM_ADJUST_FILE PG_OOM_ADJUST_VALUE=$PG_OOM_ADJUST_VALUE _ADJPATH=@BINDIR@:/usr/bin:/usr/sbin:/bin:/sbin ${BINDIR}/postmaster -D '$PGDATA' ${PGOPTS} &" >> "$PGLOG" 2>&1 < /dev/null
|
||||
sleep 2
|
||||
pid=$(head -n 1 "$PGDATA/postmaster.pid" 2>/dev/null)
|
||||
if [ "x$pid" != x ]
|
||||
then
|
||||
if kill -0 "$pid"; then
|
||||
log_success_msg OK
|
||||
else
|
||||
log_failure_msg FAILED
|
||||
fi
|
||||
touch "$lockfile"
|
||||
echo "$pid" > "$pidfile"
|
||||
echo
|
||||
else
|
||||
log_failure_msg FAILED
|
||||
script_result=1
|
||||
fi
|
||||
}
|
||||
|
||||
stop(){
|
||||
echo -n "Stopping ${NAME} service" "postgrespro-@EDITION@-@VERSION@"
|
||||
if [ -e "$lockfile" ]
|
||||
then
|
||||
|
||||
$SU -l postgres -c "${BINDIR}/pg_ctl stop -D '$PGDATA' -s -m fast" > /dev/null 2>&1 < /dev/null
|
||||
ret=$?
|
||||
if [ $ret -eq 0 ]
|
||||
then
|
||||
log_success_msg STOPPED
|
||||
rm -f "$pidfile"
|
||||
rm -f "$lockfile"
|
||||
else
|
||||
log_failure_msg FAILED
|
||||
script_result=1
|
||||
fi
|
||||
else
|
||||
# not running; per LSB standards this is "ok"
|
||||
log_success_msg OK
|
||||
fi
|
||||
echo
|
||||
}
|
||||
|
||||
restart(){
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
condrestart(){
|
||||
# shellcheck disable=SC2015
|
||||
[ -e "$lockfile" ] && restart || :
|
||||
}
|
||||
|
||||
reload(){
|
||||
$SU -l postgres -c "${BINDIR}/pg_ctl reload -D '$PGDATA' -s" > /dev/null 2>&1 < /dev/null
|
||||
}
|
||||
|
||||
promote(){
|
||||
$SU -l postgres -c "${BINDIR}/pg_ctl promote -D '$PGDATA' -s" > /dev/null 2>&1 < /dev/null
|
||||
}
|
||||
|
||||
# See how we were called.
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
status)
|
||||
$SU -l postgres -c "${BINDIR}/pg_ctl status -D '$PGDATA'"
|
||||
script_result=$?
|
||||
;;
|
||||
restart)
|
||||
restart
|
||||
;;
|
||||
promote)
|
||||
promote
|
||||
;;
|
||||
condrestart|try-restart)
|
||||
condrestart
|
||||
;;
|
||||
reload)
|
||||
reload
|
||||
;;
|
||||
force-reload)
|
||||
restart
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|promote}"
|
||||
exit 2
|
||||
esac
|
||||
|
||||
exit $script_result
|
3
postgrespro.pam
Executable file
3
postgrespro.pam
Executable file
|
@ -0,0 +1,3 @@
|
|||
#%PAM-1.0
|
||||
auth include password-auth
|
||||
account include password-auth
|
49
postgrespro.service.in
Normal file
49
postgrespro.service.in
Normal file
|
@ -0,0 +1,49 @@
|
|||
# It's not recommended to modify this file in-place, because it will be
|
||||
# overwritten during package upgrades. If you want to customize, the
|
||||
# best way is to create a file "/etc/systemd/system/postgrespro-10.service",
|
||||
# containing
|
||||
# .include /lib/systemd/system/postgrespro-10.service
|
||||
# ...make your changes here...
|
||||
# For more info about custom unit files, see
|
||||
# http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F
|
||||
|
||||
# Note: changing PGDATA will typically require adjusting SELinux
|
||||
# configuration as well.
|
||||
|
||||
# Note: do not use a PGDATA pathname containing spaces, or you will
|
||||
# break pg-setup.
|
||||
[Unit]
|
||||
Description=Postgres Pro @EDITION@ @VERSION@ database server
|
||||
After=syslog.target
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=notify
|
||||
|
||||
User=postgres
|
||||
Group=postgres
|
||||
|
||||
OOMScoreAdjust=-1000
|
||||
Environment=PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
|
||||
Environment=PG_OOM_ADJUST_VALUE=0
|
||||
Environment=PATH=@BINDIR@:/usr/sbin:/usr/bin:/bin:/sbin
|
||||
# Location of database directory
|
||||
EnvironmentFile=/etc/default/postgrespro-@EDITION@-@VERSION@
|
||||
|
||||
# Where to send early-startup messages from the server (before the logging
|
||||
# options of postgresql.conf take effect)
|
||||
# This is normally controlled by the global default set by systemd
|
||||
# StandardOutput=syslog
|
||||
|
||||
# Disable OOM kill on the postmaster
|
||||
ExecStartPre=@BINDIR@/check-db-dir ${PGDATA}
|
||||
ExecStart=@BINDIR@/postgres -D ${PGDATA}
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
KillMode=mixed
|
||||
KillSignal=SIGINT
|
||||
|
||||
# Give a reasonable amount of time for the server to start up/shut down
|
||||
TimeoutSec=300
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
2000
postgrespro.spec
Normal file
2000
postgrespro.spec
Normal file
File diff suppressed because it is too large
Load diff
18
small.conf.sample
Normal file
18
small.conf.sample
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Version: 9.6
|
||||
# OS Type: linux
|
||||
# DB Type: oltp
|
||||
# Total Memory (RAM): 4 GB
|
||||
# Number of Connections: 20
|
||||
|
||||
max_connections = 20
|
||||
shared_buffers = 1GB
|
||||
effective_cache_size = 3GB
|
||||
work_mem = 52428kB
|
||||
maintenance_work_mem = 256MB
|
||||
min_wal_size = 2GB
|
||||
max_wal_size = 4GB
|
||||
checkpoint_completion_target = 0.9
|
||||
wal_buffers = 16MB
|
||||
default_statistics_target = 100
|
||||
|
||||
|
Loading…
Add table
Reference in a new issue