Page 1 of 1

[SOLVED] cannot set postgresql socket dir

PostPosted: Mar 14th, '14, 15:33
by magfan
Although the variable unix_socket_directory is set in /var/lib/pgsql/data/postgresql.conf postgres opens sockets in /tmp:
Code: Select all
# cat /var/lib/pgsql/data/postgresql.conf | grep unix_socket_directory
unix_socket_directory = '/var/run/postgresql'          # (change requires restart)
# ls -l /tmp/.s*
srwxrwxrwx 1 postgres postgres  0 Mär 14 13:51 /tmp/.s.PGSQL.5432=
-rw------- 1 postgres postgres 46 Mär 14 13:51 /tmp/.s.PGSQL.5432.lock
#

How can I force postgresql to use another socket directory than /tmp?

Code: Select all
# rpm -qa | grep postgres
postgresql9.1-plpgsql-9.1.11-2.mga4
postgresql9.1-devel-9.1.11-2.mga4
postgresql9.1-plpython-9.1.11-2.mga4
postgresql9.1-plperl-9.1.11-2.mga4
postgresql9.1-server-9.1.11-2.mga4
postgresql9.1-9.1.11-2.mga4
postgresql9.1-pl-9.1.11-2.mga4
postgresql9.1-pltcl-9.1.11-2.mga4
postgresql-jdbc-9.2.1002-6.mga4
#

Re: cannot set postgresql socket dir

PostPosted: Mar 19th, '14, 22:31
by davidwhodgins
In Mageia 3 and 4, /var/run is a symlink to /run, which is a tmpfs filesystem.
I haven't tested, but suspect a file fill be needed in /etc/tmpfiles.d to create the
directory /var/run/postgresql
See /usr/lib/tmpfiles.d/initscripts.conf for a sample of the layout, or read
man tmpfiles.d

Regards, Dave Hodgins

Re: cannot set postgresql socket dir

PostPosted: Mar 19th, '14, 22:53
by davidwhodgins
Sorry for the typo. That should be will rather then fill.

Re: cannot set postgresql socket dir

PostPosted: Mar 20th, '14, 14:52
by magfan
Unfortunately, this does not help. Even if I stop postgresql.service and manually create that directory (/var/run/postgresql) starting postgresql.service will place its socket files in /tmp. I know that creating socket files in /tmp is a default for postgresql which can be changed either during compile time (rpm-package should know about it) or by defining unix_socket_directory in /var/lib/pgsql/data/postgresql.conf. The strange thing is that in mga3 I just installed postgresql and it was using /var/run/postgresql. Now after upgrading to mga4 it does not use that directory any more but the default (/tmp). However, somewhere there must be some kind of "system configuration" which tells programs that the socket directory is /var/run/postgresql. I know it because I have a commercial software package which complains during installation that there is no socket file in /var/run/postgresql. How could it know about this path if it is not even the default path? Where could I look for such a hidden configuration parameter?

Re: cannot set postgresql socket dir

PostPosted: Mar 20th, '14, 17:14
by davidwhodgins
I just tried with postgresql9.2 (which I already had installed) ...
Code: Select all
mkdir /var/run/postgresql
chown postgres:postgres /var/run/postgresql
systemctl restart postgresql.service
ll /var/run/postgresql/
total 4
srwxrwxrwx 1 postgres postgres  0 Mar 20 10:49 .s.PGSQL.5432=
-rw------- 1 postgres postgres 62 Mar 20 10:49 .s.PGSQL.5432.lock


Did you chown the directory?

I then created cat /etc/tmpfiles.d/postgres.conf

Code: Select all
d /var/run/postgresql 0755 postgres postgres -


And after rebooting
Code: Select all
ll /var/run/postgresql/
total 4
srwxrwxrwx 1 postgres postgres  0 Mar 20 11:06 .s.PGSQL.5432=
-rw------- 1 postgres postgres 61 Mar 20 11:06 .s.PGSQL.5432.lock


So it's working with postgresql9.2-server

If chown of the directory doesn't fix it for 9.1, I can downgrade, to see if I can recreate the
problem.

Re: cannot set postgresql socket dir

PostPosted: Mar 20th, '14, 18:02
by magfan
No, it still does not work:
Code: Select all
# mkdir /var/run/postgresql
# chown postgres:postgres /var/run/postgresql
# systemctl restart postgresql.service
# ll /var/run/postgresql/
insgesamt 0
# ll /tmp/.s*
srwxrwxrwx 1 postgres postgres  0 Mär 20 16:49 /tmp/.s.PGSQL.5432=
-rw------- 1 postgres postgres 46 Mär 20 16:49 /tmp/.s.PGSQL.5432.lock
#

Re: cannot set postgresql socket dir

PostPosted: Mar 20th, '14, 18:44
by davidwhodgins
I uninstalled all postgresql9 packages, deleted /var/lib/pgsql, installed postgresql9.1-server,
and started the postgresql.service, then edited postgresql.conf
grep socket /var/lib/pgsql/data/postgresql.conf |head -n 1
unix_socket_directory = '/run/postgresql'
Then restarted the service.
[root@x3 data]# ll -d /var/run/postgresql/
drwxr-xr-x 2 postgres postgres 80 Mar 20 12:37 /var/run/postgresql//
[root@x3 data]# ll /var/run/postgresql/
total 4
srwxrwxrwx 1 postgres postgres 0 Mar 20 12:37 .s.PGSQL.5432=
-rw------- 1 postgres postgres 58 Mar 20 12:37 .s.PGSQL.5432.lock

Re: cannot set postgresql socket dir

PostPosted: Mar 20th, '14, 18:54
by davidwhodgins
Is /var/run a symlink to /run?

Only other thing I can think of is that the config file doesn't like have the spaces
before and after the = sign.

Re: cannot set postgresql socket dir

PostPosted: Mar 21st, '14, 11:19
by magfan
Finally I decided to do the following:

1. stopping postgresql.service
2. uninstalling postgresql9.1
3. deleting /var/lib/pgsql completely
4. creating your /etc/tmpfiles.d/postgres.conf
5. rebooting
6. installing postgresql9.1
7. starting postgresql.service
8. editing /var/lib/pgsql/data/postgresql.conf (unix_socket_directory = '/var/run/postgresql)
9. restarting postgresql.service

Now everything works! Great! Thanks a lot!