pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rich Shepard <rshepard@appl-ecosys.com>
To: pgsql-general@postgresql.org
Subject: Re: Need to fix one more glitch in upgrade to -10.2
Date: Sat, 17 Feb 2018 14:25:06 -0800 (PST)
Message-ID: <alpine.LNX.2.20.1802171424460.19982@salmo.appl-ecosys.com> (raw)

On Sat, 17 Feb 2018, Adrian Klaver wrote:

> How did you upgrade, dump/restore or pg_upgrade?

Adrian,

   Ran 'pg_dumpall -c -f <filename>.sql' prior to doing anything. Then built,
installed the new version, upgraded rc.postgresql (only differences were
version numbers), and ran 'pg_upgrade ...' with the appropriate binary and
data directory paths.

> What is in rc.postgresql? Is there maybe another start script in etc/ for
> the new version?

   Nope. One script per application.

/etc/rc.d/rc.postgresql:

#!/bin/bash

# PostgreSQL startup script for Slackware Linux
#
# $Revision$
# $Date$
#
# Copyright 2007-2018 Adis Nezirovic <adis_at_linux.org.ba>
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Do not source this script (since it contains exit() calls)
#
# Since version 9.3 this startup script can run multiple PostgreSQL
# versions on different ports and with different data dirs.
# # e.g. PG_VERSION=10.2 PG_PORT=6432 /etc/rc.d/rc.@PRGNAM@ start

PG_VERSION=${PG_VERSION:-@PG_VERSION@}
PG_PORT=${PG_PORT:-@PG_PORT@}
LIBDIRSUFFIX="@LIBDIRSUFFIX@"
LOGFILE=/var/log/@PRGNAM@-$PG_VERSION
DATADIR=/var/lib/pgsql/$PG_VERSION/data
POSTGRES=/usr/lib${LIBDIRSUFFIX}/@PRGNAM@/$PG_VERSION/bin/postgres
PG_CTL=/usr/lib${LIBDIRSUFFIX}/@PRGNAM@/$PG_VERSION/bin/pg_ctl
PIDFILE=$DATADIR/postmaster.pid

# oom-killer score
#
# 
http://www.postgresql.org/docs/10.2/static/kernel-resources.html#LINUX-MEMORY-OVERCOMMIT
PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
PG_MASTER_OOM_SCORE_ADJ=-1000
PG_CHILD_OOM_SCORE_ADJ=0
PG_ENV="PG_OOM_ADJUST_FILE=$PG_OOM_ADJUST_FILE 
PG_OOM_ADJUST_VALUE=$PG_CHILD_OOM_SCORE_ADJ"

# Return values (according to LSB):
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running

pg_ctl()
{
 	CMD="$PG_CTL -o '-p $PG_PORT' $@"
 	su - postgres -c "$PG_ENV $CMD"
}

if [ ! -f $POSTGRES ]; then
 	echo "Could not find 'postgres' binary. Maybe PostgreSQL is not 
installed properly?"
 	exit 5
fi

case "$1" in

 	"start")
 		echo "Starting PostgreSQL"
 		touch $LOGFILE
 		chown postgres:wheel $LOGFILE
 		chmod 0640 $LOGFILE

 		if [ ! -e $DATADIR/PG_VERSION ]; then
 			echo "You should initialize the PostgreSQL database at 
location $DATADIR"
 			echo "e.g. su postgres -c \"initdb -D $DATADIR 
--locale=en_US.UTF-8 -A md5 -W\""
 			exit 6
 		fi

 		if [ $(pgrep -f $POSTGRES) ]; then

 			echo "PostgreSQL daemon already running"
 			if [ ! -f $PIDFILE ]; then
 				echo "Warning: Missing pid file $PIDFILE"
 			fi
 			exit 1

 		else
 			test -e "$PG_OOM_ADJUST_FILE" && echo 
"$PG_MASTER_OOM_SCORE_ADJ" > "$PG_OOM_ADJUST_FILE"
 			pg_ctl start -w -l $LOGFILE -D $DATADIR
 			exit 0
 		fi
 	;;

 	"stop")
 		echo "Shutting down PostgreSQL..."
 		pg_ctl stop -l $LOGFILE -D $DATADIR -m smart
 	;;

 	"force-stop")
 		# Take care! This will kill _all_ client connections
 		# and rollback current transactions.
 		echo "Shutting down PostgreSQL (fast)..."
 		pg_ctl stop -l $LOGFILE -D $DATADIR -m fast
 	;;

 	"unclean-stop")
 		# Take care! This will abort server process itself
 		# resulting with database recovery on next start.
 		echo "Shutting down PostgreSQL (immediate)..."
 		pg_ctl stop -l $LOGFILE -D $DATADIR -m immediate
 	;;

 	"restart")
 		echo "Restarting PostgreSQL..."
 		test -e "$PG_OOM_ADJUST_FILE" && echo 
"$PG_MASTER_OOM_SCORE_ADJ" > "$PG_OOM_ADJUST_FILE"
 		pg_ctl restart -l $LOGFILE -D $DATADIR -m smart
 	;;

 	"force-restart")
 		# Take care! This will kill _all_ client connections
 		# and rollback current transactions.
 		echo "Restarting PostgreSQL (fast)..."
 		pg_ctl restart -l $LOGFILE -D $DATADIR -m fast
 	;;

 	"unclean-restart")
 		# Take care: This will abort server process itself
 		# resulting with database recovery on start.
 		echo "Restarting PostgreSQL (immediate)..."
 		pg_ctl restart -l $LOGFILE -D $DATADIR -m immediate
 	;;

 	"reload")
 		echo "Reloading configuration for PostgreSQL..."
 		pg_ctl reload -l $LOGFILE -D $DATADIR -m smart
 	;;

 	"status")
 		if [ $(pgrep -f $POSTGRES) ]; then
 			echo "PostgreSQL is running"

 			if [ ! -e $PIDFILE ]; then
 				echo "Warning: Missing pid file $PIDFILE"
 			fi

 			exit 0
 		else
 			echo "PostgreSQL is stopped"

 			if [ -e $PIDFILE ]; then
 				echo "Detected stale pid file $PIDFILE"
 			fi

 			exit 0
 		fi
 	;;

 	*)
 		# unclean-stop and unclean-restart are not documented on 
purpose.
 		echo "Usage: $0 
{start|stop|force-stop|status|restart|force-restart|reload}"
 		exit 1
 	;;
esac

Regards,

Rich




view thread (22+ messages)  latest in thread

Message-ID: <alpine.LNX.2.20.1802171424460.19982@salmo.appl-ecosys.com>
Permalink:  ../alpine.LNX.2.20.1802171424460.19982@salmo.appl-ecosys.com/
Also on:    postgresql.org/message-id/alpine.LNX.2.20.1802171424460.19982@salmo.appl-ecosys.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: rshepard@appl-ecosys.com
  Subject: Re: Need to fix one more glitch in upgrade to -10.2
  In-Reply-To: <alpine.LNX.2.20.1802171424460.19982@salmo.appl-ecosys.com>
  References: <alpine.LNX.2.20.1802171424460.19982@salmo.appl-ecosys.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox