RE: Issue: Creating Symlink for data directory of postgresql in CentOS7

From: "Chatterjee, Shibayan" <shibayan(dot)chatterjee(at)centurylink(dot)com>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: RE: Issue: Creating Symlink for data directory of postgresql in CentOS7
Date: 2019-07-15 18:10:01
Message-ID: 634c2118e2ec4d4aa94e8fd1ca8bd44b@level3.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I found a work around for the problem:
After changing access permissions and ownership of the symlink data directory, I logged into postgres using 'postgres' login as:

>>> sudo -i -u postgres

Then force started postgres from there as mentioned below. The execution doesn't return back to prompt, so had it run back in the background. Postgres started running back to normal.

>>> /usr/bin/postgres -D /var/lib/pgsql/data &

Thanks !
-Shibayan

-----Original Message-----
From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Sent: Sunday, July 14, 2019 9:05 AM
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>; Chatterjee, Shibayan <shibayan(dot)chatterjee(at)level3(dot)com>; pgsql-general(at)postgresql(dot)org
Subject: Re: Issue: Creating Symlink for data directory of postgresql in CentOS7

Adrian Klaver wrote:
> On 7/13/19 4:30 AM, Laurenz Albe wrote:
> > On Fri, 2019-07-12 at 18:08 +0000, Chatterjee, Shibayan wrote:
> > > > Jul 12 10:00:51 postgresql-check-db-dir: "/data/postgresql/data" is missing or empty.
> > > > Jul 12 10:00:51 postgresql-check-db-dir: Use "postgresql-setup initdb" to initialize the database cluster.
> > > > Jul 12 10:00:51 postgresql-check-db-dir: See /usr/share/doc/postgresql-9.2.24/README.rpm-dist for more information.
> > >
> > > For sure there's all the necessary files in '/data/postgresql/data'.
> > > The startup process cannot read it, because of sym link.
> >
> > Well, where is the source for this fabled "postgresql-check-db-dir"?
>
> https://git.postgresql.org/gitweb/?p=pgrpms.git;a=blob;f=rpm/redhat/9.
> 2/postgresql/EL-7/postgresql92-check-db-dir;h=550b31770cabacf32cbb1b8f
> 272e8ce305fc9908;hb=HEAD

Thanks. I read this:

30 # Check for the PGDATA structure
31 if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base" ]
32 then
[...]
49 else
50 # No existing PGDATA! Warn the user to initdb it.
51 echo $"\"$PGDATA\" is missing or empty."
52 echo $"Use \"/usr/pgsql-9.2/bin/postgresql92-setup initdb\" to initialize the database cluster."
53 echo $"See $PGDOCDIR/README.rpm-dist for more information."
54 exit 1
55 fi

That means that either there was no regular file /data/postgresql/data/PG_VERSION or no directory /data/postgresql/data/base, or that the user running the script lacked the permissions to access them.

Since you say that there was a regular data directory there, that would point to permission problems.

Witn that information, it should be simple to debug the problem.

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com

This communication is the property of CenturyLink and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alex Williams 2019-07-15 18:35:28 Tablespace column value null on select * from pg_tables
Previous Message Peter Geoghegan 2019-07-15 17:20:57 Re: after restore the size of the database is increased