Search Postgresql Archives

Re: Recover PostgreSQL database folder data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 On Sat, Apr 22, 2017 at 9:11 AM, Edson Lidorio <edson@xxxxxxxxxxxxxxx> wrote:



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


On Sat, Apr 22, 2017 at 3:05 AM, Cat <cat@xxxxxxxxxx> 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



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux