Thread: Service not starting on Ubuntu 15.04

Service not starting on Ubuntu 15.04

From
Lasse Westh-Nielsen
Date:
Hey,

I posted to stackoverflow about my problem upgrading from Ubuntu 14.04 to Ubuntu 15.04: http://stackoverflow.com/questions/33306475/ubuntu-15-04-postgresql-doesnt-start

Tl;dr: postgresql service does not start properly when installed as a package using cloud-init.

And I can't figure out if I am doing something wrong, if the AMI is no good, if the package has problems, ... I reckon I cannot be the first person to use Postgres on Ubuntu Vivid, but I have been hammering my head against the wall with this for hours.

Any help greatly appreciated!

Regards,

Lasse


Re: Service not starting on Ubuntu 15.04

From
Bill Moran
Date:
On Mon, 26 Oct 2015 11:21:23 +0000
Lasse Westh-Nielsen <lassewesth@gmail.com> wrote:
>
> I posted to stackoverflow about my problem upgrading from Ubuntu 14.04 to
> Ubuntu 15.04:
> http://stackoverflow.com/questions/33306475/ubuntu-15-04-postgresql-doesnt-start
>
> Tl;dr: postgresql service does not start properly when installed as a
> package using cloud-init.
>
> And I can't figure out if I am doing something wrong, if the AMI is no
> good, if the package has problems, ... I reckon I cannot be the first
> person to use Postgres on Ubuntu Vivid, but I have been hammering my head
> against the wall with this for hours.
>
> Any help greatly appreciated!

I'm taking a shot in the dark here, but ...

The symptoms you describe seem to suggest that the script is starting
PostgreSQL asynchronously (i.e. in the background) which means that
the CREATE command runs too quickly and the server isn't started yet.

A quick way to _test_ this theory would be to put a sleep between the
install and the CREATE commands and see if the problem goes away.

If that does seem to be the problem, then a good _fix_ would be to
find a way to foreground the startup of the server, or have some command
that tests to ensure the server is started and blocks until it is
before running the create command.

The only point I'm unclear on is whether you've confirmed that
Postgres actually _is_ started once the server is up (albiet without
the CREATE statement having succeeded).

--
Bill Moran


Re: Service not starting on Ubuntu 15.04

From
Adrian Klaver
Date:
On 10/26/2015 04:21 AM, Lasse Westh-Nielsen wrote:
> Hey,
>
> I posted to stackoverflow about my problem upgrading from Ubuntu 14.04
> to Ubuntu 15.04:
> http://stackoverflow.com/questions/33306475/ubuntu-15-04-postgresql-doesnt-start

Pretty sure it is no coincidence that the 14.04 --> 15.04 upgrade
changes the init process from Upstart to systemd. Might want to take a
look at this article:

http://linux.softpedia.com/blog/Ubuntu-15-04-Users-Can-Switch-Off-Systemd-and-Use-Upstart-479373.shtml

and this:

https://wiki.ubuntu.com/SystemdForUpstartUsers


>
> Tl;dr: postgresql service does not start properly when installed as a
> package using cloud-init.

What does the /var/log/bootstrap.log show?

>
> And I can't figure out if I am doing something wrong, if the AMI is no
> good, if the package has problems, ... I reckon I cannot be the first
> person to use Postgres on Ubuntu Vivid, but I have been hammering my
> head against the wall with this for hours.
>
> Any help greatly appreciated!
>
> Regards,
>
> Lasse
>
>


--
Adrian Klaver
adrian.klaver@aklaver.com


Re: Service not starting on Ubuntu 15.04

From
Lasse Westh-Nielsen
Date:
Bill,

Thanks for your help. But I have already tried with a variant that gives the postgres service time to do what it needs to do:

#!/bin/bash -eux

exec > >(tee /var/log/bootstrap.log)
exec 2>&1

apt-get --quiet --quiet update
apt-get --quiet --quiet upgrade

apt-get install --quiet --quiet postgresql

service postgresql status || true
sleep 10
service postgresql stop
service postgresql status || true
sleep 10
service postgresql start
service postgresql status || true
sleep 10
service postgresql status || true
pstree

sudo -u postgres psql -c "CREATE USER foo WITH PASSWORD 'foo';"

So, output from that:
 - service starts normally, i.e. first call to status says the service is up.
 - sleep-then-stop: now calling status says it has stopped.
 - sleep-more-then-start: status reports service is up again
 - even-more-sleep: status says service is still up
 - however, that last call to pstree finds no trace of postgres

Sleeping 10 seconds came from me running these start and stop commands from command line, where response time seems to be 2-3 seconds for start, meaning 10 seconds should be plenty (and start seems to block, why else would it take 3 seconds).

Thanks anyway,

Lasse




On Mon, Oct 26, 2015 at 12:09 PM, Bill Moran <wmoran@potentialtech.com> wrote:
On Mon, 26 Oct 2015 11:21:23 +0000
Lasse Westh-Nielsen <lassewesth@gmail.com> wrote:
>
> I posted to stackoverflow about my problem upgrading from Ubuntu 14.04 to
> Ubuntu 15.04:
> http://stackoverflow.com/questions/33306475/ubuntu-15-04-postgresql-doesnt-start
>
> Tl;dr: postgresql service does not start properly when installed as a
> package using cloud-init.
>
> And I can't figure out if I am doing something wrong, if the AMI is no
> good, if the package has problems, ... I reckon I cannot be the first
> person to use Postgres on Ubuntu Vivid, but I have been hammering my head
> against the wall with this for hours.
>
> Any help greatly appreciated!

I'm taking a shot in the dark here, but ...

The symptoms you describe seem to suggest that the script is starting
PostgreSQL asynchronously (i.e. in the background) which means that
the CREATE command runs too quickly and the server isn't started yet.

A quick way to _test_ this theory would be to put a sleep between the
install and the CREATE commands and see if the problem goes away.

If that does seem to be the problem, then a good _fix_ would be to
find a way to foreground the startup of the server, or have some command
that tests to ensure the server is started and blocks until it is
before running the create command.

The only point I'm unclear on is whether you've confirmed that
Postgres actually _is_ started once the server is up (albiet without
the CREATE statement having succeeded).

--
Bill Moran

Re: Service not starting on Ubuntu 15.04

From
Lasse Westh-Nielsen
Date:
Adrian,

Thanks. I know about the systemd change, and indeed the postgres package I end up with _has_ systemd integration already:

$ cat /etc/systemd/system/multi-user.target.wants/postgresql.service
# systemd service for managing all PostgreSQL clusters on the system. This
# service is actually a systemd target, but we are using a service since
# targets cannot be reloaded.

[Unit]
Description=PostgreSQL RDBMS

[Service]
Type=oneshot
ExecStart=/bin/true
ExecReload=/bin/true
RemainAfterExit=on

[Install]
WantedBy=multi-user.target


Here are the contents of bootstrap.log; notice I added some checks and waits. As you can see, service stop and start has effect in that calls to status seem to say the service has started and stopped. However, it clearly never starts. Interestingly, the same exact calls to service stop and start _after_ cloud-init has finished will give me a running postgres service.

+ apt-get install --quiet --quiet postgresql
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin: 
Selecting previously unselected package libpq5:amd64.
(Reading database ... 53521 files and directories currently installed.)
Preparing to unpack .../libpq5_9.4.5-0ubuntu0.15.04_amd64.deb ...
Unpacking libpq5:amd64 (9.4.5-0ubuntu0.15.04) ...
Selecting previously unselected package postgresql-client-common.
Preparing to unpack .../postgresql-client-common_166bzr2_all.deb ...
Unpacking postgresql-client-common (166bzr2) ...
Selecting previously unselected package postgresql-client-9.4.
Preparing to unpack .../postgresql-client-9.4_9.4.5-0ubuntu0.15.04_amd64.deb ...
Unpacking postgresql-client-9.4 (9.4.5-0ubuntu0.15.04) ...
Selecting previously unselected package ssl-cert.
Preparing to unpack .../ssl-cert_1.0.35_all.deb ...
Unpacking ssl-cert (1.0.35) ...
Selecting previously unselected package postgresql-common.
Preparing to unpack .../postgresql-common_166bzr2_all.deb ...
Adding 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common'
Unpacking postgresql-common (166bzr2) ...
Selecting previously unselected package postgresql-9.4.
Preparing to unpack .../postgresql-9.4_9.4.5-0ubuntu0.15.04_amd64.deb ...
Unpacking postgresql-9.4 (9.4.5-0ubuntu0.15.04) ...
Selecting previously unselected package postgresql.
Preparing to unpack .../postgresql_9.4+166bzr2_all.deb ...
Unpacking postgresql (9.4+166bzr2) ...
Processing triggers for man-db (2.7.0.2-5) ...
Processing triggers for systemd (219-7ubuntu6) ...
Processing triggers for ureadahead (0.100.0-19) ...
Setting up libpq5:amd64 (9.4.5-0ubuntu0.15.04) ...
Setting up postgresql-client-common (166bzr2) ...
Setting up postgresql-client-9.4 (9.4.5-0ubuntu0.15.04) ...
update-alternatives: using /usr/share/postgresql/9.4/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode
Setting up ssl-cert (1.0.35) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
Setting up postgresql-common (166bzr2) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
Adding user postgres to group ssl-cert

Creating config file /etc/postgresql-common/createcluster.conf with new version

Creating config file /etc/logrotate.d/postgresql-common with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
Setting up postgresql-9.4 (9.4.5-0ubuntu0.15.04) ...
Creating new cluster 9.4/main ...
  config /etc/postgresql/9.4/main
  data   /var/lib/postgresql/9.4/main
  locale en_US.UTF-8
Flags of /var/lib/postgresql/9.4/main set as -------------e-C
  port   5432
update-alternatives: using /usr/share/postgresql/9.4/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
Setting up postgresql (9.4+166bzr2) ...
Processing triggers for libc-bin (2.21-0ubuntu4) ...
Processing triggers for systemd (219-7ubuntu6) ...
Processing triggers for ureadahead (0.100.0-19) ...
+ service postgresql status
● postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
   Active: active (exited) since Mon 2015-10-26 10:57:51 UTC; 3s ago
 Main PID: 7481 (code=exited, status=0/SUCCESS)

Oct 26 10:57:51 ip-10-103-210-147 systemd[1]: Starting PostgreSQL RDBMS...
Oct 26 10:57:51 ip-10-103-210-147 systemd[1]: Started PostgreSQL RDBMS.
Oct 26 10:57:54 ip-10-103-210-147 systemd[1]: Started PostgreSQL RDBMS.
+ sleep 10
+ service postgresql stop
+ service postgresql status
● postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Mon 2015-10-26 10:58:05 UTC; 5ms ago
 Main PID: 7481 (code=exited, status=0/SUCCESS)

Oct 26 10:57:51 ip-10-103-210-147 systemd[1]: Starting PostgreSQL RDBMS...
Oct 26 10:57:51 ip-10-103-210-147 systemd[1]: Started PostgreSQL RDBMS.
Oct 26 10:57:54 ip-10-103-210-147 systemd[1]: Started PostgreSQL RDBMS.
Oct 26 10:58:05 ip-10-103-210-147 systemd[1]: Stopped PostgreSQL RDBMS.
Oct 26 10:58:05 ip-10-103-210-147 systemd[1]: Stopping PostgreSQL RDBMS...
+ true
+ sleep 10
+ service postgresql start
+ service postgresql status
● postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
   Active: active (exited) since Mon 2015-10-26 10:58:15 UTC; 6ms ago
  Process: 7726 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
 Main PID: 7726 (code=exited, status=0/SUCCESS)

Oct 26 10:58:15 ip-10-103-210-147 systemd[1]: Starting PostgreSQL RDBMS...
Oct 26 10:58:15 ip-10-103-210-147 systemd[1]: Started PostgreSQL RDBMS.
+ sleep 10
+ service postgresql status
● postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
   Active: active (exited) since Mon 2015-10-26 10:58:15 UTC; 10s ago
  Process: 7726 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
 Main PID: 7726 (code=exited, status=0/SUCCESS)

Oct 26 10:58:15 ip-10-103-210-147 systemd[1]: Starting PostgreSQL RDBMS...
Oct 26 10:58:15 ip-10-103-210-147 systemd[1]: Started PostgreSQL RDBMS.
+ pstree
systemd-+-accounts-daemon-+-{gdbus}
        |                 `-{gmain}
        |-2*[agetty]
        |-atd
        |-cloud-init-+-part-001-+-part-001---tee
        |            |          `-pstree
        |            `-sh---tee
        |-cron
        |-dbus-daemon
        |-dhclient
        |-irqbalance
        |-polkitd-+-{gdbus}
        |         `-{gmain}
        |-rsyslogd-+-{in:imklog}
        |          |-{in:imuxsock}
        |          `-{rs:main Q:Reg}
        |-sshd---sshd---bash---tail
        |-sshd
        |-systemd---(sd-pam)
        |-systemd-journal
        |-systemd-logind
        |-systemd-timesyn---{sd-resolve}
        `-systemd-udevd
+ sudo -u postgres psql -c 'CREATE USER teamcity WITH PASSWORD '\''teamcity'\'';'
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?


On Mon, Oct 26, 2015 at 1:42 PM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 10/26/2015 04:21 AM, Lasse Westh-Nielsen wrote:
Hey,

I posted to stackoverflow about my problem upgrading from Ubuntu 14.04
to Ubuntu 15.04:
http://stackoverflow.com/questions/33306475/ubuntu-15-04-postgresql-doesnt-start

Pretty sure it is no coincidence that the 14.04 --> 15.04 upgrade changes the init process from Upstart to systemd. Might want to take a look at this article:

http://linux.softpedia.com/blog/Ubuntu-15-04-Users-Can-Switch-Off-Systemd-and-Use-Upstart-479373.shtml

and this:

https://wiki.ubuntu.com/SystemdForUpstartUsers



Tl;dr: postgresql service does not start properly when installed as a
package using cloud-init.

What does the /var/log/bootstrap.log show?



And I can't figure out if I am doing something wrong, if the AMI is no
good, if the package has problems, ... I reckon I cannot be the first
person to use Postgres on Ubuntu Vivid, but I have been hammering my
head against the wall with this for hours.

Any help greatly appreciated!

Regards,

Lasse




--
Adrian Klaver
adrian.klaver@aklaver.com

Re: Service not starting on Ubuntu 15.04

From
Stuart Bishop
Date:
On 26 October 2015 at 18:21, Lasse Westh-Nielsen <lassewesth@gmail.com> wrote:
> Hey,
>
> I posted to stackoverflow about my problem upgrading from Ubuntu 14.04 to
> Ubuntu 15.04:
> http://stackoverflow.com/questions/33306475/ubuntu-15-04-postgresql-doesnt-start
>
> Tl;dr: postgresql service does not start properly when installed as a
> package using cloud-init.
>
> And I can't figure out if I am doing something wrong, if the AMI is no good,
> if the package has problems, ... I reckon I cannot be the first person to
> use Postgres on Ubuntu Vivid, but I have been hammering my head against the
> wall with this for hours.
>
> Any help greatly appreciated!

I'd be trying 'pg_ctlcluster --force 9.4 main stop'  and
'pg_ctlcluster 9.4 main start' instead of service start/stop. If it
works, you have narrowed down the problem to systemd and/or the
startup scripts. If it doesn't work, the problem is elsewhere (eg.
some required path like /var/run or /tmp or /var/log/postgresql
doesn't exist or has peculiar permissions). If nothing else, you
should get more informative output rather than systemd hiding it away
somewhere.

--
Stuart Bishop <stuart@stuartbishop.net>
http://www.stuartbishop.net/


Re: Service not starting on Ubuntu 15.04

From
Adrian Klaver
Date:
On 10/26/2015 07:08 AM, Lasse Westh-Nielsen wrote:
> Adrian,
>
> Thanks. I know about the systemd change, and indeed the postgres package
> I end up with _has_ systemd integration already:
>
>     $ cat /etc/systemd/system/multi-user.target.wants/postgresql.service
>     # systemd service for managing all PostgreSQL clusters on the
>     system. This
>     # service is actually a systemd target, but we are using a service since
>     # targets cannot be reloaded.
>
>     [Unit]
>     Description=PostgreSQL RDBMS
>
>     [Service]
>     Type=oneshot
>     ExecStart=/bin/true
>     ExecReload=/bin/true
>     RemainAfterExit=on
>
>     [Install]
>     WantedBy=multi-user.target

The thing above the above is I do not see anything that starts Postgres.

Are you sure the same script is being called in cloud-init and outside
of it?

Or more to the point, what script actually starts Postgres?




--
Adrian Klaver
adrian.klaver@aklaver.com


Re: Service not starting on Ubuntu 15.04

From
Lasse Westh-Nielsen
Date:
Adrian,

The service starts once the package is installed.

 - It did that on Ubuntu14.04
 - On Ubuntu 15.04, `sudo service postgresql status` _claims_ it has been started.



On Mon, Oct 26, 2015 at 2:57 PM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 10/26/2015 07:08 AM, Lasse Westh-Nielsen wrote:
Adrian,

Thanks. I know about the systemd change, and indeed the postgres package
I end up with _has_ systemd integration already:

    $ cat /etc/systemd/system/multi-user.target.wants/postgresql.service
    # systemd service for managing all PostgreSQL clusters on the
    system. This
    # service is actually a systemd target, but we are using a service since
    # targets cannot be reloaded.

    [Unit]
    Description=PostgreSQL RDBMS

    [Service]
    Type=oneshot
    ExecStart=/bin/true
    ExecReload=/bin/true
    RemainAfterExit=on

    [Install]
    WantedBy=multi-user.target

The thing above the above is I do not see anything that starts Postgres.

Are you sure the same script is being called in cloud-init and outside of it?

Or more to the point, what script actually starts Postgres?




--
Adrian Klaver
adrian.klaver@aklaver.com

Re: Service not starting on Ubuntu 15.04

From
Lasse Westh-Nielsen
Date:
Stuart,

You are a life-saver!

With those two commands inserted into the cloud-init script, the service actually starts and can complete my CREATE command.

Thanks!

 - Lasse




On Mon, Oct 26, 2015 at 2:31 PM, Stuart Bishop <stuart@stuartbishop.net> wrote:
On 26 October 2015 at 18:21, Lasse Westh-Nielsen <lassewesth@gmail.com> wrote:
> Hey,
>
> I posted to stackoverflow about my problem upgrading from Ubuntu 14.04 to
> Ubuntu 15.04:
> http://stackoverflow.com/questions/33306475/ubuntu-15-04-postgresql-doesnt-start
>
> Tl;dr: postgresql service does not start properly when installed as a
> package using cloud-init.
>
> And I can't figure out if I am doing something wrong, if the AMI is no good,
> if the package has problems, ... I reckon I cannot be the first person to
> use Postgres on Ubuntu Vivid, but I have been hammering my head against the
> wall with this for hours.
>
> Any help greatly appreciated!

I'd be trying 'pg_ctlcluster --force 9.4 main stop'  and
'pg_ctlcluster 9.4 main start' instead of service start/stop. If it
works, you have narrowed down the problem to systemd and/or the
startup scripts. If it doesn't work, the problem is elsewhere (eg.
some required path like /var/run or /tmp or /var/log/postgresql
doesn't exist or has peculiar permissions). If nothing else, you
should get more informative output rather than systemd hiding it away
somewhere.

--
Stuart Bishop <stuart@stuartbishop.net>
http://www.stuartbishop.net/

Re: Service not starting on Ubuntu 15.04

From
Adrian Klaver
Date:
On 10/26/2015 08:04 AM, Lasse Westh-Nielsen wrote:
> Adrian,
>
> The service starts once the package is installed.
>
>   - It did that on Ubuntu14.04
>   - On Ubuntu 15.04, `sudo service postgresql status` _claims_ it has
> been started.

Yes, it starts but it is a go nowhere, do nothing service:

     $ cat /etc/systemd/system/multi-user.target.wants/postgresql.service
     # systemd service for managing all PostgreSQL clusters on the
system. This
     # service is actually a systemd target, but we are using a service
since
     # targets cannot be reloaded.

     [Unit]
     Description=PostgreSQL RDBMS

     [Service]
     Type=oneshot
     ExecStart=/bin/true
     ExecReload=/bin/true
     RemainAfterExit=on

     [Install]
     WantedBy=multi-user.target

All it does is start /bin/true which is why the status shows it started,
but Postgres does not run. My guess is the answer is in here:

http://askubuntu.com/questions/632882/does-upstart-really-handle-all-startup-scripts

Second answer

" PostgreSQL comes with two systemd service unit files in version 15,
/lib/systemd/system/postgresql@.service and
/lib/systemd/system/postgresql.service. System 5 rc stuff is thus
completely ignored."


Best guess is /lib/systemd/system/postgresql@.service is the one that
actually starts Postgres. Sort of confirmed by the comments in the
service script above:

"# systemd service for managing all PostgreSQL clusters on the system. This
# service is actually a systemd target, but we are using a service since
# targets cannot be reloaded."

Pretty sure /lib/systemd/system/postgresql.service is just a placeholder
script.

At any rate Stuarts answer and your application of it confirms the
service script is the issue.

>
>
>
> On Mon, Oct 26, 2015 at 2:57 PM, Adrian Klaver
> <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>> wrote:
>
>     On 10/26/2015 07:08 AM, Lasse Westh-Nielsen wrote:
>
>         Adrian,
>
>         Thanks. I know about the systemd change, and indeed the postgres
>         package
>         I end up with _has_ systemd integration already:
>
>              $ cat
>         /etc/systemd/system/multi-user.target.wants/postgresql.service
>              # systemd service for managing all PostgreSQL clusters on the
>              system. This
>              # service is actually a systemd target, but we are using a
>         service since
>              # targets cannot be reloaded.
>
>              [Unit]
>              Description=PostgreSQL RDBMS
>
>              [Service]
>              Type=oneshot
>              ExecStart=/bin/true
>              ExecReload=/bin/true
>              RemainAfterExit=on
>
>              [Install]
>              WantedBy=multi-user.target
>
>
>     The thing above the above is I do not see anything that starts Postgres.
>
>     Are you sure the same script is being called in cloud-init and
>     outside of it?
>
>     Or more to the point, what script actually starts Postgres?
>
>
>
>
>     --
>     Adrian Klaver
>     adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
>
>


--
Adrian Klaver
adrian.klaver@aklaver.com


Re: Service not starting on Ubuntu 15.04

From
Melvin Davidson
Date:
Just out of curiosity, is there anything in the postgresql.log which gives an indication of a problem?

On Mon, Oct 26, 2015 at 11:18 AM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 10/26/2015 08:04 AM, Lasse Westh-Nielsen wrote:
Adrian,

The service starts once the package is installed.

  - It did that on Ubuntu14.04
  - On Ubuntu 15.04, `sudo service postgresql status` _claims_ it has
been started.

Yes, it starts but it is a go nowhere, do nothing service:

    $ cat /etc/systemd/system/multi-user.target.wants/postgresql.service
    # systemd service for managing all PostgreSQL clusters on the system. This
    # service is actually a systemd target, but we are using a service since
    # targets cannot be reloaded.

    [Unit]
    Description=PostgreSQL RDBMS

    [Service]
    Type=oneshot
    ExecStart=/bin/true
    ExecReload=/bin/true
    RemainAfterExit=on

    [Install]
    WantedBy=multi-user.target

All it does is start /bin/true which is why the status shows it started, but Postgres does not run. My guess is the answer is in here:

http://askubuntu.com/questions/632882/does-upstart-really-handle-all-startup-scripts

Second answer

" PostgreSQL comes with two systemd service unit files in version 15, /lib/systemd/system/postgresql@.service and /lib/systemd/system/postgresql.service. System 5 rc stuff is thus completely ignored."


Best guess is /lib/systemd/system/postgresql@.service is the one that actually starts Postgres. Sort of confirmed by the comments in the service script above:

"# systemd service for managing all PostgreSQL clusters on the system. This
# service is actually a systemd target, but we are using a service since
# targets cannot be reloaded."

Pretty sure /lib/systemd/system/postgresql.service is just a placeholder script.

At any rate Stuarts answer and your application of it confirms the service script is the issue.




On Mon, Oct 26, 2015 at 2:57 PM, Adrian Klaver
<adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>> wrote:

    On 10/26/2015 07:08 AM, Lasse Westh-Nielsen wrote:

        Adrian,

        Thanks. I know about the systemd change, and indeed the postgres
        package
        I end up with _has_ systemd integration already:

             $ cat
        /etc/systemd/system/multi-user.target.wants/postgresql.service
             # systemd service for managing all PostgreSQL clusters on the
             system. This
             # service is actually a systemd target, but we are using a
        service since
             # targets cannot be reloaded.

             [Unit]
             Description=PostgreSQL RDBMS

             [Service]
             Type=oneshot
             ExecStart=/bin/true
             ExecReload=/bin/true
             RemainAfterExit=on

             [Install]
             WantedBy=multi-user.target


    The thing above the above is I do not see anything that starts Postgres.

    Are you sure the same script is being called in cloud-init and
    outside of it?

    Or more to the point, what script actually starts Postgres?




    --
    Adrian Klaver
    adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>




--
Adrian Klaver
adrian.klaver@aklaver.com


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



--
Melvin Davidson
I reserve the right to fantasize.  Whether or not you
wish to share my fantasy is entirely up to you.

Re: Service not starting on Ubuntu 15.04

From
Lasse Westh-Nielsen
Date:
Nope, the log is empty. Literally zero bytes.

On Mon, Oct 26, 2015 at 3:57 PM, Melvin Davidson <melvin6925@gmail.com> wrote:
Just out of curiosity, is there anything in the postgresql.log which gives an indication of a problem?

On Mon, Oct 26, 2015 at 11:18 AM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 10/26/2015 08:04 AM, Lasse Westh-Nielsen wrote:
Adrian,

The service starts once the package is installed.

  - It did that on Ubuntu14.04
  - On Ubuntu 15.04, `sudo service postgresql status` _claims_ it has
been started.

Yes, it starts but it is a go nowhere, do nothing service:

    $ cat /etc/systemd/system/multi-user.target.wants/postgresql.service
    # systemd service for managing all PostgreSQL clusters on the system. This
    # service is actually a systemd target, but we are using a service since
    # targets cannot be reloaded.

    [Unit]
    Description=PostgreSQL RDBMS

    [Service]
    Type=oneshot
    ExecStart=/bin/true
    ExecReload=/bin/true
    RemainAfterExit=on

    [Install]
    WantedBy=multi-user.target

All it does is start /bin/true which is why the status shows it started, but Postgres does not run. My guess is the answer is in here:

http://askubuntu.com/questions/632882/does-upstart-really-handle-all-startup-scripts

Second answer

" PostgreSQL comes with two systemd service unit files in version 15, /lib/systemd/system/postgresql@.service and /lib/systemd/system/postgresql.service. System 5 rc stuff is thus completely ignored."


Best guess is /lib/systemd/system/postgresql@.service is the one that actually starts Postgres. Sort of confirmed by the comments in the service script above:

"# systemd service for managing all PostgreSQL clusters on the system. This
# service is actually a systemd target, but we are using a service since
# targets cannot be reloaded."

Pretty sure /lib/systemd/system/postgresql.service is just a placeholder script.

At any rate Stuarts answer and your application of it confirms the service script is the issue.




On Mon, Oct 26, 2015 at 2:57 PM, Adrian Klaver
<adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>> wrote:

    On 10/26/2015 07:08 AM, Lasse Westh-Nielsen wrote:

        Adrian,

        Thanks. I know about the systemd change, and indeed the postgres
        package
        I end up with _has_ systemd integration already:

             $ cat
        /etc/systemd/system/multi-user.target.wants/postgresql.service
             # systemd service for managing all PostgreSQL clusters on the
             system. This
             # service is actually a systemd target, but we are using a
        service since
             # targets cannot be reloaded.

             [Unit]
             Description=PostgreSQL RDBMS

             [Service]
             Type=oneshot
             ExecStart=/bin/true
             ExecReload=/bin/true
             RemainAfterExit=on

             [Install]
             WantedBy=multi-user.target


    The thing above the above is I do not see anything that starts Postgres.

    Are you sure the same script is being called in cloud-init and
    outside of it?

    Or more to the point, what script actually starts Postgres?




    --
    Adrian Klaver
    adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>




--
Adrian Klaver
adrian.klaver@aklaver.com


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



--
Melvin Davidson
I reserve the right to fantasize.  Whether or not you
wish to share my fantasy is entirely up to you.