Re: Trouble starting Postgresql after an upgrade

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Kevin Brannen <KBrannen(at)efji(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Trouble starting Postgresql after an upgrade
Date: 2016-07-14 16:48:29
Message-ID: 24b0a51e-09e9-64b6-4e38-2be25bed7168@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 07/14/2016 06:58 AM, Kevin Brannen wrote:
> I’m having a little trouble and I hope someone can point me towards a fix. ☺
>
> We’ve been using Pg 9.3.4 and just upgraded to 9.5.1. I’ve installed it on 1 server and it works. ☺ However, when I copied those binaries over to a 2nd server, I find that they won’t start normally. I can do “/etc/init.d/postgresql-9.5 start” from anywhere and it fails to start. Looking in the script, I believe the important line (expanded via bash -x) is:

What OS, OS version and architecture for each machine?

How did you upgrade?

>
> + echo -n 'Starting postgresql-9.5 service: '
> Starting postgresql-9.5 service: + runuser -l postgres -c '/opt/pgsql-9.5/bin/postmaster -p '\''5432'\'' -D '\''/nms-db/9.5/data'\'' &'
>
> In the pgstartup.log, I see:
>
> LOG: skipping missing configuration file "/home/postgres/postgresql.auto.conf"
> 2016-07-12 22:16:41 GMT [6066]: [2-1] user=,db=,app= FATAL: "/home/postgres" is not a valid data directory
> 2016-07-12 22:16:41 GMT [6066]: [3-1] user=,db=,app= DETAIL: File "/home/postgres/PG_VERSION" is missing.
>
> Duh, there is no postgresql.auto.conf in the ~postgres, it's in the data dir "/nms-db/9.5/data", as is "PG_VERSION". I also don’t see anything in the main log (in /logs/pg_log/post*”) that gives me any more info.
>
> Since it all works on the original server, I must have done something wrong on this install, but I can’t figure out what. Can someone see what I did wrong from the above or a pointer to a place to look with better error messages would also be helpful.
>
> To make the problem more interesting, I can bring the DB engine up if I use pg_ctl … but only if I’m in the data dir.
>
> [root(at)nms59c ~]# pwd
> /root
> [root(at)nms59c ~]# sudo -u postgres "/opt/pgsql-9.5/bin/pg_ctl" -w -D "/nms-db/9.5/data" -o "" start
> could not change directory to "/root": Permission denied
> waiting for server to start....LOG: skipping missing configuration file "/opt/pgsql-9.5/bin/postgresql.auto.conf"
> 2016-07-12 22:41:30 GMT [5567]: [2-1] user=,db=,app= FATAL: data directory "/opt/pgsql-9.5/bin" has wrong ownership
> 2016-07-12 22:41:30 GMT [5567]: [3-1] user=,db=,app= HINT: The server must be started by the user that owns the data directory.
> stopped waiting
> pg_ctl: could not start server
> Examine the log output.
> [root(at)nms59c ~]#
> [root(at)nms59c ~]#
> [root(at)nms59c ~]# cd $PGDATA
> [root(at)nms59c data]# pwd
> /nms-db/9.5/data
> [root(at)nms59c data]# sudo -u postgres "/opt/pgsql-9.5/bin/pg_ctl" -w -D "/nms-db/9.5/data" -o "" start
> waiting for server to start....2016-07-12 22:41:38 GMT [5571]: [1-1] user=,db=,app= LOG: redirecting log output to logging collector process
> 2016-07-12 22:41:38 GMT [5571]: [2-1] user=,db=,app= HINT: Future log output will appear in directory "/logs/pg_log".
> done
> server started
> [root(at)nms59c data]#
>
> That almost makes sense to me as it probably wants to write some file so perms matter, but yet I don’t understand why it wouldn’t change to the data dir itself if that’s really required.

I would say it is the difference between init/service scripts between
machines. Can't be more specific until the questions above are answered.

>
> Given the above, I’m tempted to change /etc/init.d/postgresql-9.5 so that it does “cd $PGDATA” then replace the “runuser -l postgres -c…” line to be what I have that works with pg_ctl, but I’m concerned that the error is an indication that I’ve screwed up something important that will bite me later if I don’t figure it out now. This is on a test system, so no real data is endangered; but I really need to figure this out as we automate the upgrade so it can go to real data servers.
>
> Kevin
>
> This e-mail transmission, and any documents, files or previous e-mail messages attached to it, may contain confidential information. If you are not the intended recipient, or a person responsible for delivering it to the intended recipient, you are hereby notified that any disclosure, distribution, review, copy or use of any of the information contained in or attached to this message is STRICTLY PROHIBITED. If you have received this transmission in error, please immediately notify us by reply e-mail, and destroy the original transmission and its attachments without reading them or saving them to disk. Thank you.
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2016-07-14 17:01:39 Re: Trouble starting Postgresql after an upgrade
Previous Message Tom Lane 2016-07-14 15:21:41 Re: Server side backend permanent session memory usage ?