RHEL 7 Install Works Until Reboot

I am running into issues after installation
(following https://www.theforeman.org/manuals/1.13/index.html#2.Quickstart
for RHEL 7)

In a nutshell, I can run through the installation and everything appears to
be working. I can access the web interface, import puppet modules, etc.
However, as soon as I reboot it no longer works. I can see that the problem
is that postgresql is unable to create the socket file /var/run/postgresql/.s.PGSQL.5432
during startup.

My question is, because I am new to foreman and postgresql (and how they
are intertwined), what do I need to do to enable postgres to create the
socket file? Did I miss some (obvious?) step? Do I need to point postgres
to another location for the socket file (/tmp or /var/lib/pgsql/ ?)

Many thanks!

Do you have selinux enabled? I would guess that is part of the problem.

The solution is to either set the right sebool (setsebool, I think) on the
directory for pgsql, or to disable selinux entirely (which is what I do).

To disable, simply edit /etc/sysconfig/selinux and set SELINUX=disabled,
and then reboot :slight_smile:

··· On Fri, Oct 28, 2016 at 9:37 AM Joe Barnes wrote:

I am running into issues after installation (following
https://www.theforeman.org/manuals/1.13/index.html#2.Quickstart for RHEL
7)

In a nutshell, I can run through the installation and everything appears
to be working. I can access the web interface, import puppet modules, etc.
However, as soon as I reboot it no longer works. I can see that the problem
is that postgresql is unable to create the socket file /var/run/postgresql/.s.PGSQL.5432
during startup.

My question is, because I am new to foreman and postgresql (and how they
are intertwined), what do I need to do to enable postgres to create the
socket file? Did I miss some (obvious?) step? Do I need to point postgres
to another location for the socket file (/tmp or /var/lib/pgsql/ ?)

Many thanks!


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at https://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.

KAYAK

Neil Hanlon

Devops Engineer

+1 978 902 8171

> I am running into issues after installation
> (following https://www.theforeman.org/manuals/1.13/index.html#2.Quickstart
> for RHEL 7)
>
> In a nutshell, I can run through the installation and everything appears
> to be working. I can access the web interface, import puppet modules,
> etc. However, as soon as I reboot it no longer works. I can see that the
> problem is that postgresql is unable to create the socket
> file /var/run/postgresql/.s.PGSQL.5432 during startup.

What is the exact error?

What does ls -ld /var/run/postgresql show, is it there? It should have
postgres:postgres ownership, created via systemd-tmpfiles at boot.

Also ensure that /var/run remains a symlink to /run.

> My question is, because I am new to foreman and postgresql (and how they
> are intertwined), what do I need to do to enable postgres to create the
> socket file? Did I miss some (obvious?) step? Do I need to point
> postgres to another location for the socket file (/tmp or /var/lib/pgsql/ ?)

It's a fairly default installation created with the
puppetlabs-postgresql module, nothing intertwined about it. Foreman is
just configured to connect to it via /etc/foreman/database.yml.

··· On 27/10/16 22:09, Joe Barnes wrote:


Dominic Cleal
dominic@cleal.org

>
> Do you have selinux enabled? I would guess that is part of the problem.
>
Negative

[root@ ~]# grep SELINUX /etc/sysconfig/selinux

SELINUX= can take one of these three values:

SELINUX=disabled

SELINUXTYPE= can take one of three two values:

SELINUXTYPE=targeted

What is the exact error?

-bash-4.2$ /usr/bin/postgres -D /var/lib/pgsql/data/ -p 5432
2016-10-27 14:47:03 PDT FATAL: could not create lock file
"/var/run/postgresql/.s.PGSQL.5432.lock": No such file or directory

What does ls -ld /var/run/postgresql show, is it there? It should have
> postgres:postgres ownership, created via systemd-tmpfiles at boot.
>
It doesn't exist after reboot:

[root@ ~]# ls -ld /var/run/postgresql
ls: cannot access /var/run/postgresql: No such file or directory

> Also ensure that /var/run remains a symlink to /run.

That's something I've actually never seen happen, you definitely made me
look:

[root@ ~]# ls -ld /var/run
lrwxrwxrwx. 1 root root 6 Jan 21 2016 /var/run -> …/run

>
> > My question is, because I am new to foreman and postgresql (and how they
> > are intertwined), what do I need to do to enable postgres to create the
> > socket file? Did I miss some (obvious?) step? Do I need to point
> > postgres to another location for the socket file (/tmp or
> /var/lib/pgsql/ ?)
>
> It's a fairly default installation created with the
> puppetlabs-postgresql module, nothing intertwined about it. Foreman is
> just configured to connect to it via /etc/foreman/database.yml.
>
> Precisely why I am stumped as to how this isn't working. I do, thankfully,
have snapshots of the VM prior to foreman install and after foreman install
(prior to reboot) so I can easily rollback.

I have resolved the issue, here's some detail for others in case they have
this issue:

I reverted back to my snapshot of post foreman install (before reboot) and
did some poking. Making sure that /run/postgresql exists and its
permissions I found:

ls -ld /var/run/postgresql

drwxr-xr-x 2 postgres postdrop 80 Oct 27 10:39 /var/run/postgresql

Check to see which group the postgres user was assigned:

grep postgres /etc/passwd

postgres:x:26:90:PostgreSQL Server:/var/lib/pgsql:/bin/bash

And what is gid 90?

grep postgres /etc/group

··· #

Oh, postgres doesn’t exist…

groupadd postgres

groupadd: group ‘postgres’ already exists

Eh?? Ohhhhhhhh…

getent group postgres

postgres:*:90:

Someone created an LDAP group for postgres which is gid 90, but the local
gid 90 is postdrop… Manually added postgres to /etc/group, updated the
gid for the postgres user in /etc/passwd, rebooted and everything came up
as it should.