pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Bryce Pepper <BPepper@KCSouthern.com>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: RHEL 7 (systemd) reboot
Date: Wed, 10 Oct 2018 12:10:23 -0700
Message-ID: <711aa192-9733-8a4c-90a1-46b40876fad9@aklaver.com> (raw)
In-Reply-To: <b8db64244cf74bcc989502fb46e8ac97@WNEXMBFEP03.KCSCP.CORP>
References: <49f8b4546d9948d798d81e1fd32bfb4f@WNEXMBFEP03.KCSCP.CORP>
	<532b0c39-6b76-658f-fe45-852dd964d7ba@aklaver.com>
	<5de197dc0e9241c59caad6cb3f69ef25@WNEXMBFEP03.KCSCP.CORP>
	<5c30d3c8-ddd0-452c-a667-cb1356c10c47@aklaver.com>
	<b8db64244cf74bcc989502fb46e8ac97@WNEXMBFEP03.KCSCP.CORP>

On 10/10/18 7:37 AM, Bryce Pepper wrote:
> Sorry, I wasn't clear in the prior posts.
> 
> The stop script is running during reboot. The problem is the database is not reachable when the stop script runs.  The ctmdist server shut down is as follows:
>     Stop control-m application
>     Stop control-m configuration agent
>     Stop database

Several things:

1) In your OP there was this:

Oct 05 14:18:56 kccontrolmt01 network[29310]: Shutting down interface 
eth0:  Device 'eth0' successfully disconnected.

Oct 05 14:18:56 kccontrolmt01 network[29310]: [  OK  ]

Oct 05 14:18:56 kccontrolmt01 stop_ctmlinux_server.sh[29185]: 
------------------------

Oct 05 14:18:56 kccontrolmt01 stop_ctmlinux_server.sh[29185]: Shutting 
down CONTROL-M.

So is your Postgres instance running on the same machine as the CTM 
instance or does the eth0 need to be up to reach the database?

2) In the above there is:
"Shutting down CONTROL-M."

Yet in script below there is:
"Stopping CONTROL-M application"

Is this because there are sub-scripts involved or the "Stopping ..." is 
embedded in the script?

3) I am by no means a shell script expert and I will admit to not fully 
understanding what control-m_shutdown.sh does. Still here it goes:

a) Are there actually two shebangs in one file or are there two files 
involved?

b) What is:

# stop database
/data00/ctmlinux/ctm_server/scripts/dbversion
if [ $? -ne 0 ] ; then
   echo "SQL Server is already stopped "
else
   if [ -f /data00/ctmlinux/ctm_server/scripts/shutdb ]; then
     echo "Stopping SQL server for CONTROL-M"
     /data00/ctmlinux/ctm_server/scripts/shutdb
   fi

actually doing?

I ask because from what I can see there are a set of parallel processes 
initiated and it is possible that the database server is winning. It 
comes down to what 'if [ $? -ne 0 ]' is testing.



> 
> As you can see the intent is for the database to be shut down after the product.
> 
> But as you noticed from /var/log/message the stop_ctmlinux_server.sh  script is running but unable to execute the update query.
> 
> I created the following Service definition and scripts that follow -- note there are 2 datacenters (ctmdist, ctmlinux) that have comparable scripts so I have only included one set:
> 
> [root@kccontrolmt01 ~]# cat ControlM_Shutdown.service
> [Unit]
> Description=Run mycommand at shutdown
> Requires=network.target CTM_Postgre.service
> DefaultDependencies=no
> Before=shutdown.target reboot.target
> 
> [Service]
> Type=oneshot
> RemainAfterExit=true
> ExecStart=/bin/true
> ExecStop=/root/scripts/control-m_shutdown.sh
> 
> [Install]
> WantedBy=multi-user.target
> 
> 
> [root@kccontrolmt01 ~]# cat /root/scripts/control-m_shutdown.sh
> #!/bin/sh
>    # Shutdown any running Control-M services
>      STATUS=$(/usr/bin/systemctl is-active CTMLinux_Server.service)
>      if [ ${STATUS} == "active" ]; then
>        /usr/bin/systemctl stop CTMLinux_Server.service
>      fi
> 
>      STATUS=$(/usr/bin/systemctl is-active CTMDist_Server.service)
>      if [ ${STATUS} == "active" ]; then
>        /usr/bin/systemctl stop CTMDist_Server.service
>      fi
> 
>      STATUS=$(/usr/bin/systemctl is-active EnterpriseManager.service)
>      if [ ${STATUS} == "active" ]; then
>        /usr/bin/systemctl stop EnterpriseManager.service
>      fi
> exit 0
> 
> 
> #!/bin/bash
> 
> # stop CONTROL-M
> if [ -f /data00/ctmlinux/ctm_server/scripts/shut_ctm ]; then
>    echo "Stopping CONTROL-M application"
>    /data00/ctmlinux/ctm_server/scripts/shut_ctm
> fi
> 
> # stop CONTROL-M Configuration Agent
> if [ -f /data00/ctmlinux/ctm_server/scripts/shut_ca ]; then
>    echo "Stopping CONTROL-M Server Configuration Agent"
>    /data00/ctmlinux/ctm_server/scripts/shut_ca
> fi
> 
> # stop database
> /data00/ctmlinux/ctm_server/scripts/dbversion
> if [ $? -ne 0 ] ; then
>    echo "SQL Server is already stopped "
> else
>    if [ -f /data00/ctmlinux/ctm_server/scripts/shutdb ]; then
>      echo "Stopping SQL server for CONTROL-M"
>      /data00/ctmlinux/ctm_server/scripts/shutdb
>    fi
> fi
> 
> exit 0
> 



-- 
Adrian Klaver
adrian.klaver@aklaver.com




view thread (13+ messages)  latest in thread

Message-ID: <711aa192-9733-8a4c-90a1-46b40876fad9@aklaver.com>
Permalink:  ../711aa192-9733-8a4c-90a1-46b40876fad9@aklaver.com/
Also on:    postgresql.org/message-id/711aa192-9733-8a4c-90a1-46b40876fad9@aklaver.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: adrian.klaver@aklaver.com, BPepper@KCSouthern.com
  Subject: Re: RHEL 7 (systemd) reboot
  In-Reply-To: <711aa192-9733-8a4c-90a1-46b40876fad9@aklaver.com>
  References: <49f8b4546d9948d798d81e1fd32bfb4f@WNEXMBFEP03.KCSCP.CORP> <532b0c39-6b76-658f-fe45-852dd964d7ba@aklaver.com> <5de197dc0e9241c59caad6cb3f69ef25@WNEXMBFEP03.KCSCP.CORP> <5c30d3c8-ddd0-452c-a667-cb1356c10c47@aklaver.com> <b8db64244cf74bcc989502fb46e8ac97@WNEXMBFEP03.KCSCP.CORP> <711aa192-9733-8a4c-90a1-46b40876fad9@aklaver.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