pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Question about servicescript for stopping and starting postgresql instance
6+ messages / 2 participants
[nested] [flat]

* Question about servicescript for stopping and starting postgresql instance
@ 2018-10-30 12:09  Marian Forums <marianforums@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Marian Forums @ 2018-10-30 12:09 UTC (permalink / raw)
  To: pgsql-general

Hi,

I have a question about creating a service script to start/stop/status
postgresql instance ( version 9.6.8) on Red Hat 7.

I have read the explanation of how to create such a service script on
https://www.postgresql.org/docs/9.6/static/server-start.html .

Stopping and Starting works.
However when I stop the service with:
systemctl stop postgresq.service and than ask for the status with systemctl
status postgresql.service, the service gets started again.

Is this normal functionality on Red Hat 7?
I have searched on the Internet ( including the Red Hat site) for a
parameter to replace this behavior, but did not find anything.

Your help is much appreciated.
Thanks in advance.
Regards,
Marian

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Question about servicescript for stopping and starting postgresql instance
@ 2018-10-30 13:29  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Marian Forums <marianforums@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Adrian Klaver @ 2018-10-30 13:29 UTC (permalink / raw)
  To: Marian Forums <marianforums@gmail.com>; pgsql-general

On 10/30/18 5:09 AM, Marian Forums wrote:
> Hi,
> 
> I have a question about creating a service script to start/stop/status 
> postgresql instance ( version 9.6.8) on Red Hat 7.

How did you install Postgres on the machine?

> 
> I have read the explanation of how to create such a service script on 
> https://www.postgresql.org/docs/9.6/static/server-start.html .

Did you use the example at the above link or did you write your own?

If you wrote your own can you show it?


> 
> Stopping and Starting works.
> However when I stop the service with:
> systemctl stop postgresq.service and than ask for the status with 
> systemctl status postgresql.service, the service gets started again.
> 
> Is this normal functionality on Red Hat 7?
> I have searched on the Internet ( including the Red Hat site) for a 
> parameter to replace this behavior, but did not find anything.
> 
> Your help is much appreciated.
> Thanks in advance.
> Regards,
> Marian


-- 
Adrian Klaver
adrian.klaver@aklaver.com




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Question about servicescript for stopping and starting postgresql instance
@ 2018-10-30 16:27  Marian Forums <marianforums@gmail.com>
  parent: Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Marian Forums @ 2018-10-30 16:27 UTC (permalink / raw)
  To: adrian.klaver@aklaver.com; +Cc: pgsql-general

Hi Adrain,
Thanks for your reply.
My script looks like this:
# cat /usr/lib/systemd/system/postgresql-9.6.pg-tstxxx.service
[Unit]
Description=postgresql_pg-tstxxx
After=syslog.target
After=network.target

[Service]
Type=forking
User=postgresql
Group=postgresqlg
Environment=PGDATA=/data/pg-tstxxx/data-01/
# Run ExecStartPre with root-permissions
PermissionsStartOnly=true
ExecStartPre=/bin/chown postgresql:postgresqlgroup /var/run/postgresql
ExecStart=/usr/pgsql-9.6/bin/pg_ctl start -D ${PGDATA}
ExecStop=/usr/pgsql-9.6/bin/pg_ctl stop -D ${PGDATA} -s -m fast
ExecReload=/usr/pgsql-9.6/bin/pg_ctl reload -D ${PGDATA} -s
Restart=on-failure
KillMode=control-group
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s

[Install]
WantedBy=multi-user.target

thanks in advance.
regards,
Marian

Op di 30 okt. 2018 om 14:30 schreef Adrian Klaver <adrian.klaver@aklaver.com
>:

> On 10/30/18 5:09 AM, Marian Forums wrote:
> > Hi,
> >
> > I have a question about creating a service script to start/stop/status
> > postgresql instance ( version 9.6.8) on Red Hat 7.
>
> How did you install Postgres on the machine?
>
> >
> > I have read the explanation of how to create such a service script on
> > https://www.postgresql.org/docs/9.6/static/server-start.html .
>
> Did you use the example at the above link or did you write your own?
>
> If you wrote your own can you show it?
>
>
> >
> > Stopping and Starting works.
> > However when I stop the service with:
> > systemctl stop postgresq.service and than ask for the status with
> > systemctl status postgresql.service, the service gets started again.
> >
> > Is this normal functionality on Red Hat 7?
> > I have searched on the Internet ( including the Red Hat site) for a
> > parameter to replace this behavior, but did not find anything.
> >
> > Your help is much appreciated.
> > Thanks in advance.
> > Regards,
> > Marian
>
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com
>

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Question about servicescript for stopping and starting postgresql instance
@ 2018-10-30 20:56  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Marian Forums <marianforums@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Adrian Klaver @ 2018-10-30 20:56 UTC (permalink / raw)
  To: Marian Forums <marianforums@gmail.com>; +Cc: pgsql-general

On 10/30/18 9:27 AM, Marian Forums wrote:
> Hi Adrain,
> Thanks for your reply.


How was Postgres installed on this machine?

Have you tried the script from the docs?


> My script looks like this:

I am no systemd expert, still the Type=forking does not seem right to me.

> # cat /usr/lib/systemd/system/postgresql-9.6.pg-tstxxx.service
> [Unit]
> Description=postgresql_pg-tstxxx
> After=syslog.target
> After=network.target
> 
> [Service]
> Type=forking
> User=postgresql
> Group=postgresqlg
> Environment=PGDATA=/data/pg-tstxxx/data-01/
> # Run ExecStartPre with root-permissions
> PermissionsStartOnly=true
> ExecStartPre=/bin/chown postgresql:postgresqlgroup /var/run/postgresql
> ExecStart=/usr/pgsql-9.6/bin/pg_ctl start -D ${PGDATA}
> ExecStop=/usr/pgsql-9.6/bin/pg_ctl stop -D ${PGDATA} -s -m fast
> ExecReload=/usr/pgsql-9.6/bin/pg_ctl reload -D ${PGDATA} -s
> Restart=on-failure
> KillMode=control-group
> ExecStop=/bin/kill -SIGTERM $MAINPID
> RestartSec=10s
> 
> [Install]
> WantedBy=multi-user.target
> 
> thanks in advance.
> regards,
> Marian
> 
> Op di 30 okt. 2018 om 14:30 schreef Adrian Klaver 
> <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>>:
> 
>     On 10/30/18 5:09 AM, Marian Forums wrote:
>      > Hi,
>      >
>      > I have a question about creating a service script to
>     start/stop/status
>      > postgresql instance ( version 9.6.8) on Red Hat 7.
> 
>     How did you install Postgres on the machine?
> 
>      >
>      > I have read the explanation of how to create such a service
>     script on
>      > https://www.postgresql.org/docs/9.6/static/server-start.html .
> 
>     Did you use the example at the above link or did you write your own?
> 
>     If you wrote your own can you show it?
> 
> 
>      >
>      > Stopping and Starting works.
>      > However when I stop the service with:
>      > systemctl stop postgresq.service and than ask for the status with
>      > systemctl status postgresql.service, the service gets started again.
>      >
>      > Is this normal functionality on Red Hat 7?
>      > I have searched on the Internet ( including the Red Hat site) for a
>      > parameter to replace this behavior, but did not find anything.
>      >
>      > Your help is much appreciated.
>      > Thanks in advance.
>      > Regards,
>      > Marian
> 
> 
>     -- 
>     Adrian Klaver
>     adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Question about servicescript for stopping and starting postgresql instance
@ 2018-10-30 21:09  Marian Forums <marianforums@gmail.com>
  parent: Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Marian Forums @ 2018-10-30 21:09 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: pgsql-general



Hi,
Postgres was installed through a repo with yum install.
I will try to run it with another type.
Regards
Marian

> Op 30 okt. 2018 om 21:56 heeft Adrian Klaver <adrian.klaver@aklaver.com> het volgende geschreven:
> 
>> On 10/30/18 9:27 AM, Marian Forums wrote:
>> Hi Adrain,
>> Thanks for your reply.
> 
> 
> How was Postgres installed on this machine?
> 
> Have you tried the script from the docs?
> 
> 
>> My script looks like this:
> 
> I am no systemd expert, still the Type=forking does not seem right to me.
> 
>> # cat /usr/lib/systemd/system/postgresql-9.6.pg-tstxxx.service
>> [Unit]
>> Description=postgresql_pg-tstxxx
>> After=syslog.target
>> After=network.target
>> [Service]
>> Type=forking
>> User=postgresql
>> Group=postgresqlg
>> Environment=PGDATA=/data/pg-tstxxx/data-01/
>> # Run ExecStartPre with root-permissions
>> PermissionsStartOnly=true
>> ExecStartPre=/bin/chown postgresql:postgresqlgroup /var/run/postgresql
>> ExecStart=/usr/pgsql-9.6/bin/pg_ctl start -D ${PGDATA}
>> ExecStop=/usr/pgsql-9.6/bin/pg_ctl stop -D ${PGDATA} -s -m fast
>> ExecReload=/usr/pgsql-9.6/bin/pg_ctl reload -D ${PGDATA} -s
>> Restart=on-failure
>> KillMode=control-group
>> ExecStop=/bin/kill -SIGTERM $MAINPID
>> RestartSec=10s
>> [Install]
>> WantedBy=multi-user.target
>> thanks in advance.
>> regards,
>> Marian
>> Op di 30 okt. 2018 om 14:30 schreef Adrian Klaver <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>>:
>>    On 10/30/18 5:09 AM, Marian Forums wrote:
>>     > Hi,
>>     >
>>     > I have a question about creating a service script to
>>    start/stop/status
>>     > postgresql instance ( version 9.6.8) on Red Hat 7.
>>    How did you install Postgres on the machine?
>>     >
>>     > I have read the explanation of how to create such a service
>>    script on
>>     > https://www.postgresql.org/docs/9.6/static/server-start.html .
>>    Did you use the example at the above link or did you write your own?
>>    If you wrote your own can you show it?
>>     >
>>     > Stopping and Starting works.
>>     > However when I stop the service with:
>>     > systemctl stop postgresq.service and than ask for the status with
>>     > systemctl status postgresql.service, the service gets started again.
>>     >
>>     > Is this normal functionality on Red Hat 7?
>>     > I have searched on the Internet ( including the Red Hat site) for a
>>     > parameter to replace this behavior, but did not find anything.
>>     >
>>     > Your help is much appreciated.
>>     > Thanks in advance.
>>     > Regards,
>>     > Marian
>>    --     Adrian Klaver
>>    adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
> 
> 
> -- 
> Adrian Klaver
> adrian.klaver@aklaver.com




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Question about servicescript for stopping and starting postgresql instance
@ 2018-10-30 21:11  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Marian Forums <marianforums@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Adrian Klaver @ 2018-10-30 21:11 UTC (permalink / raw)
  To: Marian Forums <marianforums@gmail.com>; +Cc: pgsql-general

On 10/30/18 2:09 PM, Marian Forums wrote:
> 
> 
> Hi,
> Postgres was installed through a repo with yum install.

So did you disable the start/stop scripts that the package installed?

> I will try to run it with another type.
> Regards
> Marian
> 
>> Op 30 okt. 2018 om 21:56 heeft Adrian Klaver <adrian.klaver@aklaver.com> het volgende geschreven:
>>
>>> On 10/30/18 9:27 AM, Marian Forums wrote:
>>> Hi Adrain,
>>> Thanks for your reply.
>>
>>
>> How was Postgres installed on this machine?
>>
>> Have you tried the script from the docs?
>>
>>
>>> My script looks like this:
>>
>> I am no systemd expert, still the Type=forking does not seem right to me.
>>
>>> # cat /usr/lib/systemd/system/postgresql-9.6.pg-tstxxx.service
>>> [Unit]
>>> Description=postgresql_pg-tstxxx
>>> After=syslog.target
>>> After=network.target
>>> [Service]
>>> Type=forking
>>> User=postgresql
>>> Group=postgresqlg
>>> Environment=PGDATA=/data/pg-tstxxx/data-01/
>>> # Run ExecStartPre with root-permissions
>>> PermissionsStartOnly=true
>>> ExecStartPre=/bin/chown postgresql:postgresqlgroup /var/run/postgresql
>>> ExecStart=/usr/pgsql-9.6/bin/pg_ctl start -D ${PGDATA}
>>> ExecStop=/usr/pgsql-9.6/bin/pg_ctl stop -D ${PGDATA} -s -m fast
>>> ExecReload=/usr/pgsql-9.6/bin/pg_ctl reload -D ${PGDATA} -s
>>> Restart=on-failure
>>> KillMode=control-group
>>> ExecStop=/bin/kill -SIGTERM $MAINPID
>>> RestartSec=10s
>>> [Install]
>>> WantedBy=multi-user.target
>>> thanks in advance.
>>> regards,
>>> Marian
>>> Op di 30 okt. 2018 om 14:30 schreef Adrian Klaver <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>>:
>>>     On 10/30/18 5:09 AM, Marian Forums wrote:
>>>      > Hi,
>>>      >
>>>      > I have a question about creating a service script to
>>>     start/stop/status
>>>      > postgresql instance ( version 9.6.8) on Red Hat 7.
>>>     How did you install Postgres on the machine?
>>>      >
>>>      > I have read the explanation of how to create such a service
>>>     script on
>>>      > https://www.postgresql.org/docs/9.6/static/server-start.html .
>>>     Did you use the example at the above link or did you write your own?
>>>     If you wrote your own can you show it?
>>>      >
>>>      > Stopping and Starting works.
>>>      > However when I stop the service with:
>>>      > systemctl stop postgresq.service and than ask for the status with
>>>      > systemctl status postgresql.service, the service gets started again.
>>>      >
>>>      > Is this normal functionality on Red Hat 7?
>>>      > I have searched on the Internet ( including the Red Hat site) for a
>>>      > parameter to replace this behavior, but did not find anything.
>>>      >
>>>      > Your help is much appreciated.
>>>      > Thanks in advance.
>>>      > Regards,
>>>      > Marian
>>>     --     Adrian Klaver
>>>     adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
>>
>>
>> -- 
>> Adrian Klaver
>> adrian.klaver@aklaver.com


-- 
Adrian Klaver
adrian.klaver@aklaver.com




^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2018-10-30 21:11 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-10-30 12:09 Question about servicescript for stopping and starting postgresql instance Marian Forums <marianforums@gmail.com>
2018-10-30 13:29 ` Adrian Klaver <adrian.klaver@aklaver.com>
2018-10-30 16:27   ` Marian Forums <marianforums@gmail.com>
2018-10-30 20:56     ` Adrian Klaver <adrian.klaver@aklaver.com>
2018-10-30 21:09       ` Marian Forums <marianforums@gmail.com>
2018-10-30 21:11         ` Adrian Klaver <adrian.klaver@aklaver.com>

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