Обсуждение: [GENERAL] Recover PostgreSQL database folder data

Поиск
Список
Период
Сортировка

[GENERAL] Recover PostgreSQL database folder data

От
Edson Lidorio
Дата:
Hi,
There was a disaster in my development note. I was able to recover the
data folder. PostgreSQL 9.6.2, was installed in Centos 7.

Here are the procedures I'm trying to initialize Postgresql for me to do
a backup.

1- I installed PostgreSQL 9.6.2 on a VM with Centos 7.
2- I stopped the PostgreSQL service: sudo systemctl stop postgresql-9.6
3- I renamed the /var/lib/pgsql/9.6/data folder to date data_old and
copied the old date folder
4- I gave permission in the folder date:
      sudo chown postgres: postgres /var/lib/pgsql/9.6/data;
      sudo chmod 700 /var/lib/pgsql/9.6/data
5 - I tried to start the service: sudo systemctl start postgresql-9.6
It is generating the following errors:

Abr 21 01:25:35 localhost.localdomain systemd[1]: Starting PostgreSQL
9.6 database server...
Abr 21 01:25:36 localhost.localdomain postgresql96-check-db-dir[19996]:
cat: /var/lib/pgsql/9.6/data//PG_VER…ada
Abr 21 01:25:36 localhost.localdomain postgresql96-check-db-dir[19996]:
cat: /var/lib/pgsql/9.6/data//PG_VER…ada
Abr 21 01:25:36 localhost.localdomain systemd[1]:
postgresql-9.6.service: control process exited, code=ex...us=1
Abr 21 01:25:36 localhost.localdomain systemd[1]: Failed to start
PostgreSQL 9.6 database server.
Abr 21 01:25:36 localhost.localdomain systemd[1]: Unit
postgresql-9.6.service entered failed state.
Abr 21 01:25:36 localhost.localdomain systemd[1]: postgresql-9.6.service
failed.
Hint: Some lines were ellipsized, use -l to show in full.



Re: [GENERAL] Recover PostgreSQL database folder data

От
Adrian Klaver
Дата:
On 04/21/2017 09:40 AM, Edson Lidorio wrote:
> Hi,
> There was a disaster in my development note. I was able to recover the
> data folder. PostgreSQL 9.6.2, was installed in Centos 7.
>
> Here are the procedures I'm trying to initialize Postgresql for me to do
> a backup.
>
> 1- I installed PostgreSQL 9.6.2 on a VM with Centos 7.
> 2- I stopped the PostgreSQL service: sudo systemctl stop postgresql-9.6
> 3- I renamed the /var/lib/pgsql/9.6/data folder to date data_old and
> copied the old date folder
> 4- I gave permission in the folder date:
>      sudo chown postgres: postgres /var/lib/pgsql/9.6/data;
>      sudo chmod 700 /var/lib/pgsql/9.6/data
> 5 - I tried to start the service: sudo systemctl start postgresql-9.6
> It is generating the following errors:
>
> Abr 21 01:25:35 localhost.localdomain systemd[1]: Starting PostgreSQL
> 9.6 database server...
> Abr 21 01:25:36 localhost.localdomain postgresql96-check-db-dir[19996]:
> cat: /var/lib/pgsql/9.6/data//PG_VER…ada
> Abr 21 01:25:36 localhost.localdomain postgresql96-check-db-dir[19996]:
> cat: /var/lib/pgsql/9.6/data//PG_VER…ada
> Abr 21 01:25:36 localhost.localdomain systemd[1]:
> postgresql-9.6.service: control process exited, code=ex...us=1
> Abr 21 01:25:36 localhost.localdomain systemd[1]: Failed to start
> PostgreSQL 9.6 database server.
> Abr 21 01:25:36 localhost.localdomain systemd[1]: Unit
> postgresql-9.6.service entered failed state.
> Abr 21 01:25:36 localhost.localdomain systemd[1]: postgresql-9.6.service
> failed.
> Hint: Some lines were ellipsized, use -l to show in full.

What do you see if you do the above, add -l to the systemctl command?

What does the system log show?



>
>
>


--
Adrian Klaver
adrian.klaver@aklaver.com


Re: [GENERAL] Recover PostgreSQL database folder data

От
Edson Lidorio
Дата:

On 21-04-2017 13:48, Adrian Klaver wrote:
> On 04/21/2017 09:40 AM, Edson Lidorio wrote:
>> Hi,
>> There was a disaster in my development note. I was able to recover the
>> data folder. PostgreSQL 9.6.2, was installed in Centos 7.
>>
>> Here are the procedures I'm trying to initialize Postgresql for me to do
>> a backup.
>>
>> 1- I installed PostgreSQL 9.6.2 on a VM with Centos 7.
>> 2- I stopped the PostgreSQL service: sudo systemctl stop postgresql-9.6
>> 3- I renamed the /var/lib/pgsql/9.6/data folder to date data_old and
>> copied the old date folder
>> 4- I gave permission in the folder date:
>>      sudo chown postgres: postgres /var/lib/pgsql/9.6/data;
>>      sudo chmod 700 /var/lib/pgsql/9.6/data
>> 5 - I tried to start the service: sudo systemctl start postgresql-9.6
>> It is generating the following errors:
>>
>> Abr 21 01:25:35 localhost.localdomain systemd[1]: Starting PostgreSQL
>> 9.6 database server...
>> Abr 21 01:25:36 localhost.localdomain postgresql96-check-db-dir[19996]:
>> cat: /var/lib/pgsql/9.6/data//PG_VER…ada
>> Abr 21 01:25:36 localhost.localdomain postgresql96-check-db-dir[19996]:
>> cat: /var/lib/pgsql/9.6/data//PG_VER…ada
>> Abr 21 01:25:36 localhost.localdomain systemd[1]:
>> postgresql-9.6.service: control process exited, code=ex...us=1
>> Abr 21 01:25:36 localhost.localdomain systemd[1]: Failed to start
>> PostgreSQL 9.6 database server.
>> Abr 21 01:25:36 localhost.localdomain systemd[1]: Unit
>> postgresql-9.6.service entered failed state.
>> Abr 21 01:25:36 localhost.localdomain systemd[1]: postgresql-9.6.service
>> failed.
>> Hint: Some lines were ellipsized, use -l to show in full.
>
> What do you see if you do the above, add -l to the systemctl command?
● postgresql-9.6.service loaded failed failed    PostgreSQL 9.6 database
server
>
> What does the system log show?
> Apr 21 04:01:01 localhost systemd: Started Session 53 of user root.
> Apr 21 04:01:01 localhost systemd: Starting Session 53 of user root.
> Apr 21 04:01:48 localhost systemd: Starting PostgreSQL 9.6 database
> server...
> Apr 21 04:01:48 localhost postgresql96-check-db-dir: cat:
> /var/lib/pgsql/9.6/data//PG_VERSION: Permissão negada
> Apr 21 04:01:48 localhost postgresql96-check-db-dir: cat:
> /var/lib/pgsql/9.6/data//PG_VERSION: Permissão negada
> Apr 21 04:01:48 localhost postgresql96-check-db-dir: An old version of
> the database format was found.
> Apr 21 04:01:48 localhost postgresql96-check-db-dir: You need to dump
> and reload before using PostgreSQL 9.6.
> Apr 21 04:01:48 localhost postgresql96-check-db-dir: See
> /usr/share/doc/postgresql96/README.rpm-dist for more information.
> Apr 21 04:01:48 localhost systemd: postgresql-9.6.service: control
> process exited, code=exited status=1
> Apr 21 04:01:48 localhost systemd: Failed to start PostgreSQL 9.6
> database server.
> Apr 21 04:01:48 localhost systemd: Unit postgresql-9.6.service entered
> failed state.
> Apr 21 04:01:48 localhost systemd: postgresql-9.6.service failed.
> Apr 21 04:02:07 localhost gnome-session: (nautilus:17753): Gtk-WARNING
> **: gtk_widget_size_allocate(): attempt to allocate widget with width
> -15 and height 34
> Apr 21 04:02:57 localhost gnome-session: (nautilus:17753): Gtk-WARNING
> **: gtk_widget_size_allocate(): attempt to allocate widget with width
> -15 and height 34
> Apr 21 04:03:00 localhost gnome-session: (nautilus:17753): Gtk-WARNING
> **: gtk_widget_size_allocate(): attempt to allocate widget with width
> -15 and height 34
>
>
>>
>>
>>
>
>



Re: [GENERAL] Recover PostgreSQL database folder data

От
Adrian Klaver
Дата:
On 04/21/2017 10:09 AM, Edson Lidorio wrote:
>
>
> On 21-04-2017 13:48, Adrian Klaver wrote:
>> On 04/21/2017 09:40 AM, Edson Lidorio wrote:
>>> Hi,
>>> There was a disaster in my development note. I was able to recover the
>>> data folder. PostgreSQL 9.6.2, was installed in Centos 7.
>>>
>>> Here are the procedures I'm trying to initialize Postgresql for me to do
>>> a backup.
>>>
>>> 1- I installed PostgreSQL 9.6.2 on a VM with Centos 7.
>>> 2- I stopped the PostgreSQL service: sudo systemctl stop postgresql-9.6
>>> 3- I renamed the /var/lib/pgsql/9.6/data folder to date data_old and
>>> copied the old date folder
>>> 4- I gave permission in the folder date:
>>>      sudo chown postgres: postgres /var/lib/pgsql/9.6/data;
>>>      sudo chmod 700 /var/lib/pgsql/9.6/data
>>> 5 - I tried to start the service: sudo systemctl start postgresql-9.6
>>> It is generating the following errors:
>>>
>>> Abr 21 01:25:35 localhost.localdomain systemd[1]: Starting PostgreSQL
>>> 9.6 database server...
>>> Abr 21 01:25:36 localhost.localdomain postgresql96-check-db-dir[19996]:
>>> cat: /var/lib/pgsql/9.6/data//PG_VER…ada
>>> Abr 21 01:25:36 localhost.localdomain postgresql96-check-db-dir[19996]:
>>> cat: /var/lib/pgsql/9.6/data//PG_VER…ada
>>> Abr 21 01:25:36 localhost.localdomain systemd[1]:
>>> postgresql-9.6.service: control process exited, code=ex...us=1
>>> Abr 21 01:25:36 localhost.localdomain systemd[1]: Failed to start
>>> PostgreSQL 9.6 database server.
>>> Abr 21 01:25:36 localhost.localdomain systemd[1]: Unit
>>> postgresql-9.6.service entered failed state.
>>> Abr 21 01:25:36 localhost.localdomain systemd[1]: postgresql-9.6.service
>>> failed.
>>> Hint: Some lines were ellipsized, use -l to show in full.
>>
>> What do you see if you do the above, add -l to the systemctl command?
> ● postgresql-9.6.service loaded failed failed    PostgreSQL 9.6 database
> server
>>
>> What does the system log show?
>> Apr 21 04:01:01 localhost systemd: Started Session 53 of user root.
>> Apr 21 04:01:01 localhost systemd: Starting Session 53 of user root.
>> Apr 21 04:01:48 localhost systemd: Starting PostgreSQL 9.6 database
>> server...
>> Apr 21 04:01:48 localhost postgresql96-check-db-dir: cat:
>> /var/lib/pgsql/9.6/data//PG_VERSION: Permissão negada
>> Apr 21 04:01:48 localhost postgresql96-check-db-dir: cat:
>> /var/lib/pgsql/9.6/data//PG_VERSION: Permissão negada

So you got a permissions error when the script was trying to read
PG_VERSION.

The suspicious part is this:
/var/lib/pgsql/9.6/data//PG_VERSION

in particular the //

Is that really the case?


>> Apr 21 04:01:48 localhost postgresql96-check-db-dir: An old version of
>> the database format was found.
>> Apr 21 04:01:48 localhost postgresql96-check-db-dir: You need to dump
>> and reload before using PostgreSQL 9.6.
>> Apr 21 04:01:48 localhost postgresql96-check-db-dir: See
>> /usr/share/doc/postgresql96/README.rpm-dist for more information.

Have to believe the above is a consequence of the permissions error. In
the event it is not:

1) What are the contents of PG_VERSION for data_old versus data?

2) Did you use the same repos in the VM that you used in the original
machine?

>> Apr 21 04:01:48 localhost systemd: postgresql-9.6.service: control
>> process exited, code=exited status=1
>> Apr 21 04:01:48 localhost systemd: Failed to start PostgreSQL 9.6
>> database server.
>> Apr 21 04:01:48 localhost systemd: Unit postgresql-9.6.service entered
>> failed state.
>> Apr 21 04:01:48 localhost systemd: postgresql-9.6.service failed.
>> Apr 21 04:02:07 localhost gnome-session: (nautilus:17753): Gtk-WARNING
>> **: gtk_widget_size_allocate(): attempt to allocate widget with width
>> -15 and height 34
>> Apr 21 04:02:57 localhost gnome-session: (nautilus:17753): Gtk-WARNING
>> **: gtk_widget_size_allocate(): attempt to allocate widget with width
>> -15 and height 34
>> Apr 21 04:03:00 localhost gnome-session: (nautilus:17753): Gtk-WARNING
>> **: gtk_widget_size_allocate(): attempt to allocate widget with width
>> -15 and height 34
>>
>>
>>>
>>>
>>>
>>
>>
>
>


--
Adrian Klaver
adrian.klaver@aklaver.com


Re: [GENERAL] Recover PostgreSQL database folder data

От
John R Pierce
Дата:
On 4/21/2017 12:00 PM, Adrian Klaver wrote:
Apr 21 04:01:48 localhost postgresql96-check-db-dir: cat:
/var/lib/pgsql/9.6/data//PG_VERSION: Permissão negada

So you got a permissions error when the script was trying to read PG_VERSION.

The suspicious part is this:
/var/lib/pgsql/9.6/data//PG_VERSION

in particular the //

Is that really the case?


unix/linux seems quite happy to ignore extra /'s ...

# ls -l /var/lib/pgsql/9.3/data//PG_VERSION
-rw-------. 1 postgres postgres 4 May 22  2014 /var/lib/pgsql/9.3/data//PG_VERSION


-- 
john r pierce, recycling bits in santa cruz

Re: [GENERAL] Recover PostgreSQL database folder data

От
Edson Lidorio
Дата:

On 21-04-2017 16:00, Adrian Klaver wrote:
> Is that really the case?
Yes, I have already given permission on this folder and it does not
initialize.
I'll try to make another copy in another vm.


Re: [GENERAL] Recover PostgreSQL database folder data

От
John R Pierce
Дата:
On 4/21/2017 1:14 PM, Edson Lidorio wrote:


On 21-04-2017 16:00, Adrian Klaver wrote:
Is that really the case?
Yes, I have already given permission on this folder and it does not initialize.
I'll try to make another copy in another vm.

who owns the files IN the folder?     try chown -R postgres.postgres /path/to/data


-- 
john r pierce, recycling bits in santa cruz

Re: [GENERAL] Recover PostgreSQL database folder data

От
Scott Mead
Дата:


On Fri, Apr 21, 2017 at 12:40 PM, Edson Lidorio <edson@openmailbox.org> wrote:
Hi,
There was a disaster in my development note. I was able to recover the data folder. PostgreSQL 9.6.2, was installed in Centos 7.

Here are the procedures I'm trying to initialize Postgresql for me to do a backup.

1- I installed PostgreSQL 9.6.2 on a VM with Centos 7.
2- I stopped the PostgreSQL service: sudo systemctl stop postgresql-9.6
3- I renamed the /var/lib/pgsql/9.6/data folder to date data_old and copied the old date folder
4- I gave permission in the folder date:
     sudo chown postgres: postgres /var/lib/pgsql/9.6/data;

Your error is that you didn't 'chown -R postgres:postgres /var/lib/pgsql/9.6/data'

--Scott
 
     sudo chmod 700 /var/lib/pgsql/9.6/data
5 - I tried to start the service: sudo systemctl start postgresql-9.6
It is generating the following errors:

Abr 21 01:25:35 localhost.localdomain systemd[1]: Starting PostgreSQL 9.6 database server...
Abr 21 01:25:36 localhost.localdomain postgresql96-check-db-dir[19996]: cat: /var/lib/pgsql/9.6/data//PG_VER…ada
Abr 21 01:25:36 localhost.localdomain postgresql96-check-db-dir[19996]: cat: /var/lib/pgsql/9.6/data//PG_VER…ada
Abr 21 01:25:36 localhost.localdomain systemd[1]: postgresql-9.6.service: control process exited, code=ex...us=1
Abr 21 01:25:36 localhost.localdomain systemd[1]: Failed to start PostgreSQL 9.6 database server.
Abr 21 01:25:36 localhost.localdomain systemd[1]: Unit postgresql-9.6.service entered failed state.
Abr 21 01:25:36 localhost.localdomain systemd[1]: postgresql-9.6.service failed.
Hint: Some lines were ellipsized, use -l to show in full.



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



--
--
Scott Mead
Sr. Architect
OpenSCG

Re: [GENERAL] Recover PostgreSQL database folder data

От
Adrian Klaver
Дата:
On 04/21/2017 01:14 PM, Edson Lidorio wrote:
>
>
> On 21-04-2017 16:00, Adrian Klaver wrote:
>> Is that really the case?
> Yes, I have already given permission on this folder and it does not
> initialize.

You do not want to initialize the directory that was taken care of when
you did:

3- I renamed the /var/lib/pgsql/9.6/data folder to date data_old and
copied the old date folder

The files are there, the start script is just not able to read them
because of permissions issues. You need to verify the permissions on the
files in data/-


> I'll try to make another copy in another vm.

Pretty sure you will end up at the same place.
>


--
Adrian Klaver
adrian.klaver@aklaver.com


Re: [GENERAL] Recover PostgreSQL database folder data

От
Edson Lidorio
Дата:



On 21-04-2017 17:27, Scott Mead wrote:
chown -R postgres:postgres /var/lib/pgsql/9.6/data

Chown -R postgres: postgres /var/lib/pgsql/9.6/data
  Sudo systemctl start postgresql-9.6

Erros:

Unit postgresql-9.6.service entered failed state.
Abr 21 07:50:11 localhost.localdomain systemd[1]: postgresql-9.6.service failed.
Abr 21 07:50:11 localhost.localdomain polkitd[693]: Unregistered Authentication Agent for unix-process:30276:3843896 (system bus name :1.486, object p
lines 2341-2377/2377 (END)


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


Re: [GENERAL] Recover PostgreSQL database folder data

От
Adrian Klaver
Дата:
On 04/21/2017 01:36 PM, Edson Lidorio wrote:
>
>
> On 21-04-2017 17:27, Scott Mead wrote:
>> chown *-R* postgres:postgres /var/lib/pgsql/9.6/data
>
> Chown -R postgres: postgres /var/lib/pgsql/9.6/data
>   Sudo systemctl start postgresql-9.6

Is this on the first VM you showed previously or the new one you said
you where going to create?

>
> Erros:
>
> Unit postgresql-9.6.service entered failed state.
> Abr 21 07:50:11 localhost.localdomain systemd[1]: postgresql-9.6.service
> failed.
> Abr 21 07:50:11 localhost.localdomain polkitd[693]: Unregistered
> Authentication Agent for unix-process:30276:3843896 (system bus name
> :1.486, object p
> lines 2341-2377/2377 (END)
>
>
> /var/lib/pgsql/9.6/data/" is missing or empty.

Is it empty, because before it was not?


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


--
Adrian Klaver
adrian.klaver@aklaver.com


Re: [GENERAL] Recover PostgreSQL database folder data

От
Edson Lidorio
Дата:

On 21-04-2017 17:43, Adrian Klaver wrote:
> On 04/21/2017 01:36 PM, Edson Lidorio wrote:
>>
>>
>> On 21-04-2017 17:27, Scott Mead wrote:
>>> chown *-R* postgres:postgres /var/lib/pgsql/9.6/data
>>
>> Chown -R postgres: postgres /var/lib/pgsql/9.6/data
>>   Sudo systemctl start postgresql-9.6
>
> Is this on the first VM you showed previously or the new one you said
> you where going to create?
>
>>
>> Erros:
>>
>> Unit postgresql-9.6.service entered failed state.
>> Abr 21 07:50:11 localhost.localdomain systemd[1]: postgresql-9.6.service
>> failed.
>> Abr 21 07:50:11 localhost.localdomain polkitd[693]: Unregistered
>> Authentication Agent for unix-process:30276:3843896 (system bus name
>> :1.486, object p
>> lines 2341-2377/2377 (END)
>>
>>
>> /var/lib/pgsql/9.6/data/" is missing or empty.
>
> Is it empty, because before it was not?
>
>
>> Apr 21 07:50:11 localhost postgresql96-check-db-dir: Use
>> "/usr/pgsql-9.6/bin/postgresql96-setup initdb" to initialize the
>> database cluster.
>> Apr 21 07:50:11 localhost postgresql96-check-db-dir: See
>> /usr/share/doc/postgresql96/README.rpm-dist for more information.
>> Apr 21 07:50:11 localhost systemd: postgresql-9.6.service: control
>> process exited, code=exited status=1
>> Apr 21 07:50:11 localhost systemd: Failed to start PostgreSQL 9.6
>> database server.
>> Apr 21 07:50:11 localhost systemd: Unit postgresql-9.6.service entered
>> failed state.
>> Apr 21 07:50:11 localhost systemd: postgresql-9.6.service failed.
>>
>>
>
>
In the new

Is it empty, because before it was not?
It's strange the date folder, old is there with the data!


Re: [GENERAL] Recover PostgreSQL database folder data

От
Adrian Klaver
Дата:
On 04/21/2017 01:53 PM, Edson Lidorio wrote:
>
>
> On 21-04-2017 17:43, Adrian Klaver wrote:
>> On 04/21/2017 01:36 PM, Edson Lidorio wrote:
>>>
>>>
>>> On 21-04-2017 17:27, Scott Mead wrote:
>>>> chown *-R* postgres:postgres /var/lib/pgsql/9.6/data
>>>
>>> Chown -R postgres: postgres /var/lib/pgsql/9.6/data
>>>   Sudo systemctl start postgresql-9.6
>>
>> Is this on the first VM you showed previously or the new one you said
>> you where going to create?
>>
>>>
>>> Erros:
>>>
>>> Unit postgresql-9.6.service entered failed state.
>>> Abr 21 07:50:11 localhost.localdomain systemd[1]: postgresql-9.6.service
>>> failed.
>>> Abr 21 07:50:11 localhost.localdomain polkitd[693]: Unregistered
>>> Authentication Agent for unix-process:30276:3843896 (system bus name
>>> :1.486, object p
>>> lines 2341-2377/2377 (END)
>>>
>>>
>>> /var/lib/pgsql/9.6/data/" is missing or empty.
>>
>> Is it empty, because before it was not?
>>
>>
>>> Apr 21 07:50:11 localhost postgresql96-check-db-dir: Use
>>> "/usr/pgsql-9.6/bin/postgresql96-setup initdb" to initialize the
>>> database cluster.
>>> Apr 21 07:50:11 localhost postgresql96-check-db-dir: See
>>> /usr/share/doc/postgresql96/README.rpm-dist for more information.
>>> Apr 21 07:50:11 localhost systemd: postgresql-9.6.service: control
>>> process exited, code=exited status=1
>>> Apr 21 07:50:11 localhost systemd: Failed to start PostgreSQL 9.6
>>> database server.
>>> Apr 21 07:50:11 localhost systemd: Unit postgresql-9.6.service entered
>>> failed state.
>>> Apr 21 07:50:11 localhost systemd: postgresql-9.6.service failed.
>>>
>>>
>>
>>
> In the new

So why not try:

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

on the previous system. Not sure if is was a transcribing error, but in
your previous post you had:

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

which would not work.

>
> Is it empty, because before it was not?
> It's strange the date folder, old is there with the data!

Just to be clear we are talking about the data/ directory.

Could we see the listings for data/ data_old?

>


--
Adrian Klaver
adrian.klaver@aklaver.com


Re: [GENERAL] Recover PostgreSQL database folder data

От
Edson Lidorio
Дата:

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.



Re: [GENERAL] Recover PostgreSQL database folder data

От
Adrian Klaver
Дата:
On 04/21/2017 02:13 PM, 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:

What does the directory listing for /var/lib/pgsql/9.6/data  show?
>
> 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.
>
>
>


--
Adrian Klaver
adrian.klaver@aklaver.com


Re: [GENERAL] Recover PostgreSQL database folder data

От
John R Pierce
Дата:
On 4/21/2017 2:13 PM, Edson Lidorio wrote:
Apr 21 18:11:41 localhost postgresql96-check-db-dir: "/var/lib/pgsql/9.6/data/" is missing or empty.

whats there?

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


-- 
john r pierce, recycling bits in santa cruz

Re: [GENERAL] Recover PostgreSQL database folder data

От
Alan Hodgson
Дата:
> On Fri, Apr 21, 2017 at 12:40 PM, Edson Lidorio <edson@openmailbox.org>
>
> wrote:
> > Hi,
> > There was a disaster in my development note. I was able to recover the
> > data folder. PostgreSQL 9.6.2, was installed in Centos 7.
> >
> > Here are the procedures I'm trying to initialize Postgresql for me to do a
> > backup.
> >
> > 1- I installed PostgreSQL 9.6.2 on a VM with Centos 7.
> > 2- I stopped the PostgreSQL service: sudo systemctl stop postgresql-9.6
> > 3- I renamed the /var/lib/pgsql/9.6/data folder to date data_old and
> > copied the old date folder
> >
> > 4- I gave permission in the folder date:
> >      sudo chown postgres: postgres /var/lib/pgsql/9.6/data;

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).

as root:

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

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.


Re: [GENERAL] Recover PostgreSQL database folder data

От
Edson Lidorio
Дата:

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@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@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


Re: [GENERAL] Recover PostgreSQL database folder data

От
"David G. Johnston"
Дата:
On Friday, April 21, 2017, Edson Lidorio <edson@openmailbox.org> wrote:
4- I gave permission in the folder date:
     sudo chown postgres: postgres /var/lib/pgsql/9.6/data;
     sudo chmod 700 /var/lib/pgsql/9.6/data

You might want to check and see what permissions the original package installed directory had and emulate those instead of blindly dropping a 700 on it.

David J.

Re: [GENERAL] Recover PostgreSQL database folder data

От
Adrian Klaver
Дата:
On 04/21/2017 04:20 PM, Edson Lidorio wrote:
>
>
> On 21-04-2017 18:13, Edson Lidorio wrote:

> What does the directory listing for /var/lib/pgsql/9.6/data  show?
> [root@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@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

Not sure it applies here,  but I see that in the above file you have
tablespace links.

Are those tablespaces actually there?

Can you find postgresql96-check-db-dir and see what it is looking for?

>
>


--
Adrian Klaver
adrian.klaver@aklaver.com


Re: [GENERAL] Recover PostgreSQL database folder data

От
Edson Lidorio
Дата:

On 21-04-2017 20:55, Adrian Klaver wrote:
> On 04/21/2017 04:20 PM, Edson Lidorio wrote:
>>
>>
>> On 21-04-2017 18:13, Edson Lidorio wrote:
>
>> What does the directory listing for /var/lib/pgsql/9.6/data  show?
>> [root@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@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
>
> Not sure it applies here,  but I see that in the above file you have
> tablespace links.
>
> Are those tablespaces actually there?
>
> Can you find postgresql96-check-db-dir and see what it is looking for?
>
>>
>>
>
>
The tablespace exists I have restored in the same directory that was
/var/tablespace_pgsql
  chown -R postgres:postgres /var/tablespace_pgsql/
chmod 700 /var/tablespace_pgsql/



Re: [GENERAL] Recover PostgreSQL database folder data

От
Adrian Klaver
Дата:
On 04/21/2017 04:20 PM, Edson Lidorio wrote:
>
>
> 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@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@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

Found postgresql96-check-db-dir in the RPM, it looks straight forward
and should not be failing from what I see.

>
>


--
Adrian Klaver
adrian.klaver@aklaver.com


Re: [GENERAL] Recover PostgreSQL database folder data

От
Cat
Дата:
On Fri, Apr 21, 2017 at 08:20:38PM -0300, Edson Lidorio wrote:
> 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 ..

Ensure that the user 'postgres' has permissions to get to
this dir from / up. This may either mean changing permissions
on some directories or changing ownership.

More than likely / /var /lib are a permissions thing (likely
need to be u+rwx,g+rx,o+rx) and /var/lib/pgsql/ and up is an
ownership thing (postgres:postgres) but this is not guaranteed
so take care.

--
  "A search of his car uncovered pornography, a homemade sex aid, women's
  stockings and a Jack Russell terrier."
    - http://www.dailytelegraph.com.au/news/wacky/indeed/story-e6frev20-1111118083480


Re: [GENERAL] Recover PostgreSQL database folder data

От
Magnus Hagander
Дата:


On Sat, Apr 22, 2017 at 3:05 AM, Cat <cat@zip.com.au> wrote:
On Fri, Apr 21, 2017 at 08:20:38PM -0300, Edson Lidorio wrote:
> 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 ..

Ensure that the user 'postgres' has permissions to get to
this dir from / up. This may either mean changing permissions
on some directories or changing ownership.

More than likely / /var /lib are a permissions thing (likely
need to be u+rwx,g+rx,o+rx) and /var/lib/pgsql/ and up is an
ownership thing (postgres:postgres) but this is not guaranteed
so take care.

Since this is CentOS, I would also look into if it's selinux things that are incorrect. The easiest way is to turn it off and see if that fixes it -- if it does, then read up on the selinux docs for how to figure out what is wrong and probably use restorecon to get things back in order. 

--

Re: [GENERAL] Recover PostgreSQL database folder data

От
Edson Lidorio
Дата:



On 22-04-2017 06:40, Magnus Hagander wrote:


On Sat, Apr 22, 2017 at 3:05 AM, Cat <cat@zip.com.au> wrote:
On Fri, Apr 21, 2017 at 08:20:38PM -0300, Edson Lidorio wrote:
> 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 ..

Ensure that the user 'postgres' has permissions to get to
this dir from / up. This may either mean changing permissions
on some directories or changing ownership.

More than likely / /var /lib are a permissions thing (likely
need to be u+rwx,g+rx,o+rx) and /var/lib/pgsql/ and up is an
ownership thing (postgres:postgres) but this is not guaranteed
so take care.

Since this is CentOS, I would also look into if it's selinux things that are incorrect. The easiest way is to turn it off and see if that fixes it -- if it does, then read up on the selinux docs for how to figure out what is wrong and probably use restorecon to get things back in order. 

--
Friends,
The problem, was the selinux of CentOS, I disabled the selinux and applied the pemissions again and PostgreSQL started normally.

Used Commands:
# sudo /usr/sbin/setenforce 0
# sudo chown postgres /var/lib/pgsql/9.6/
#  sudo chown postgres:postgres /var/lib/pgsql/9.6/data
# chmod 700 /var/lib/pgsql/9.6/
# sudo systemctl start postgresql-9.6

Thank you all

Note: Looking at google, I noticed that there is more people with this problem. It's a problem with CentOS and PostgreSQL, which does not go down very well.

Re: [GENERAL] Recover PostgreSQL database folder data

От
"Christofer C. Bell"
Дата:
 On Sat, Apr 22, 2017 at 9:11 AM, Edson Lidorio <edson@openmailbox.org> wrote:



On 22-04-2017 06:40, Magnus Hagander wrote:


On Sat, Apr 22, 2017 at 3:05 AM, Cat <cat@zip.com.au> wrote:
On Fri, Apr 21, 2017 at 08:20:38PM -0300, Edson Lidorio wrote:
> 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 ..

Ensure that the user 'postgres' has permissions to get to
this dir from / up. This may either mean changing permissions
on some directories or changing ownership.

More than likely / /var /lib are a permissions thing (likely
need to be u+rwx,g+rx,o+rx) and /var/lib/pgsql/ and up is an
ownership thing (postgres:postgres) but this is not guaranteed
so take care.

Since this is CentOS, I would also look into if it's selinux things that are incorrect. The easiest way is to turn it off and see if that fixes it -- if it does, then read up on the selinux docs for how to figure out what is wrong and probably use restorecon to get things back in order. 

--
Friends,
The problem, was the selinux of CentOS, I disabled the selinux and applied the pemissions again and PostgreSQL started normally.

Used Commands:
# sudo /usr/sbin/setenforce 0
# sudo chown postgres /var/lib/pgsql/9.6/
#  sudo chown postgres:postgres /var/lib/pgsql/9.6/data
# chmod 700 /var/lib/pgsql/9.6/
# sudo systemctl start postgresql-9.6

Thank you all

Note: Looking at google, I noticed that there is more people with this problem. It's a problem with CentOS and PostgreSQL, which does not go down very well.

I think you may want to look into doing this:

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

Then re-enable SELinux and try to start the database again.  You should find that it works.  Rather, if it was working with SELinux on this system before, then it should work after running the restorecon.  Forgetting to reset the necessary SELinux file labels is a common mistake in this kind of situation.

Note:  You don't need to use "sudo" when you're already root.

--
Chris

"If you wish to make an apple pie from scratch, you must first invent the Universe." -- Carl Sagan