Re: Recover PostgreSQL database folder data

From: Edson Lidorio <edson(at)openmailbox(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Recover PostgreSQL database folder data
Date: 2017-04-21 23:20:38
Message-ID: fa2f3288-bbd5-19cb-d4d6-cad9314fc6b8@openmailbox.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 21-04-2017 18:13, Edson Lidorio wrote:
>
>
> On 21-04-2017 18:02, Adrian Klaver wrote:
>> Chown -R postgres: postgres /var/lib/pgsql/9.6/data
> After the command, I have the errors:
>
> Apr 21 18:11:41 localhost postgresql96-check-db-dir:
> "/var/lib/pgsql/9.6/data/" is missing or empty.
> Apr 21 18:11:41 localhost postgresql96-check-db-dir: Use
> "/usr/pgsql-9.6/bin/postgresql96-setup initdb" to initialize the
> database cluster.
> Apr 21 18:11:41 localhost postgresql96-check-db-dir: See
> /usr/share/doc/postgresql96/README.rpm-dist for more information.
> Apr 21 18:11:41 localhost systemd: postgresql-9.6.service: control
> process exited, code=exited status=1
> Apr 21 18:11:41 localhost systemd: Failed to start PostgreSQL 9.6
> database server.
> Apr 21 18:11:41 localhost systemd: Unit postgresql-9.6.service entered
> failed state.
> Apr 21 18:11:41 localhost systemd: postgresql-9.6.service failed.
>
Follows all the results:

What does the directory listing for /var/lib/pgsql/9.6/data show?
[root(at)localhost data]# pwd
/var/lib/pgsql/9.6/data

Ls -la /var/lib/pgsql/9.6/data

drwx------. 20 postgres postgres 4096 Abr 21 17:52 .
drwx------. 4 root root 51 Abr 21 06:33 ..
-rw-------. 1 postgres postgres 0 Abr 21 06:33 ArquivoASerCriado.dmp
drwx------. 44 postgres postgres 4096 Abr 21 06:32 base
drwx------. 2 postgres postgres 4096 Abr 21 06:32 global
drwx------. 2 postgres postgres 18 Abr 21 06:32 pg_clog
drwx------. 2 postgres postgres 6 Abr 21 06:32 pg_commit_ts
drwx------. 2 postgres postgres 6 Abr 21 06:32 pg_dynshmem
-rw-------. 1 postgres postgres 4345 Abr 21 06:33 pg_hba.conf
-rw-------. 1 postgres postgres 1636 Abr 21 06:33 pg_ident.conf
drwx------. 2 postgres postgres 188 Abr 21 06:32 pg_log
drwx------. 4 postgres postgres 39 Abr 21 06:32 pg_logical
drwx------. 4 postgres postgres 36 Abr 21 06:32 pg_multixact
drwx------. 2 postgres postgres 18 Abr 21 06:32 pg_notify
drwx------. 2 postgres postgres 6 Abr 21 06:32 pg_replslot
drwx------. 2 postgres postgres 6 Abr 21 06:32 pg_serial
drwx------. 2 postgres postgres 6 Abr 21 06:32 pg_snapshots
drwx------. 2 postgres postgres 4096 Abr 21 06:32 pg_stat
drwx------. 2 postgres postgres 6 Abr 21 06:32 pg_stat_tmp
drwx------. 2 postgres postgres 18 Abr 21 06:32 pg_subtrans
drwx------. 2 postgres postgres 84 Abr 21 06:32 pg_tblspc
drwx------. 2 postgres postgres 6 Abr 21 06:32 pg_twophase
-rw-------. 1 postgres postgres 4 Abr 21 06:33 PG_VERSION
drwx------. 3 postgres postgres 4096 Abr 21 06:33 pg_xlog
-rw-------. 1 postgres postgres 88 Abr 21 06:33 postgresql.auto.conf
-rw-------. 1 postgres postgres 22289 Abr 21 06:33 postgresql.conf
-rw-------. 1 postgres postgres 60 Abr 21 06:33 postmaster.opts

Ensure you actually have a folder named "/var/lib/pgsql/9.6/data" with your
database in it (not, possibly, a folder named "date" per your original
message).

[root(at)localhost 9.6]# du -hs *
0 backups
4,2G data
4,0K initdb.log

chown -R postgres:postgres /var/lib/pgsql/9.6/data

systemctl start postgresql-9.6.service
Job for postgresql-9.6.service failed because the control process exited
with error code. See "systemctl status postgresql-9.6.service" and
"journalctl -xe" for details.

restorecon -R /var/lib/pgsql/9.6/data

Apr 21 19:11:58 localhost systemd: Starting PostgreSQL 9.6 database
server...
Apr 21 19:11:58 localhost postgresql96-check-db-dir:
"/var/lib/pgsql/9.6/data/" is missing or empty.
Apr 21 19:11:58 localhost postgresql96-check-db-dir: Use
"/usr/pgsql-9.6/bin/postgresql96-setup initdb" to initialize the
database cluster.
Apr 21 19:11:58 localhost postgresql96-check-db-dir: See
/usr/share/doc/postgresql96/README.rpm-dist for more information.
Apr 21 19:11:58 localhost systemd: postgresql-9.6.service: control
process exited, code=exited status=1
Apr 21 19:11:58 localhost systemd: Failed to start PostgreSQL 9.6
database server.
Apr 21 19:11:58 localhost systemd: Unit postgresql-9.6.service entered
failed state.
Apr 21 19:11:58 localhost systemd: postgresql-9.6.service failed.

If it still won't start after that, please do an "ls -alRZ
/var/lib/pgsql/9.6", pastebin the output, and send the link.

Download Link: http://myaccount.dropsend.com/file/2714afb84f8ecadd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2017-04-21 23:38:38 Re: Recover PostgreSQL database folder data
Previous Message Michael Paquier 2017-04-21 22:29:25 Re: pg_basebackup ----xlog-method=stream